зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-03 14:26:17 +03:00
add Key::Copy, Key::Cut, Key::Paste support
Этот коммит содержится в:
@@ -252,9 +252,9 @@ Default key mappings are as follows:
|
||||
| `Alt+D`, `Alt+Delete` | Delete one word next to cursor |
|
||||
| `Ctrl+U` | Undo |
|
||||
| `Ctrl+R` | Redo |
|
||||
| `Ctrl+C` | Copy selected text |
|
||||
| `Ctrl+X` | Cut selected text |
|
||||
| `Ctrl+Y` | Paste yanked text |
|
||||
| `Ctrl+C`, `Copy` | Copy selected text |
|
||||
| `Ctrl+X`, `Cut` | Cut selected text |
|
||||
| `Ctrl+Y`, `Paste` | Paste yanked text |
|
||||
| `Ctrl+F`, `→` | Move cursor forward by one character |
|
||||
| `Ctrl+B`, `←` | Move cursor backward by one character |
|
||||
| `Ctrl+P`, `↑` | Move cursor up by one line |
|
||||
|
||||
@@ -45,6 +45,12 @@ pub enum Key {
|
||||
PageDown,
|
||||
/// Escape key
|
||||
Esc,
|
||||
/// Copy key. This key is supported by termwiz only
|
||||
Copy,
|
||||
/// Cut key. This key is supported by termwiz only
|
||||
Cut,
|
||||
/// Paste key. This key is supported by termwiz only
|
||||
Paste,
|
||||
/// Virtual key to scroll down by mouse
|
||||
MouseScrollDown,
|
||||
/// Virtual key to scroll up by mouse
|
||||
|
||||
@@ -34,6 +34,9 @@ impl From<KeyCode> for Key {
|
||||
KeyCode::DownArrow => Key::Down,
|
||||
KeyCode::Delete => Key::Delete,
|
||||
KeyCode::Function(x) => Key::F(x),
|
||||
KeyCode::Copy => Key::Copy,
|
||||
KeyCode::Cut => Key::Cut,
|
||||
KeyCode::Paste => Key::Paste,
|
||||
_ => Key::Null,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,19 +558,24 @@ impl<'a> TextArea<'a> {
|
||||
ctrl: true,
|
||||
alt: false,
|
||||
..
|
||||
}
|
||||
| Input {
|
||||
key: Key::Paste, ..
|
||||
} => self.paste(),
|
||||
Input {
|
||||
key: Key::Char('x'),
|
||||
ctrl: true,
|
||||
alt: false,
|
||||
..
|
||||
} => self.cut(),
|
||||
}
|
||||
| Input { key: Key::Cut, .. } => self.cut(),
|
||||
Input {
|
||||
key: Key::Char('c'),
|
||||
ctrl: true,
|
||||
alt: false,
|
||||
..
|
||||
} => {
|
||||
}
|
||||
| Input { key: Key::Copy, .. } => {
|
||||
self.copy();
|
||||
false
|
||||
}
|
||||
|
||||
@@ -47,6 +47,9 @@ fn test_input_all_combinations_sanity() {
|
||||
Esc,
|
||||
MouseScrollDown,
|
||||
MouseScrollUp,
|
||||
Copy,
|
||||
Cut,
|
||||
Paste,
|
||||
] {
|
||||
push_all_modifiers_combination(&mut inputs, k);
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user