Fixed issue 70: Unable to type characters with CTRL+ALT

This commit is contained in:
veeso 2021-10-04 20:40:24 +02:00
parent 58d5ea264f
commit 4973bf8cbe
7 changed files with 39 additions and 18 deletions

View File

@ -51,13 +51,15 @@ Released on 12/10/2021
- Enhancements:
- Reuse mounts in UI, in order to reduce executable size
- File list can now be "rewinded", which means that moving with arrows will now allow you to go from top to bottom of the list pressing `<UP>` and viceversa pressing `<DOWN>`.
- Bugfix:
- Fixed [Issue 70](https://github.com/veeso/termscp/issues/70): Unable to type characters with `CTRL+ALT` (e.g. italian layout `CTRL+ALT+ò` => `@`) due to a crossterm issue. Fixed with tui-realm-stdlib `0.6.3`.
- Dependencies:
- Added `notify_rust 4.5.3`
- Added `rust-s3 0.27-rc4`
- Added `self_update 0.27.0`
- Updated `argh` to `0.1.6`
- Updated `dirs` to `4.0.0`
- Updated `tui-realm-stdlib` to `0.6.2`
- Updated `tui-realm-stdlib` to `0.6.3`
- Removed `ureq`
## 0.6.1

4
Cargo.lock generated
View File

@ -2390,9 +2390,9 @@ dependencies = [
[[package]]
name = "tui-realm-stdlib"
version = "0.6.2"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54af02e93599f275c1eb0286235c935f60501d7ae1b554cfb1c9c584ca0193ff"
checksum = "f159d383b40dec75e0541530bc3416318f5e0a8b6999db9df9b5efa6b122380e"
dependencies = [
"textwrap",
"tuirealm",

View File

@ -55,7 +55,7 @@ tempfile = "3.1.0"
textwrap = "0.14.2"
thiserror = "^1.0.0"
toml = "0.5.8"
tui-realm-stdlib = "0.6.2"
tui-realm-stdlib = "0.6.3"
tuirealm = "0.6.0"
whoami = "1.1.1"
wildmatch = "2.0.0"

View File

@ -113,7 +113,6 @@ 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();
}
@ -128,7 +127,6 @@ 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();

View File

@ -182,7 +182,6 @@ 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();
}
@ -215,7 +214,6 @@ impl SetupActivity {
}
}
// Restore terminal
#[cfg(not(target_os = "windows"))]
if let Some(ctx) = self.context.as_mut() {
// Clear screen
ctx.clear_screen();

View File

@ -98,7 +98,6 @@ 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().iter_ssh_keys().nth(idx) {
@ -123,7 +122,6 @@ 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() {

View File

@ -33,9 +33,12 @@ use crate::system::config_client::ConfigClient;
use crate::system::theme_provider::ThemeProvider;
// Includes
use crossterm::event::DisableMouseCapture;
use crossterm::execute;
use crossterm::terminal::{EnterAlternateScreen, LeaveAlternateScreen};
#[cfg(target_family = "unix")]
use crossterm::{
event::DisableMouseCapture,
execute,
terminal::{EnterAlternateScreen, LeaveAlternateScreen},
};
use std::io::{stdout, Stdout};
use tuirealm::tui::backend::CrosstermBackend;
use tuirealm::tui::Terminal;
@ -64,15 +67,12 @@ impl Context {
theme_provider: ThemeProvider,
error: Option<String>,
) -> Context {
// Create terminal
let mut stdout = stdout();
assert!(execute!(stdout, EnterAlternateScreen).is_ok());
Context {
ft_params: None,
config_client,
store: Store::init(),
input_hnd: InputHandler::new(),
terminal: Terminal::new(CrosstermBackend::new(stdout)).unwrap(),
terminal: Terminal::new(CrosstermBackend::new(Self::stdout())).unwrap(),
theme_provider,
error,
}
@ -141,7 +141,7 @@ impl Context {
/// ### enter_alternate_screen
///
/// Enter alternate screen (gui window)
#[cfg(not(target_os = "windows"))]
#[cfg(target_family = "unix")]
pub fn enter_alternate_screen(&mut self) {
match execute!(
self.terminal.backend_mut(),
@ -153,9 +153,16 @@ impl Context {
}
}
/// ### enter_alternate_screen
///
/// Enter alternate screen (gui window)
#[cfg(target_family = "windows")]
pub fn enter_alternate_screen(&self) {}
/// ### leave_alternate_screen
///
/// Go back to normal screen (gui window)
#[cfg(target_family = "unix")]
pub fn leave_alternate_screen(&mut self) {
match execute!(
self.terminal.backend_mut(),
@ -167,6 +174,12 @@ impl Context {
}
}
/// ### leave_alternate_screen
///
/// Go back to normal screen (gui window)
#[cfg(target_family = "windows")]
pub fn leave_alternate_screen(&self) {}
/// ### clear_screen
///
/// Clear terminal screen
@ -176,6 +189,18 @@ impl Context {
Ok(_) => info!("Cleared screen"),
}
}
#[cfg(target_family = "unix")]
fn stdout() -> Stdout {
let mut stdout = stdout();
assert!(execute!(stdout, EnterAlternateScreen).is_ok());
stdout
}
#[cfg(target_family = "windows")]
fn stdout() -> Stdout {
stdout()
}
}
impl Drop for Context {