From 79fe9304511b58577d86a123044677bb7aa11a46 Mon Sep 17 00:00:00 2001 From: Yui Date: Thu, 5 Sep 2024 19:22:59 +0300 Subject: [PATCH] Added Ctrl+Home and Ctrl+End shortcuts to Editbox --- src/ui/widgets/editbox.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ui/widgets/editbox.rs b/src/ui/widgets/editbox.rs index 2ed979cc..d84b1695 100644 --- a/src/ui/widgets/editbox.rs +++ b/src/ui/widgets/editbox.rs @@ -213,20 +213,40 @@ impl<'a> Editbox<'a> { } InputCharacter { key: Key::KeyCode(Home), + modifier_ctrl: false, modifier_shift, .. } => { let to_line_begin = state.find_line_begin(text) as i32; state.move_cursor(text, -to_line_begin, modifier_shift); } + InputCharacter { + key: Key::KeyCode(Home), + modifier_ctrl: true, + modifier_shift, + .. + } => { + let to_text_being = state.cursor as i32; + state.move_cursor(text, -to_text_being, modifier_shift); + } InputCharacter { key: Key::KeyCode(End), + modifier_ctrl: false, modifier_shift, .. } => { let to_line_end = state.find_line_end(text) as i32; state.move_cursor(text, to_line_end, modifier_shift); } + InputCharacter { + key: Key::KeyCode(End), + modifier_ctrl: true, + modifier_shift, + .. + } => { + let to_text_end = (text.len() as u32 - state.cursor) as i32; + state.move_cursor(text, to_text_end, modifier_shift); + } InputCharacter { key: Key::KeyCode(Up), modifier_shift,