termwiz: line editor: allow application cursor keys

On Windows, if you run `wsl.exe` from the terminal and start zsh
(maybe bash also?) and it enables application cursor key mode,
exiting zsh doesn't clear application cursor key mode and when we
return to the shell and are using virtual terminal input rather
than the native windows console input, we'll continue to receive
application cursor key sequences instead of regular cursor key
input sequences.

This commit recognizes both flavors as arrow movement
in the line editor to make this feel less broken.
This commit is contained in:
Wez Furlong committed 2020-04-08 19:11:15 -07:00
1 parent 5b57f5f9ff
commit af339f7cfe
1 file changed
+24
+24
View File
@@ -291,6 +291,10 @@ impl<T: Terminal> LineEditor<T> {
| InputEvent::Key(KeyEvent {
key: KeyCode::UpArrow,
modifiers: Modifiers::NONE,
})
| InputEvent::Key(KeyEvent {
key: KeyCode::ApplicationUpArrow,
modifiers: Modifiers::NONE,
}) => Some(Action::HistoryPrevious),
InputEvent::Key(KeyEvent {
@@ -300,12 +304,20 @@ impl<T: Terminal> LineEditor<T> {
| InputEvent::Key(KeyEvent {
key: KeyCode::DownArrow,
modifiers: Modifiers::NONE,
})
| InputEvent::Key(KeyEvent {
key: KeyCode::ApplicationDownArrow,
modifiers: Modifiers::NONE,
}) => Some(Action::HistoryNext),
InputEvent::Key(KeyEvent {
key: KeyCode::Char('B'),
modifiers: Modifiers::CTRL,
})
| InputEvent::Key(KeyEvent {
key: KeyCode::ApplicationLeftArrow,
modifiers: Modifiers::NONE,
})
| InputEvent::Key(KeyEvent {
key: KeyCode::LeftArrow,
modifiers: Modifiers::NONE,
@@ -323,6 +335,10 @@ impl<T: Terminal> LineEditor<T> {
| InputEvent::Key(KeyEvent {
key: KeyCode::LeftArrow,
modifiers: Modifiers::ALT,
})
| InputEvent::Key(KeyEvent {
key: KeyCode::ApplicationLeftArrow,
modifiers: Modifiers::ALT,
}) => Some(Action::Move(Movement::BackwardWord(1))),
InputEvent::Key(KeyEvent {
@@ -332,6 +348,10 @@ impl<T: Terminal> LineEditor<T> {
| InputEvent::Key(KeyEvent {
key: KeyCode::RightArrow,
modifiers: Modifiers::ALT,
})
| InputEvent::Key(KeyEvent {
key: KeyCode::ApplicationRightArrow,
modifiers: Modifiers::ALT,
}) => Some(Action::Move(Movement::ForwardWord(1))),
InputEvent::Key(KeyEvent {
@@ -357,6 +377,10 @@ impl<T: Terminal> LineEditor<T> {
| InputEvent::Key(KeyEvent {
key: KeyCode::RightArrow,
modifiers: Modifiers::NONE,
})
| InputEvent::Key(KeyEvent {
key: KeyCode::ApplicationRightArrow,
modifiers: Modifiers::NONE,
}) => Some(Action::Move(Movement::ForwardChar(1))),
InputEvent::Key(KeyEvent {
key: KeyCode::Char(c),