From 27330a5dd6d544acf80272e6173418d5e47d259b Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Fri, 15 Mar 2024 17:51:51 +0000 Subject: [PATCH] csi: indicate "permanently reset" for DECRQM queries of mode 67 (DECBKM) This allows dynamic querying for the equivalent of terminfo's "kbs" capability. --- CHANGELOG.md | 4 +++- README.md | 6 +++--- csi.c | 8 ++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04571604..53d0bf39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,14 +64,16 @@ * Support for OSC-176, _"Set App-ID"_ (https://gist.github.com/delthas/d451e2cc1573bb2364839849c7117239). * Support for `DECRQM` queries with ANSI/ECMA-48 modes (`CSI Ps $ p`). +* `DECRQM` queries for private mode 67 ([`DECBKM`]) now reply with mode + value 4 ("permanently reset") instead of 0 ("not recognized"). * Rectangular edit functions: `DECCARA`, `DECRARA`, `DECCRA`, `DECFRA` and `DECERA` ([#1633][1633]). * `Rect` capability to terminfo. [1348]: https://codeberg.org/dnkl/foot/issues/1348 [1633]: https://codeberg.org/dnkl/foot/issues/1633 - [1564]: https://codeberg.org/dnkl/foot/pulls/1564 +[`DECBKM`]: https://vt100.net/docs/vt510-rm/DECBKM.html ### Changed diff --git a/README.md b/README.md index b8d67e96..eb7fe81c 100644 --- a/README.md +++ b/README.md @@ -428,13 +428,13 @@ mode_, `\E[?1034l`), and enabled again with `smm` (_set meta mode_, ## Backspace Foot transmits DEL (`^?`) on backspace. This corresponds to -XTerm's `backarrowKey` option set to `false`, and to DECBKM being -_reset_. +XTerm's `backarrowKey` option set to `false`, and to +[`DECBKM`](https://vt100.net/docs/vt510-rm/DECBKM.html) being _reset_. To instead transmit BS (`^H`), press ctrl+backspace. -Note that foot does **not** implement DECBKM, and that the behavior +Note that foot does **not** implement `DECBKM`, and that the behavior described above **cannot** be changed. Finally, pressing alt will prefix the transmitted byte with diff --git a/csi.c b/csi.c index 0d1ee1f4..04777310 100644 --- a/csi.c +++ b/csi.c @@ -324,6 +324,11 @@ decset_decrst(struct terminal *term, unsigned param, bool enable) term->keypad_keys_mode = enable ? KEYPAD_APPLICATION : KEYPAD_NUMERICAL; break; + case 67: + if (enable) + LOG_WARN("unimplemented: DECBKM"); + break; + case 80: term->sixel.scrolling = !enable; break; @@ -555,6 +560,7 @@ decrqm(const struct terminal *term, unsigned param) case 25: return decrpm(!term->hide_cursor); case 45: return decrpm(term->reverse_wrap); case 66: return decrpm(term->keypad_keys_mode == KEYPAD_APPLICATION); + case 67: return DECRPM_PERMANENTLY_RESET; /* https://vt100.net/docs/vt510-rm/DECBKM */ case 80: return decrpm(!term->sixel.scrolling); case 1000: return decrpm(term->mouse_tracking == MOUSE_CLICK); case 1001: return DECRPM_PERMANENTLY_RESET; @@ -600,6 +606,7 @@ xtsave(struct terminal *term, unsigned param) 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 67: 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; @@ -642,6 +649,7 @@ xtrestore(struct terminal *term, unsigned param) 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 67: return; case 80: enable = term->xtsave.sixel_display_mode; break; case 1000: enable = term->xtsave.mouse_click; break; case 1001: return;