Initial commit
This commit is contained in:
32
main.rs
Normal file
32
main.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use crossterm::{
|
||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event},
|
||||
execute,
|
||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||
};
|
||||
use std::io::{self};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
enable_raw_mode()?;
|
||||
let mut stdout = io::stdout();
|
||||
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
|
||||
|
||||
execute!(
|
||||
stdout,
|
||||
crossterm::terminal::Clear(crossterm::terminal::ClearType::All)
|
||||
)?;
|
||||
execute!(stdout, crossterm::cursor::MoveTo(0, 0))?;
|
||||
println!("Hello, World!");
|
||||
execute!(stdout, crossterm::cursor::MoveTo(0, 1))?;
|
||||
println!("Press any key to exit.");
|
||||
|
||||
loop {
|
||||
if let Event::Key(_) = event::read()? {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
disable_raw_mode()?;
|
||||
execute!(stdout, LeaveAlternateScreen, DisableMouseCapture)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user