2018-08-12 22:51:08 +10:00
|
|
|
|
|
|
|
//! This bin folder can be used to try the examples out located in the examples directory.
|
|
|
|
//!
|
|
|
|
//! All you need to do is:
|
|
|
|
//!
|
|
|
|
//! - Download the crossterm source code.
|
|
|
|
//! - Run program with: `cargo run --example examples`
|
|
|
|
|
|
|
|
extern crate crossterm;
|
|
|
|
|
|
|
|
// modules that could be test
|
2018-09-21 06:24:10 +10:00
|
|
|
//mod terminal;
|
2018-08-15 05:40:07 +10:00
|
|
|
mod color;
|
|
|
|
mod cursor;
|
|
|
|
mod some_types;
|
|
|
|
mod input;
|
2018-08-12 22:51:08 +10:00
|
|
|
|
2018-08-22 02:05:53 +10:00
|
|
|
use std::io::Write;
|
2018-09-21 06:24:10 +10:00
|
|
|
|
|
|
|
use crossterm::style::{style, Color, DisplayableObject};
|
|
|
|
use crossterm::terminal::terminal;
|
|
|
|
use crossterm::Screen;
|
|
|
|
|
2018-09-22 05:36:03 +10:00
|
|
|
use crossterm::output::TerminalOutput;
|
2018-09-22 06:22:25 +10:00
|
|
|
use crossterm::cursor::TerminalCursor;
|
2018-09-22 05:36:03 +10:00
|
|
|
|
2018-09-23 06:42:23 +10:00
|
|
|
use crossterm::terminal::Terminal;
|
|
|
|
use std::{thread,time};
|
|
|
|
|
2018-08-22 02:05:53 +10:00
|
|
|
fn main()
|
|
|
|
{
|
2018-09-23 06:42:23 +10:00
|
|
|
let screen = Screen::new(false);
|
|
|
|
let terminal = Terminal::new(&screen.stdout);
|
|
|
|
|
|
|
|
// get terminal size
|
|
|
|
let (x, y) = terminal.terminal_size();
|
|
|
|
|
|
|
|
// set size to 30, 50
|
|
|
|
terminal.set_size(30,50);
|
|
|
|
|
|
|
|
// if we uncomment the line below the code will work perfectly fine and we will get the new dimensions.
|
|
|
|
// if we comment this line the terminal dimensions gotten from terminal_size() are equal to the old dimensions.
|
2018-09-21 06:24:10 +10:00
|
|
|
|
2018-09-23 06:42:23 +10:00
|
|
|
// thread::sleep(time::Duration::from_millis(20));
|
2018-09-22 06:22:25 +10:00
|
|
|
|
2018-09-23 06:42:23 +10:00
|
|
|
// get new dimensions
|
|
|
|
let (x_new, y_new) = terminal.terminal_size();
|
2018-09-22 06:22:25 +10:00
|
|
|
|
2018-09-23 06:42:23 +10:00
|
|
|
println!("old width: {} old height: {}", x, y);
|
|
|
|
println!("new width: {} new height: {}", x_new, y_new);
|
2018-08-12 22:51:08 +10:00
|
|
|
}
|