33 lines
890 B
Rust
33 lines
890 B
Rust
|
|
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(())
|
||
|
|
}
|