minicrossterm/examples/simple.rs

47 lines
1.0 KiB
Rust
Raw Normal View History

2018-08-03 20:01:04 +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.
2018-08-03 20:01:04 +10:00
//!
//! - Add this in the Cargo.toml file:
//! ``` [[bin]]
//! name = "example_bin"
//! path = "./examples/bin.rs"
//! ```
//!
//! - Run program with: `cargo run`
extern crate crossterm;
use crossterm::style::Color;
use crossterm::Crossterm;
2018-08-03 20:01:04 +10:00
// mod terminal;
// mod color;
// mod cursor;
// mod crossterm_type;
2018-07-28 02:44:38 +10:00
// mod input;
2018-07-28 02:44:38 +10:00
//use input::keyboard::{async_input, input as stdin};
2018-07-22 22:55:14 +10:00
use std::{thread, time};
2018-07-22 22:55:14 +10:00
fn main() {
2018-08-03 20:01:04 +10:00
do_something();
}
fn do_something()
{
let mut crossterm = Crossterm::new();
{
let mut cursor = crossterm.cursor(); // <- Immutable borrow occurs here ( cursor(&self) ) end lives until the end of this function call.
cursor.goto(10, 10);
}
crossterm.to_alternate_screen(); // <- mutable borrow occurs here ( to_alternate_screen(&mut self) ) but because we already have borrowed immutable we can not mutate it.
2018-07-28 18:09:09 +10:00
}
2018-08-03 20:01:04 +10:00