Browse Source
Add some macOS emacs keybindings (#1243)
Move cursor left: ^B
Move cursor right: ^F
Beginning of line: ^A
End of line: ^E
Line up: ^P
Line down: ^N
pull/1270/head
Benedikt Terhechte
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
21 additions and
0 deletions
-
CHANGELOG.md
-
egui/src/widgets/text_edit/builder.rs
|
|
@ -8,6 +8,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w |
|
|
|
## Unreleased |
|
|
|
|
|
|
|
### Added ⭐ |
|
|
|
* Support a subset of macOS' emacs input field keybindings in `TextEdit` ([#1243](https://github.com/emilk/egui/pull/1243). |
|
|
|
* Much improved font selection ([#1154](https://github.com/emilk/egui/pull/1154)): |
|
|
|
* You can now select any font size and family using `RichText::size` amd `RichText::family` and the new `FontId`. |
|
|
|
* Easily change text styles with `Style::text_styles`. |
|
|
|
|
|
@ -1092,11 +1092,31 @@ fn on_key_press( |
|
|
|
None |
|
|
|
} |
|
|
|
|
|
|
|
Key::P | Key::N | Key::B | Key::F | Key::A | Key::E |
|
|
|
if cfg!(target_os = "macos") && modifiers.ctrl && !modifiers.shift => |
|
|
|
{ |
|
|
|
move_single_cursor(&mut cursor_range.primary, galley, key, modifiers); |
|
|
|
cursor_range.secondary = cursor_range.primary; |
|
|
|
None |
|
|
|
} |
|
|
|
|
|
|
|
_ => None, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fn move_single_cursor(cursor: &mut Cursor, galley: &Galley, key: Key, modifiers: &Modifiers) { |
|
|
|
if cfg!(target_os = "macos") && modifiers.ctrl && !modifiers.shift { |
|
|
|
match key { |
|
|
|
Key::A => *cursor = galley.cursor_begin_of_row(cursor), |
|
|
|
Key::E => *cursor = galley.cursor_end_of_row(cursor), |
|
|
|
Key::P => *cursor = galley.cursor_up_one_row(cursor), |
|
|
|
Key::N => *cursor = galley.cursor_down_one_row(cursor), |
|
|
|
Key::B => *cursor = galley.cursor_left_one_character(cursor), |
|
|
|
Key::F => *cursor = galley.cursor_right_one_character(cursor), |
|
|
|
_ => (), |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
match key { |
|
|
|
Key::ArrowLeft => { |
|
|
|
if modifiers.alt || modifiers.ctrl { |
|
|
|