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
This commit is contained in:
parent
e746e3a58b
commit
8e62b382fd
2 changed files with 21 additions and 0 deletions
|
@ -8,6 +8,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
### Added ⭐
|
### 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)):
|
* 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`.
|
* 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`.
|
* Easily change text styles with `Style::text_styles`.
|
||||||
|
|
|
@ -1092,11 +1092,31 @@ fn on_key_press(
|
||||||
None
|
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,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_single_cursor(cursor: &mut Cursor, galley: &Galley, key: Key, modifiers: &Modifiers) {
|
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 {
|
match key {
|
||||||
Key::ArrowLeft => {
|
Key::ArrowLeft => {
|
||||||
if modifiers.alt || modifiers.ctrl {
|
if modifiers.alt || modifiers.ctrl {
|
||||||
|
|
Loading…
Reference in a new issue