summaryrefslogtreecommitdiff
path: root/src/terminal_ui.cc
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2023-06-17 14:53:44 +0200
committerJohannes Altmanninger <aclopte@gmail.com>2023-06-24 22:18:49 +0200
commit84ea52e46e5176950afb1b92f6100122edbc2dbd (patch)
treec45584845913287a4ddc2e1303b484bcdd892c7d /src/terminal_ui.cc
parente06e409dc16cd98e0353b6bd33b311efbc792000 (diff)
Support CSI u numpad keys
Normally page-down is sent as \033[6~ but some terminals send a CSI u encoding for the page-down on the numpad. See https://codeberg.org/dnkl/foot#keypad for example. Treat them as the underlying key; we could add a modifier if anyone cares about the distinction.
Diffstat (limited to 'src/terminal_ui.cc')
-rw-r--r--src/terminal_ui.cc22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc
index f87a914e..98744050 100644
--- a/src/terminal_ui.cc
+++ b/src/terminal_ui.cc
@@ -877,8 +877,26 @@ Optional<Key> TerminalUI::get_next_key()
}
return {};
case 'u':
- return masked_key(convert(static_cast<Codepoint>(params[0][0])),
- convert(static_cast<Codepoint>(params[0][1])));
+ {
+ Codepoint key;
+ switch (params[0][0])
+ {
+ // Treat numpad keys the same as their non-numpad counterparts. Could add a numpad modifier here.
+ case 57414: key = Key::Return; break;
+ case 57417: key = Key::Left; break;
+ case 57418: key = Key::Right; break;
+ case 57419: key = Key::Up; break;
+ case 57420: key = Key::Down; break;
+ case 57421: key = Key::PageUp; break;
+ case 57422: key = Key::PageDown; break;
+ case 57423: key = Key::Home; break;
+ case 57424: key = Key::End; break;
+ case 57425: key = Key::Insert; break;
+ case 57426: key = Key::Delete; break;
+ default: key = convert(static_cast<Codepoint>(params[0][0])); break;
+ }
+ return masked_key(key, convert(static_cast<Codepoint>(params[0][1])));
+ }
case 'Z': return shift(Key::Tab);
case 'I': return {Key::FocusIn};
case 'O': return {Key::FocusOut};