minicrossterm/examples/examples.rs

52 lines
1.3 KiB
Rust
Raw Normal View History

//! 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
//mod terminal;
mod color;
mod cursor;
mod some_types;
mod input;
2018-08-22 02:05:53 +10:00
use std::io::Write;
use crossterm::style::{style, Color, DisplayableObject};
use crossterm::terminal::terminal;
use crossterm::Screen;
use crossterm::output::TerminalOutput;
2018-09-22 06:22:25 +10:00
use crossterm::cursor::TerminalCursor;
use crossterm::terminal::Terminal;
use std::{thread,time};
2018-08-22 02:05:53 +10:00
fn main()
{
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.
// thread::sleep(time::Duration::from_millis(20));
2018-09-22 06:22:25 +10:00
// get new dimensions
let (x_new, y_new) = terminal.terminal_size();
2018-09-22 06:22:25 +10:00
println!("old width: {} old height: {}", x, y);
println!("new width: {} new height: {}", x_new, y_new);
}