support more keys in textarea (#1820)
Added: * C-m for newline (not sure if this is actually treated differently to Enter, but tui-textarea handles it and it doesn't hurt) * C-d to delete one char forwards (same as Del) * A-bksp to delete backwards one word * A-arrows to navigate by word
This commit is contained in:
@@ -210,7 +210,7 @@ impl TextArea {
|
|||||||
..
|
..
|
||||||
} => self.insert_str(&c.to_string()),
|
} => self.insert_str(&c.to_string()),
|
||||||
KeyEvent {
|
KeyEvent {
|
||||||
code: KeyCode::Char('j'),
|
code: KeyCode::Char('j' | 'm'),
|
||||||
modifiers: KeyModifiers::CONTROL,
|
modifiers: KeyModifiers::CONTROL,
|
||||||
..
|
..
|
||||||
}
|
}
|
||||||
@@ -220,11 +220,22 @@ impl TextArea {
|
|||||||
} => self.insert_str("\n"),
|
} => self.insert_str("\n"),
|
||||||
KeyEvent {
|
KeyEvent {
|
||||||
code: KeyCode::Backspace,
|
code: KeyCode::Backspace,
|
||||||
|
modifiers: KeyModifiers::ALT,
|
||||||
|
..
|
||||||
|
} => self.delete_backward_word(),
|
||||||
|
KeyEvent {
|
||||||
|
code: KeyCode::Backspace,
|
||||||
|
modifiers: KeyModifiers::NONE,
|
||||||
..
|
..
|
||||||
} => self.delete_backward(1),
|
} => self.delete_backward(1),
|
||||||
KeyEvent {
|
KeyEvent {
|
||||||
code: KeyCode::Delete,
|
code: KeyCode::Delete,
|
||||||
..
|
..
|
||||||
|
}
|
||||||
|
| KeyEvent {
|
||||||
|
code: KeyCode::Char('d'),
|
||||||
|
modifiers: KeyModifiers::CONTROL,
|
||||||
|
..
|
||||||
} => self.delete_forward(1),
|
} => self.delete_forward(1),
|
||||||
|
|
||||||
KeyEvent {
|
KeyEvent {
|
||||||
@@ -303,14 +314,14 @@ impl TextArea {
|
|||||||
}
|
}
|
||||||
KeyEvent {
|
KeyEvent {
|
||||||
code: KeyCode::Left,
|
code: KeyCode::Left,
|
||||||
modifiers: KeyModifiers::CONTROL,
|
modifiers: KeyModifiers::CONTROL | KeyModifiers::ALT,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
self.set_cursor(self.beginning_of_previous_word());
|
self.set_cursor(self.beginning_of_previous_word());
|
||||||
}
|
}
|
||||||
KeyEvent {
|
KeyEvent {
|
||||||
code: KeyCode::Right,
|
code: KeyCode::Right,
|
||||||
modifiers: KeyModifiers::CONTROL,
|
modifiers: KeyModifiers::CONTROL | KeyModifiers::ALT,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
self.set_cursor(self.end_of_next_word());
|
self.set_cursor(self.end_of_next_word());
|
||||||
|
|||||||
Reference in New Issue
Block a user