Skip to content

Commit

Permalink
Added Ctrl+Home and Ctrl+End shortcuts to Editbox
Browse files Browse the repository at this point in the history
  • Loading branch information
yui-915 committed Sep 5, 2024
1 parent fc56d5e commit 79fe930
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/ui/widgets/editbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 79fe930

Please sign in to comment.