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 /Src | |
| 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
Diffstat (limited to 'Src')
| -rw-r--r-- | Src/prompt.c | 18 |
1 files changed, 17 insertions, 1 deletions
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; |
