1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 15:04:36 +03:00

separate application cursor keys

Application cursor keys are a separate set of encodings that applications can
ask the terminal to produce for cursor keys.

Unfortunately, PuTTY generates these for shift-modified cursor keys.  If an
application is to distinguish between normal and shift-modified cursor keys
on PuTTY then it will need to be able to distinguish between normal and
application cursor keys.

Add new `KeyCode` variants for application cursor keys.
This commit is contained in:
Mark Thomas 2019-04-21 04:15:43 +01:00 committed by Wez Furlong
parent 83921728ae
commit fb636995c8
2 changed files with 29 additions and 14 deletions

View File

@ -819,6 +819,10 @@ impl TerminalState {
(LeftArrow, _, _, _, APPCURSOR) => "\x1bOD",
(Home, _, _, _, APPCURSOR) => "\x1bOH",
(End, _, _, _, APPCURSOR) => "\x1bOF",
(ApplicationUpArrow, ..) => "\x1bOA",
(ApplicationDownArrow, ..) => "\x1bOB",
(ApplicationRightArrow, ..) => "\x1bOC",
(ApplicationLeftArrow, ..) => "\x1bOD",
(UpArrow, ..) => "\x1b[A",
(DownArrow, ..) => "\x1b[B",

View File

@ -154,6 +154,10 @@ pub enum KeyCode {
MediaPrevTrack,
MediaStop,
MediaPlayPause,
ApplicationLeftArrow,
ApplicationRightArrow,
ApplicationUpArrow,
ApplicationDownArrow,
#[doc(hidden)]
InternalPasteStart,
@ -461,16 +465,6 @@ impl InputParser {
(KeyCode::Home, b'H'),
(KeyCode::End, b'F'),
] {
// Arrow keys in application cursor mode encoded using SS3
let app = [0x1b, b'O', *dir];
map.insert(
&app,
InputEvent::Key(KeyEvent {
key: *keycode,
modifiers: Modifiers::NONE,
}),
);
// Arrow keys in normal mode encoded using CSI
let arrow = [0x1b, b'[', *dir];
map.insert(
@ -502,6 +496,23 @@ impl InputParser {
}
}
for (keycode, dir) in &[
(KeyCode::ApplicationUpArrow, b'A'),
(KeyCode::ApplicationDownArrow, b'B'),
(KeyCode::ApplicationRightArrow, b'C'),
(KeyCode::ApplicationLeftArrow, b'D'),
] {
// Arrow keys in application cursor mode encoded using SS3
let app = [0x1b, b'O', *dir];
map.insert(
&app,
InputEvent::Key(KeyEvent {
key: *keycode,
modifiers: Modifiers::NONE,
}),
);
}
// Function keys 1-4 with no modifiers encoded using SS3
for (keycode, c) in &[
(KeyCode::Function(1), b'P'),
@ -902,19 +913,19 @@ mod test {
vec![
InputEvent::Key(KeyEvent {
modifiers: Modifiers::NONE,
key: KeyCode::UpArrow,
key: KeyCode::ApplicationUpArrow,
}),
InputEvent::Key(KeyEvent {
modifiers: Modifiers::NONE,
key: KeyCode::DownArrow,
key: KeyCode::ApplicationDownArrow,
}),
InputEvent::Key(KeyEvent {
modifiers: Modifiers::NONE,
key: KeyCode::RightArrow,
key: KeyCode::ApplicationRightArrow,
}),
InputEvent::Key(KeyEvent {
modifiers: Modifiers::NONE,
key: KeyCode::LeftArrow,
key: KeyCode::ApplicationLeftArrow,
}),
],
inputs