diff options
| author | Oliver Kiddle <opk@zsh.org> | 2025-11-10 21:02:29 +0100 |
|---|---|---|
| committer | Oliver Kiddle <opk@zsh.org> | 2025-11-10 21:02:29 +0100 |
| commit | 3085b88a6442e1504a0635bfa400829827e3af13 (patch) | |
| tree | ef699544626a75efa6309ca934f6e52368b1ef1b | |
| parent | 53377: support OSC52 paste sequence with the "* and "+ vi registers (diff) | |
| download | zsh-3085b88a6442e1504a0635bfa400829827e3af13.tar zsh-3085b88a6442e1504a0635bfa400829827e3af13.tar.gz zsh-3085b88a6442e1504a0635bfa400829827e3af13.tar.bz2 zsh-3085b88a6442e1504a0635bfa400829827e3af13.tar.lz zsh-3085b88a6442e1504a0635bfa400829827e3af13.tar.xz zsh-3085b88a6442e1504a0635bfa400829827e3af13.tar.zst zsh-3085b88a6442e1504a0635bfa400829827e3af13.zip | |
53379, 53380: autoload nearcolor based on truecolor detection
| -rw-r--r-- | ChangeLog | 3 | ||||
| -rw-r--r-- | Doc/Zsh/params.yo | 2 | ||||
| -rw-r--r-- | Src/prompt.c | 18 | ||||
| -rw-r--r-- | Test/X04zlehighlight.ztst | 2 |
4 files changed, 22 insertions, 3 deletions
@@ -1,5 +1,8 @@ 2025-11-10 Oliver Kiddle <opk@zsh.org> + * 53379, 53380: Doc/Zsh/params.yo, Test/X04zlehighlight.ztst, + Src/prompt.c: autoload nearcolor based on truecolor detection + * 53377: Doc/Zsh/zle.yo, Src/Zle/termquery.c, Src/Zle/zle_misc.c, Src/Zle/zle_utils.c, Test/X06termquery.ztst: support OSC52 paste sequence with the "* and "+ vi registers diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index 90ed6e5d1..7bcd61531 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -1759,7 +1759,7 @@ wider range of key combinations and resolves problems with ambiguous key sequences. Currently there is only support for detecting whether the terminal supports this feature. ) -xitem(tt(truecolor) <E>) +xitem(tt(truecolor) <D>) item(tt(query-truecolor) <E>)( Support for 24-bit truecolor escape sequences. Auto-detection also tries termcap and the tt(COLORTERM) environment variable. diff --git a/Src/prompt.c b/Src/prompt.c index 7467cdfb9..762d25650 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -1836,6 +1836,19 @@ match_named_colour(const char **teststrp) return -1; } +static int +truecolor_terminal() +{ + char **f, **flist = getaparam(".term.extensions"); + int result; + for (f = flist; f && *f; f++) { + result = **f != '-'; + if (!strcmp(*f + !result, "truecolor")) + return result; + } + return 0; /* disabled by default */ +} + /* * Match just the colour part of a highlight specification. * If teststrp is NULL, use the already parsed numeric colour. @@ -1879,7 +1892,10 @@ match_colour(const char **teststrp, int is_fg, int colour) return TXT_ERROR; *teststrp = end; colour = runhookdef(GETCOLORATTR, &color) - 1; - if (colour == -1) { /* no hook function added, try true color (24-bit) */ + if (colour == -1 && !truecolor_terminal() && + !load_module("zsh/nearcolor", NULL, 1)) + colour = runhookdef(GETCOLORATTR, &color) - 1; + if (colour == -1) { /* use true color (24-bit) */ colour = (((color.red << 8) + color.green) << 8) + color.blue; return on | (is_fg ? TXT_ATTR_FG_24BIT : TXT_ATTR_BG_24BIT) | (zattr)colour << shft; diff --git a/Test/X04zlehighlight.ztst b/Test/X04zlehighlight.ztst index 723bb05d7..be0564912 100644 --- a/Test/X04zlehighlight.ztst +++ b/Test/X04zlehighlight.ztst @@ -12,7 +12,7 @@ zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z" zpty -w zsh "module_path=( ${(j< >)${(@q-)module_path}} \$module_path )" zpty -w zsh 'zle_highlight=( fg_start_code:"CDE|3" fg_end_code:"|" bg_start_code:"BCDE|4" bg_end_code:"|" )' - zpty -w zsh '.term.extensions=( -query )' + zpty -w zsh '.term.extensions=( -query truecolor )' } zpty_input() { zpty ${${(M)2:#nonl}:+-n} -w zsh "$1" |
