From c99e2989ef4a37dd6c1b01740fe5da36ab53825d Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 3 Nov 2019 11:30:38 -0800 Subject: [PATCH] Fix ctrl-J processing The front-end was treating both \r and \n as Enter and passing that through to the terminal. To verify behavior, pay attention to your termios configuration: ``` $ stty -icrnl $ od -c 0000000 \n 0000001 $ od -c 0000000 \r \n 0000002 ``` Closes https://github.com/wez/wezterm/issues/56 --- src/frontend/gui/termwindow.rs | 2 +- window/src/os/macos/window.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/frontend/gui/termwindow.rs b/src/frontend/gui/termwindow.rs index 0cc889c5b..1a01472ee 100644 --- a/src/frontend/gui/termwindow.rs +++ b/src/frontend/gui/termwindow.rs @@ -186,7 +186,7 @@ impl WindowCallbacks for TermWindow { let key = match key.key { // TODO: consider eliminating these codes from termwiz::input::KeyCode - WK::Char('\r') | WK::Char('\n') => KC::Enter, + WK::Char('\r') => KC::Enter, WK::Char('\t') => KC::Tab, WK::Char('\u{08}') => KC::Backspace, WK::Char('\u{1b}') => KC::Escape, diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index 548261055..9b98b1b6e 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -828,10 +828,6 @@ impl WindowView { let unmod = unsafe { nsstring_to_str(nsevent.charactersIgnoringModifiers()) }; let modifiers = unsafe { key_modifiers(nsevent.modifierFlags()) }; - eprintln!( - "key_common ENTER (down={} chars={:?} unmod={:?} modifiers={:?}", - key_is_down, chars, unmod, modifiers - ); if modifiers.is_empty() && key_is_down { unsafe { let input_context: id = msg_send![this, inputContext]; @@ -861,6 +857,10 @@ impl WindowView { repeat_count: 1, key_is_down, }; + eprintln!( + "key_common {:?} (chars={:?} unmod={:?} modifiers={:?}", + event, chars, unmod, modifiers + ); if let Some(myself) = Self::get_this(this) { let mut inner = myself.inner.borrow_mut();