csi: implement private mode 2031 (dark/light mode detection)

* Recognize 'CSI ? 996 n', and respond with
  - 'CSI ? 997 ; 1 n' if the primary theme is active
  - 'CSI ? 997 ; 2 n' if the alternative theme is actice
* Implement private mode 2031, where changing the color
  theme (currently only possible via key bindings) causes the terminal
  to send the same CSI sequences as above.

In this context, foot's primary theme is considered dark, and the
alternative theme light (since the default theme is dark).

Closes #2025
This commit is contained in:
Daniel Eklöf 2025-04-20 12:48:37 +02:00
parent 6bc91b5e28
commit 10e7f29149
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 70 additions and 0 deletions

View file

@ -337,6 +337,9 @@ that corresponds to one of the following modes:
| 2027
: contour
: Grapheme cluster processing
| 2031
: contour
: Request color theme updates
| 2048
: TODO
: In-band window resize notifications
@ -657,6 +660,13 @@ manipulation sequences. The generic format is:
: xterm
: Report the current entry on the palette stack, and the number of
palettes stored on the stack.
| \\E[ ? 996 n
: Query the current (color) theme mode
: contour
: The current color theme mode (light or dark) is reported as *CSI ?
997 ; 1|2 n*, where *1* means dark and *2* light. By convention, the
primary theme in foot is considered dark, and the alternative theme
light.
# OSC