Add mode 2031 support to automatically report dark or light theme. tmux

will guess the theme from the background colour on terminals which do
not themselves support the escape sequence. Written by Jonathan
Slenders, GitHub issue 4353.
This commit is contained in:
nicm
2025-03-04 08:45:04 +00:00
parent 3543d79048
commit eaf70c955b
17 changed files with 380 additions and 107 deletions

View File

@@ -213,6 +213,10 @@ static const struct tty_default_key_raw tty_default_raw_keys[] = {
/* Extended keys. */
{ "\033[1;5Z", '\011'|KEYC_CTRL|KEYC_SHIFT },
/* Theme reporting. */
{ "\033[?997;1n", KEYC_REPORT_DARK_THEME },
{ "\033[?997;2n", KEYC_REPORT_LIGHT_THEME },
};
/* Default xterm keys. */
@@ -791,10 +795,12 @@ tty_keys_next(struct tty *tty)
switch (tty_keys_colours(tty, buf, len, &size, &tty->fg, &tty->bg)) {
case 0: /* yes */
key = KEYC_UNKNOWN;
session_theme_changed(tty->client->session);
goto complete_key;
case -1: /* no, or not valid */
break;
case 1: /* partial */
session_theme_changed(tty->client->session);
goto partial_key;
}