From 694ffdbed296498c12c9c21d0e9be4d0b62befc6 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 21 Sep 2022 21:22:38 -0700 Subject: [PATCH] macos: revise how we prevent routing to the IME https://github.com/wez/wezterm/pull/2435 proposed including CTRL-modified keys, but I think that the state of the code now means that we can simplify that area and adjust it so that we will default to routing keys to the IME, but excluding them based on the `send_composed_key_when_(left|right)_alt_is_pressed` configuration. I've only very lightly tested this, but it seems ok with roman text and me punching in random pinyin and then using CTRL-H or CTRL-M to delete or enter. refs: https://github.com/wez/wezterm/pull/2435 --- docs/changelog.md | 2 ++ window/src/os/macos/window.rs | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index cc24dd98f..6238f11d1 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -67,6 +67,8 @@ As features stabilize some brief notes about them will accumulate here. * `tab:panes()` and `tab:panes_with_info()` now return the full list of panes in the tab regardless of whether a pane was zoomed. Previously, if a pane was zoomed, only that pane would be returned by those methods. +* macOS: CTRL-modified keys are now routed to the IME + [#2435](https://github.com/wez/wezterm/pull/2435) #### Updated * Bundled Nerd Font Symbols font to v2.2.2 diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index acca0d1c2..f273df169 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -1597,6 +1597,8 @@ impl WindowView { | "moveUpAndModifySelection:" | "moveDown:" | "moveDownAndModifySelection:" + | "moveToBeginningOfParagraph:" + | "moveToEndOfParagraph:" | "insertTab:" | "insertBacktab:" | "insertNewline:" @@ -2226,21 +2228,18 @@ impl WindowView { }; let alt_mods = Modifiers::LEFT_ALT | Modifiers::RIGHT_ALT | Modifiers::ALT; - let only_alt = (modifiers & alt_mods) == Modifiers::ALT; let only_left_alt = (modifiers & alt_mods) == (Modifiers::LEFT_ALT | Modifiers::ALT); let only_right_alt = (modifiers & alt_mods) == (Modifiers::RIGHT_ALT | Modifiers::ALT); // Also respect `send_composed_key_when_(left|right)_alt_is_pressed` configs // when `use_ime` is true. let forward_to_ime = { - if modifiers.is_empty() || modifiers == Modifiers::SHIFT { - true - } else if only_left_alt && !send_composed_key_when_left_alt_is_pressed { + if only_left_alt && !send_composed_key_when_left_alt_is_pressed { false } else if only_right_alt && !send_composed_key_when_right_alt_is_pressed { false } else { - only_alt + true } };