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/input | |
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/input')
-rw-r--r-- | alacritty/src/input/keyboard.rs | 15 | ||||
-rw-r--r-- | alacritty/src/input/mod.rs | 1 |
2 files changed, 6 insertions, 10 deletions
diff --git a/alacritty/src/input/keyboard.rs b/alacritty/src/input/keyboard.rs index 4bc3ffee..14755594 100644 --- a/alacritty/src/input/keyboard.rs +++ b/alacritty/src/input/keyboard.rs @@ -1,5 +1,4 @@ use std::borrow::Cow; -use std::mem; use winit::event::{ElementState, KeyEvent}; #[cfg(target_os = "macos")] @@ -29,6 +28,9 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> { let mods = self.ctx.modifiers().state(); if key.state == ElementState::Released { + if self.ctx.inline_search_state().char_pending { + self.ctx.window().set_ime_allowed(true); + } self.key_release(key, mode, mods); return; } @@ -45,15 +47,8 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> { // First key after inline search is captured. let inline_state = self.ctx.inline_search_state(); - if mem::take(&mut inline_state.char_pending) { - if let Some(c) = text.chars().next() { - inline_state.character = Some(c); - - // Immediately move to the captured character. - self.ctx.inline_search_next(); - } - - // Ignore all other characters in `text`. + if inline_state.char_pending { + self.ctx.inline_search_input(text); return; } diff --git a/alacritty/src/input/mod.rs b/alacritty/src/input/mod.rs index c10777f2..bbd8673f 100644 --- a/alacritty/src/input/mod.rs +++ b/alacritty/src/input/mod.rs @@ -127,6 +127,7 @@ pub trait ActionContext<T: EventListener> { fn inline_search_state(&mut self) -> &mut InlineSearchState; fn start_inline_search(&mut self, _direction: Direction, _stop_short: bool) {} fn inline_search_next(&mut self) {} + fn inline_search_input(&mut self, _text: &str) {} fn inline_search_previous(&mut self) {} fn hint_input(&mut self, _character: char) {} fn trigger_hint(&mut self, _hint: &HintMatch) {} |