summaryrefslogtreecommitdiff
path: root/Src/prompt.c
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2024-01-28 00:47:10 +0100
committerOliver Kiddle <opk@zsh.org>2024-01-28 00:47:36 +0100
commit85545af42b8f9278136125324c37c1f88b461421 (patch)
treed07e1f565c6bcb8fdac42cd0a595a9e481f2e57f /Src/prompt.c
parent3c5dacd503a2ac81059346b37d16ab5d1b6a1e04 (diff)
downloadzsh-85545af42b8f9278136125324c37c1f88b461421.tar.gz
zsh-85545af42b8f9278136125324c37c1f88b461421.zip
52500: add layer token to zle attributes
This provide control over the precedence of highlighting where different regions overlap.
Diffstat (limited to 'Src/prompt.c')
-rw-r--r--Src/prompt.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Src/prompt.c b/Src/prompt.c
index e4c213a13..ec79067cd 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -260,7 +260,7 @@ parsehighlight(char *arg, char endchar, zattr *atr)
if ((node = (Param) ht->getnode(ht, arg))) {
attrs = node->gsu.s->getfn(node);
entered = 1;
- if (match_highlight(attrs, atr) == attrs)
+ if (match_highlight(attrs, atr, 0) == attrs)
*atr = TXT_ERROR;
} else
*atr = TXT_ERROR;
@@ -1884,12 +1884,13 @@ match_colour(const char **teststrp, int is_fg, int colour)
/*
* Match a set of highlights in the given teststr.
* Set *on_var to reflect the values found.
+ * Set *layer to the layer
* Return a pointer to the first character not consumed.
*/
/**/
mod_export const char *
-match_highlight(const char *teststr, zattr *on_var)
+match_highlight(const char *teststr, zattr *on_var, int *layer)
{
int found = 1;
@@ -1918,6 +1919,14 @@ match_highlight(const char *teststr, zattr *on_var)
/* skip out of range colours but keep scanning attributes */
if (atr != TXT_ERROR)
*on_var |= atr;
+ } else if (layer && strpfx("layer=", teststr)) {
+ teststr += 6;
+ *layer = (int) zstrtol(teststr, (char **) &teststr, 10);
+ if (*teststr == ',')
+ teststr++;
+ else if (*teststr && *teststr != ' ')
+ break;
+ found = 1;
} else {
for (hl = highlights; hl->name; hl++) {
if (strpfx(hl->name, teststr)) {