1
0
mirror of https://github.com/danog/ytop.git synced 2024-11-30 04:29:10 +01:00

clear screen on exit if in TTY (Close #36)

This commit is contained in:
Caleb Bassi 2020-02-06 13:48:11 -08:00
parent 8efb816674
commit 0ed8d75fa7

View File

@ -35,6 +35,8 @@ fn setup_terminal() -> Result<Terminal<CrosstermBackend<io::Stdout>>> {
execute!(stdout, terminal::EnterAlternateScreen)?;
execute!(stdout, cursor::Hide)?;
// for TTYs
execute!(stdout, terminal::Clear(terminal::ClearType::All))?;
terminal::enable_raw_mode()?;
@ -48,6 +50,10 @@ fn setup_terminal() -> Result<Terminal<CrosstermBackend<io::Stdout>>> {
fn cleanup_terminal() -> Result<()> {
let mut stdout = io::stdout();
// for TTYs
execute!(stdout, cursor::MoveTo(0, 0))?;
execute!(stdout, terminal::Clear(terminal::ClearType::All))?;
execute!(stdout, terminal::LeaveAlternateScreen)?;
execute!(stdout, cursor::Show)?;