From 8d4d22218e63c88a7b9897219272775fc575da33 Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Sat, 19 Mar 2022 13:14:54 +0000 Subject: [PATCH] csi: add support for DECNKM private mode This is equivalent to DECKPAM/DECKPNM when enabled/disabled, but can also be saved/restored/queried with XTSAVE/XTRESTORE/DECRQM. See also: * https://vt100.net/docs/vt510-rm/DECNKM.html * https://vt100.net/docs/vt510-rm/DECKPAM.html * https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-PC-Style-Function-Keys --- CHANGELOG.md | 5 +++++ csi.c | 8 ++++++++ doc/foot-ctlseqs.7.scd | 3 +++ terminal.h | 1 + 4 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d05d403..f3baa0ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,8 @@ * Add "xterm" as fallback cursor where "text" is not available. * `[key-bindings].scrollback-home|end` options. * Socket activation for `foot --server` and accompanying systemd unit files +* Support for [DECNKM](https://vt100.net/docs/vt510-rm/DECNKM.html), which + allows setting/saving/restoring/querying the keypad mode. ### Changed @@ -88,8 +90,11 @@ ### Security + ### Contributors +* Craig Barnes + ## 1.11.0 diff --git a/csi.c b/csi.c index 84ecd24b..af3b2216 100644 --- a/csi.c +++ b/csi.c @@ -393,6 +393,11 @@ decset_decrst(struct terminal *term, unsigned param, bool enable) term->reverse_wrap = enable; break; + case 66: + /* DECNKM */ + term->keypad_keys_mode = enable ? KEYPAD_APPLICATION : KEYPAD_NUMERICAL; + break; + case 80: term->sixel.scrolling = !enable; break; @@ -603,6 +608,7 @@ decrqm(const struct terminal *term, unsigned param, bool *enabled) case 12: *enabled = term->cursor_blink.decset; return true; case 25: *enabled = !term->hide_cursor; return true; case 45: *enabled = term->reverse_wrap; return true; + case 66: *enabled = term->keypad_keys_mode == KEYPAD_APPLICATION; return true; case 80: *enabled = !term->sixel.scrolling; return true; case 1000: *enabled = term->mouse_tracking == MOUSE_CLICK; return true; case 1001: *enabled = false; return true; @@ -646,6 +652,7 @@ xtsave(struct terminal *term, unsigned param) case 25: term->xtsave.show_cursor = !term->hide_cursor; break; case 45: term->xtsave.reverse_wrap = term->reverse_wrap; break; case 47: term->xtsave.alt_screen = term->grid == &term->alt; break; + case 66: term->xtsave.application_keypad_keys = term->keypad_keys_mode == KEYPAD_APPLICATION; break; case 80: term->xtsave.sixel_display_mode = !term->sixel.scrolling; break; case 1000: term->xtsave.mouse_click = term->mouse_tracking == MOUSE_CLICK; break; case 1001: break; @@ -688,6 +695,7 @@ xtrestore(struct terminal *term, unsigned param) case 25: enable = term->xtsave.show_cursor; break; case 45: enable = term->xtsave.reverse_wrap; break; case 47: enable = term->xtsave.alt_screen; break; + case 66: enable = term->xtsave.application_keypad_keys; break; case 80: enable = term->xtsave.sixel_display_mode; break; case 1000: enable = term->xtsave.mouse_click; break; case 1001: return; diff --git a/doc/foot-ctlseqs.7.scd b/doc/foot-ctlseqs.7.scd index 420271e2..e9d31a32 100644 --- a/doc/foot-ctlseqs.7.scd +++ b/doc/foot-ctlseqs.7.scd @@ -268,6 +268,9 @@ that corresponds to one of the following modes: | 47 : xterm : Same as 1047 (see below) +| 66 +: VT320 +: Numeric keypad mode (DECNKM); same as DECKPAM/DECKPNM when enabled/disabled | 1000 : xterm : Send mouse x/y on button press/release diff --git a/terminal.h b/terminal.h index 7e1f7911..76f6bf22 100644 --- a/terminal.h +++ b/terminal.h @@ -393,6 +393,7 @@ struct terminal { struct { bool origin:1; bool application_cursor_keys:1; + bool application_keypad_keys:1; bool reverse:1; bool show_cursor:1; bool reverse_wrap:1;