From a39eb66be8a5440b6d2fb65a4ce7af0ff9b7eae0 Mon Sep 17 00:00:00 2001 From: henil Date: Mon, 25 Jan 2021 23:50:07 +0530 Subject: [PATCH] Use alternate buffer --- src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index dd6f91af..cee7398d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -173,6 +173,12 @@ pub enum AppInstruction { } pub fn start(mut os_input: Box, opts: CliArgs) { + let take_snapshot = "\u{1b}[?1049h"; + os_input.unset_raw_mode(0); + let _ = os_input + .get_stdout_writer() + .write(take_snapshot.as_bytes()) + .unwrap(); let mut app_state = AppState::default(); let command_is_executing = CommandIsExecuting::new(); @@ -209,6 +215,7 @@ pub fn start(mut os_input: Box, opts: CliArgs) { os_input.clone(), opts.debug, ); + // Don't use default layouts in tests, but do everywhere else #[cfg(not(test))] let default_layout = Some(PathBuf::from("default")); @@ -683,10 +690,11 @@ pub fn start(mut os_input: Box, opts: CliArgs) { // cleanup(); let reset_style = "\u{1b}[m"; let show_cursor = "\u{1b}[?25h"; + let restore_snapshot = "\u{1b}[?1049l"; let goto_start_of_last_line = format!("\u{1b}[{};{}H", full_screen_ws.rows, 1); let goodbye_message = format!( - "{}\n{}{}Bye from Mosaic!", - goto_start_of_last_line, reset_style, show_cursor + "{}\n{}{}{}Bye from Mosaic!", + goto_start_of_last_line, restore_snapshot, reset_style, show_cursor ); os_input.unset_raw_mode(0);