about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2024-03-05 00:11:02 +0100
committerOliver Kiddle <opk@zsh.org>2024-03-05 00:11:02 +0100
commit05c7b21e2b30873d002b50b37e2fbd3803d4b608 (patch)
tree70dc55c5c22cb1c245ab4f7d241ce95ca6cc7957 /Src
parent36a2d5cfa49a6b7d699269cb4f22d5f3d0255bc8 (diff)
downloadzsh-05c7b21e2b30873d002b50b37e2fbd3803d4b608.tar.gz
zsh-05c7b21e2b30873d002b50b37e2fbd3803d4b608.tar.xz
zsh-05c7b21e2b30873d002b50b37e2fbd3803d4b608.zip
52646: extend support for highlight groups to completion explanation strings and WATCHFMT
Diffstat (limited to 'Src')
-rw-r--r--Src/Modules/watch.c9
-rw-r--r--Src/Zle/complist.c7
-rw-r--r--Src/Zle/zle_tricky.c8
-rw-r--r--Src/prompt.c8
4 files changed, 28 insertions, 4 deletions
diff --git a/Src/Modules/watch.c b/Src/Modules/watch.c
index 97d4fa608..ba17cf940 100644
--- a/Src/Modules/watch.c
+++ b/Src/Modules/watch.c
@@ -373,6 +373,13 @@ watchlog2(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt, int fini)
 		case 'f':
 		    tunsetattrs(TXTFGCOLOUR);
 		    break;
+		case 'H':
+		    if (*fmt == '{') {
+			fmt = parsehighlight(fmt + 1, '}', &atr);
+			if (atr && atr != TXT_ERROR)
+			    treplaceattrs(atr);
+		    }
+		    break;
 		case 'K':
 		    if (*fmt == '{') {
 			fmt++;
@@ -428,7 +435,7 @@ watchlog_match(char *teststr, char *actual, size_t buflen)
     int ret = 0;
     Patprog pprog;
     char *str = dupstring(teststr);
-    int len = strnlen(actual, buflen);
+    size_t len = strnlen(actual, buflen);
     char *user = metafy(actual, len,
 	    len == buflen ? META_HEAPDUP : META_USEHEAP);
 
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 9cb89a60d..5619160a9 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -1181,6 +1181,13 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
 		    if (dopr)
 			tunsetattrs(TXTBGCOLOUR);
 		    break;
+		case ZWC('H'):
+		    if (*p == '{') {
+			p = parsehighlight(p + 1, '}', &atr);
+			if (atr != TXT_ERROR && dopr)
+			    treplaceattrs(atr);
+		    }
+		    break;
 		case ZWC('{'):
 		    if (arg)
 			cc += arg;
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 225ce8c74..aa3c71bc2 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -2501,6 +2501,14 @@ printfmt(char *fmt, int n, int dopr, int doesc)
 		case 'k':
 		    tunsetattrs(TXTBGCOLOUR);
 		    break;
+		case 'H':
+		    if (p[1] == '{') {
+			p = parsehighlight(p + 2, '}', &atr);
+			--p;
+			if (atr != TXT_ERROR)
+			    treplaceattrs(atr);
+		    }
+		    break;
 		case '{':
 		    if (arg)
 			cc += arg;
diff --git a/Src/prompt.c b/Src/prompt.c
index 7acbe0e47..e10b05215 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -270,7 +270,8 @@ zattrescape(zattr atr, int *len)
 }
 
 /* Parse the argument for %H */
-static char *
+/**/
+mod_export char *
 parsehighlight(char *arg, char endchar, zattr *atr)
 {
     static int entered = 0;
@@ -295,9 +296,9 @@ parsehighlight(char *arg, char endchar, zattr *atr)
     } else
 	*atr = TXT_ERROR;
     if (ep)
-	*ep = endchar;
+	*ep++ = endchar;
     else
-	ep = strchr(arg, '\0') - 1;
+	ep = strchr(arg, '\0');
     entered = 0;
     return ep;
 }
@@ -635,6 +636,7 @@ putpromptchar(int doprint, int endchar)
 	    case 'H':
 		if (bv->fm[1] == '{') {
 		    bv->fm = parsehighlight(bv->fm + 2, '}', &atr);
+		    --bv->fm;
 		    if (atr != TXT_ERROR) {
 			treplaceattrs(atr);
 			applytextattributes(TSC_PROMPT);