1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-09-04 14:55:51 +03:00

caveat on conversion from termion's key event into Input (#68)

Этот коммит содержится в:
rhysd
2024-08-03 23:48:30 +09:00
родитель 9087e75c1f
Коммит 3a9d1430d4

Просмотреть файл

@@ -14,6 +14,13 @@ impl From<Event> for Input {
impl From<KeyEvent> for Input {
/// Convert [`termion::event::Key`] into [`Input`].
///
/// termion does not provide a way to get Shift key's state. Instead termion passes key inputs as-is. For example,
/// when 'Shift + A' is pressed with US keyboard, termion passes `termion::event::Key::Char('A')`. We cannot know
/// how the 'A' character was input.
///
/// So the `shift` field of the returned `Input` instance is always `false` except for combinations with arrow keys.
/// For example, `termion::event::Key::Char('A')` is converted to `Input { key: Key::Char('A'), shift: false, .. }`.
fn from(key: KeyEvent) -> Self {
let (ctrl, alt, shift) = match key {
KeyEvent::Ctrl(_)