diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cec85e..6717d09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ Released on 21/06/2021 - If the terminal window has less than 24 lines, then an error message is displayed in the auth activity - Changed auth layout to absolute sizes - Bugfix: + - Fixed termscp on Windows dying whenever opening a file with text editor - Fixed broken input cursor when typing UTF8 characters (tui-realm 0.3.2) - Fixed [Issue 44](https://github.com/veeso/termscp/issues/44): Could not move files to other paths in FTP - Fixed [Issue 43](https://github.com/veeso/termscp/issues/43): Could not remove non-empty directories in FTP diff --git a/src/ui/activities/filetransfer/actions/edit.rs b/src/ui/activities/filetransfer/actions/edit.rs index 42de105..82b02e9 100644 --- a/src/ui/activities/filetransfer/actions/edit.rs +++ b/src/ui/activities/filetransfer/actions/edit.rs @@ -113,6 +113,7 @@ impl FileTransferActivity { error!("Failed to disable raw mode: {}", err); } // Leave alternate mode + #[cfg(not(target_os = "windows"))] if let Some(ctx) = self.context.as_mut() { ctx.leave_alternate_screen(); } @@ -127,6 +128,7 @@ impl FileTransferActivity { ), Err(err) => return Err(format!("Could not open editor: {}", err)), } + #[cfg(not(target_os = "windows"))] if let Some(ctx) = self.context.as_mut() { // Clear screen ctx.clear_screen(); diff --git a/src/ui/activities/setup/actions.rs b/src/ui/activities/setup/actions.rs index d965d42..4ca3aeb 100644 --- a/src/ui/activities/setup/actions.rs +++ b/src/ui/activities/setup/actions.rs @@ -115,6 +115,7 @@ impl SetupActivity { error!("Failed to disable raw mode: {}", err); } // Leave alternate mode + #[cfg(not(target_os = "windows"))] if let Some(ctx) = self.context.as_mut() { ctx.leave_alternate_screen(); } @@ -149,6 +150,7 @@ impl SetupActivity { } } // Restore terminal + #[cfg(not(target_os = "windows"))] if let Some(ctx) = self.context.as_mut() { // Clear screen ctx.clear_screen(); diff --git a/src/ui/activities/setup/config.rs b/src/ui/activities/setup/config.rs index 25c1b0d..2373134 100644 --- a/src/ui/activities/setup/config.rs +++ b/src/ui/activities/setup/config.rs @@ -92,6 +92,7 @@ impl SetupActivity { error!("Failed to disable raw mode: {}", err); } // Leave alternate mode + #[cfg(not(target_os = "windows"))] ctx.leave_alternate_screen(); // Get result let result: Result<(), String> = match ctx.config_client.as_ref() { @@ -121,6 +122,7 @@ impl SetupActivity { // Clear screen ctx.clear_screen(); // Enter alternate mode + #[cfg(not(target_os = "windows"))] ctx.enter_alternate_screen(); // Re-enable raw mode if let Err(err) = enable_raw_mode() { diff --git a/src/ui/context.rs b/src/ui/context.rs index dd84e0c..d9affa6 100644 --- a/src/ui/context.rs +++ b/src/ui/context.rs @@ -103,6 +103,7 @@ impl Context { /// ### enter_alternate_screen /// /// Enter alternate screen (gui window) + #[cfg(not(target_os = "windows"))] pub fn enter_alternate_screen(&mut self) { match execute!( self.terminal.backend_mut(), @@ -190,9 +191,12 @@ mod tests { assert!(ctx.get_error().is_some()); assert!(ctx.get_error().is_none()); // Try other methods - ctx.enter_alternate_screen(); - ctx.clear_screen(); - ctx.leave_alternate_screen(); + #[cfg(not(target_os = "windows"))] + { + ctx.enter_alternate_screen(); + ctx.clear_screen(); + ctx.leave_alternate_screen(); + } drop(ctx); } }