VT extension to query state and request realtime reports on future state changes #1236
Replies: 6 comments 20 replies
-
Feedback on the two items separately. DEC Mode 2031Is there another example of a DEC mode being used to communicate externally controlled state? My [admittedly small] experience is that DEC modes are used to query and change on/off terminal configurations. App theme seems more like an external event such as mouse state. On the other hand, the supportive argument could be that xterm allows configuring the default value of modes using a Xresources file and you could in theory query them at runtime to find their default state! I'm just playing both sides. I have some worries about using a mode about this for other reasons: a mode can only represent 1 bit of information. Apple already has 4 system themes (dark, light, dark high contrast, light high contrast). This mode would force terminals to make some decision about what constitutes light and dark... admittedly not too hard today, though. No comment on number choice, I didn't look into the merits of 2031. Overall: I think I'm fine with it! 😄 The broad "dark vs light" feels like enough information without getting into the weeds. And a mode is easy enough to support and integrate. Alternate background, not a formal proposal: Querying some app or system state feels more similar to DEC Mode Change NotificationMy suggestion would be to remove the In the weird scenario where there is a user DoS-ing their own terminal scenario by rapidly flipping some mode, the terminal emulator is free to coalesce the changes over a period of time before reporting. That would be an optional QoL improvement that doesn't impact the protocol. Further, by only proposing Otherwise, I like it. 👍 Footnotes |
Beta Was this translation helpful? Give feedback.
-
Just brainstorming some ideas here.
|
Beta Was this translation helpful? Give feedback.
-
I think in general this mode should only report palette changes. Consider the case where I have my OS change light/dark mode on a timer but I don't change my terminal theme. If a TUI gets a signal I've changed to light mode, and starts emitting characters with the default background (which it thinks is a light color? Unless it's also querying for the palette after such a notification) I will have some very difficult to read text. In either case, the TUI should only actually care if the terminal palette has changed. I would think this could be done with a single CSI to notify of palette change, and then it's up to the TUI to request the new palette, if it wants it. That said, I think this is a great addition! |
Beta Was this translation helpful? Give feedback.
-
I would also like unsolicited reports on terminal size please. This could simplify some differences in windows vs Mac/unix APIs for SIGWINCH |
Beta Was this translation helpful? Give feedback.
-
I think a combination of @j4james and @christianparpart approaches would work pretty well:
The reply:
It's important that this also respond to palette changes caused by OSC 4, 10-19. Applications such as This is pretty easily extended to terminal size
|
Beta Was this translation helpful? Give feedback.
-
Hey guys. I am pretty much on the side of keeping it simple. Since DSR is already established, I am in favor of extending this in a way @j4james suggested. While @dankamongmen (and @j4james?) had a good point that simply reporting palette changes should be sufficient, I was at first a great fan of that idea. That is what the unsolicited DSR will be about. However, it may make sense -for simplicity- to simply ask for day/night mode by the TUI or evne CLI to quickly decide what colors to chose. I keep having delta as a great example here, because that could simply check that and then decide what color scheme to pick. Proposal: explicit request
Proposal: unsolicited reportsLooks exactly like the reply from DSR above, except that it was generated unsolicited and not actively requested. The day/night mode param is IMHO to be taken as a hint - in my PoC implementation, I'm inferring that value based off the default text foreground color using the algorithm that was suggested also in the MS documentation how how to infer dark/light mode See https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/apply-windows-themes I personally seem to prefer that, because it's more reliable to what the user/TUI tries to achieve, and it covers more color palette changes than simply dark/light (day/night) but also the in betweens. The proposed patch for Contour would look like this: abb0e18 p.s.: applications receiving unsolicited DSR on color palette update (regardless of source that triggered it) may ignore the dark/light (night/day) mode hint and simply query and/or overwrite the palette if they need to (notcurses e.g.?) Other than that, I see great potential for standard CLI apps on the explicit request and for TUI apps like vim to reflect the colorscheme in realtime whenever the dark/light mode of the OS is changing (that was my whole motivation of getting here :) ) |
Beta Was this translation helpful? Give feedback.
-
Hi @j4james, @dankamongmen, @\all
I want my TUI apps (especially text editor) to change dark/light mode live whenever the OS configuration changes. However, not just TUI apps could benefit from that but also more colorful CLI apps like
bat
that don't just use the primary colors to produce the colord diff but truecolor. I imagine that such tools could chedk dark mode first before deciding what colors to use.I want to introduce a VT sequence for that to:
I'm pretty sure i'll add that, but i'd like to get your feedback as well before going into an entirely different direction :)
refs PR #1233
What I'm currently having as PoC in the above PR is:
2031
(Dark Mode) that indicates dark mode if enabled, and non-dark mode (e.g. light mode) if notCSI < Ps $ p
where Ps can be zero or more DEC mode numbers. Zero (similar to SGR) will reset all watches, and otherwise Ps is a DEC mode to start watching on. The result looks intentionally very similar to DECRPM, that is:CSI < Pd ; Ps $ y
withPd
being the DEC mode that has changed, andPs
as1
to indicate set and2
to indicate reset.I am not sure if feature detection is actually required for the new VT sequence extension (it simply won't report) and the new DEC mode can be detected just like any other DEC mode (via DECRQM).
Beta Was this translation helpful? Give feedback.
All reactions