cargo fmt (#132)
This commit is contained in:
parent
7880812bd0
commit
a4ff052119
@ -1,7 +1,7 @@
|
|||||||
extern crate crossterm;
|
extern crate crossterm;
|
||||||
|
|
||||||
use crossterm::{style, AlternateScreen, ClearType, Color, Crossterm};
|
use crossterm::{style, AlternateScreen, ClearType, Color, Crossterm};
|
||||||
use std::{thread, time, io};
|
use std::{io, thread, time};
|
||||||
|
|
||||||
fn print_wait_screen() -> io::Result<()> {
|
fn print_wait_screen() -> io::Result<()> {
|
||||||
let crossterm = Crossterm::new();
|
let crossterm = Crossterm::new();
|
||||||
|
@ -1,21 +1,76 @@
|
|||||||
extern crate crossterm;
|
extern crate crossterm;
|
||||||
|
|
||||||
use crossterm::{Color, Crossterm};
|
//use crossterm::{Color, Crossterm};
|
||||||
|
|
||||||
/// use the `Crossterm` to get an instance to the cursor module | demonstration.
|
use crossterm::{
|
||||||
pub fn main() {
|
AlternateScreen, Attribute, ClearType, Crossterm, InputEvent, KeyEvent, Styler, TerminalCursor,
|
||||||
// Create the crossterm type to access different modules.
|
};
|
||||||
let crossterm = Crossterm::new();
|
use std::io::Write;
|
||||||
|
use std::{io, thread, time};
|
||||||
|
|
||||||
// pass a reference to the current screen.
|
fn run() -> io::Result<()> {
|
||||||
let cursor = crossterm.cursor();
|
let alternate_screen = AlternateScreen::to_alternate(true)?;
|
||||||
let color = crossterm.color();
|
let crossterm = crossterm::Crossterm::new();
|
||||||
|
let input = crossterm.input();
|
||||||
|
let mut crossterm_events = input.read_sync();
|
||||||
|
loop {
|
||||||
|
if let Some(event) = crossterm_events.next() {
|
||||||
let terminal = crossterm.terminal();
|
let terminal = crossterm.terminal();
|
||||||
let terminal = crossterm.input();
|
let cursor = crossterm.cursor();
|
||||||
let style = crossterm
|
cursor.goto(1, 1)?;
|
||||||
.style("Black font on green background")
|
terminal.clear(ClearType::UntilNewLine)?;
|
||||||
.with(Color::Black)
|
if let InputEvent::Keyboard(key) = &event {
|
||||||
.on(Color::Green);
|
match key {
|
||||||
|
KeyEvent::Ctrl('q') => {
|
||||||
// TODO: perform some actions with the instances above.
|
println!("quitting...");
|
||||||
|
::std::io::stdout().flush();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
let s = "event";
|
||||||
|
println!(
|
||||||
|
" {}{}{} : {:?}",
|
||||||
|
Attribute::Bold,
|
||||||
|
s,
|
||||||
|
Attribute::Reset,
|
||||||
|
event
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println!("disregarding unrelevant event: {:?}", event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
thread::sleep(time::Duration::from_secs(1));
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
match run() {
|
||||||
|
Ok(_) => {
|
||||||
|
println!("ok");
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("error {:?}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// use the `Crossterm` to get an instance to the cursor module | demonstration.
|
||||||
|
//pub fn main() {
|
||||||
|
// // Create the crossterm type to access different modules.
|
||||||
|
// let crossterm = Crossterm::new();
|
||||||
|
//
|
||||||
|
// // pass a reference to the current screen.
|
||||||
|
// let cursor = crossterm.cursor();
|
||||||
|
// let color = crossterm.color();
|
||||||
|
// let terminal = crossterm.terminal();
|
||||||
|
// let terminal = crossterm.input();
|
||||||
|
// let style = crossterm
|
||||||
|
// .style("Black font on green background")
|
||||||
|
// .with(Color::Black)
|
||||||
|
// .on(Color::Green);
|
||||||
|
//
|
||||||
|
// // TODO: perform some actions with the instances above.
|
||||||
|
//}
|
||||||
|
@ -56,7 +56,7 @@ pub fn clear_from_cursor_up() -> io::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Clear all lines from cursor position X:4, Y:4 up | demonstration
|
/// Clear all lines from cursor position X:4, Y:4 up | demonstration
|
||||||
pub fn clear_current_line() -> io::Result<()>{
|
pub fn clear_current_line() -> io::Result<()> {
|
||||||
let terminal = terminal();
|
let terminal = terminal();
|
||||||
|
|
||||||
print_test_data();
|
print_test_data();
|
||||||
|
Loading…
Reference in New Issue
Block a user