diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-11-16 01:44:04 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-11-16 01:44:04 +0200 |
commit | 7590cc7b52d7e2751e71771e3fc7e3a7057ad97f (patch) | |
tree | 92d9cbb9bd8e1966708c45ef7df5e203e4b7bb41 | |
parent | 80630ae9ba9739b263fe096573cb05d5661b4549 (diff) |
Switch to main screen when quitting
Closes #12
-rw-r--r-- | src/ui/state.rs | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/ui/state.rs b/src/ui/state.rs index f6766c8..c1ee2d6 100644 --- a/src/ui/state.rs +++ b/src/ui/state.rs @@ -35,7 +35,7 @@ use std::io::Write; use termion::raw::IntoRawMode; use termion::screen::AlternateScreen; -use termion::{clear, cursor, style}; +use termion::{clear, cursor}; #[derive(PartialEq)] pub enum UIMode { @@ -91,17 +91,7 @@ pub struct State { impl Drop for State { fn drop(&mut self) { // When done, restore the defaults to avoid messing with the terminal. - write!( - self.stdout(), - "{}{}{}{}{}", - clear::All, - style::Reset, - cursor::Goto(1, 1), - cursor::Show, - BracketModeEnd, - ) - .unwrap(); - self.flush(); + self.switch_to_main_screen(); } } @@ -167,9 +157,10 @@ impl State { pub fn switch_to_main_screen(&mut self) { write!( self.stdout(), - "{}{}", + "{}{}{}", termion::screen::ToMainScreen, - cursor::Show + cursor::Show, + BracketModeEnd, ) .unwrap(); self.flush(); @@ -183,11 +174,12 @@ impl State { write!( self.stdout(), - "{}{}{}{}", + "{}{}{}{}{}", termion::screen::ToAlternateScreen, cursor::Hide, clear::All, - cursor::Goto(1, 1) + cursor::Goto(1, 1), + BracketModeStart, ) .unwrap(); self.flush(); |