diff options
author | Christian Duerr <contact@christianduerr.com> | 2024-10-15 14:06:59 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-15 17:06:59 +0300 |
commit | 6ba69f8dd469e1a9aff0b48b3ae10ce4510ca1e3 (patch) | |
tree | 39f86be15c954a2337fb30de92e38235deb7d024 /alacritty/src/event.rs | |
parent | a5bb567c0a15bed65ff18c94d04c8c147bf817a9 (diff) | |
download | r-alacritty-6ba69f8dd469e1a9aff0b48b3ae10ce4510ca1e3.tar.gz r-alacritty-6ba69f8dd469e1a9aff0b48b3ae10ce4510ca1e3.tar.bz2 r-alacritty-6ba69f8dd469e1a9aff0b48b3ae10ce4510ca1e3.zip |
Add IME support to inline search
This changes the behavior of inline search from only accepting direct
key inputs, to also accepting IME and paste. The additional characters
are still being discarded, matching the existing behavior.
This also fixes an issue where inline search wouldn't work for
characters requiring modifiers, since the modifier press was interpreted
as the search target instead.
Closes #8208.
Diffstat (limited to 'alacritty/src/event.rs')
-rw-r--r-- | alacritty/src/event.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index 46e9433c..23575e21 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -1218,6 +1218,8 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon for c in text.chars() { self.search_input(c); } + } else if self.inline_search_state.char_pending { + self.inline_search_input(text); } else if bracketed && self.terminal().mode().contains(TermMode::BRACKETED_PASTE) { self.on_terminal_input_start(); @@ -1291,6 +1293,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon self.inline_search_state.stop_short = stop_short; self.inline_search_state.direction = direction; self.inline_search_state.char_pending = true; + self.inline_search_state.character = None; } /// Jump to the next matching character in the line. @@ -1305,6 +1308,22 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon self.inline_search(direction); } + /// Process input during inline search. + fn inline_search_input(&mut self, text: &str) { + // Ignore input with empty text, like modifier keys. + let c = match text.chars().next() { + Some(c) => c, + None => return, + }; + + self.inline_search_state.char_pending = false; + self.inline_search_state.character = Some(c); + self.window().set_ime_allowed(false); + + // Immediately move to the captured character. + self.inline_search_next(); + } + fn message(&self) -> Option<&Message> { self.message_buffer.message() } |