about summary refs log tree commit diff
path: root/Src/Zle/complist.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-05-16 09:37:56 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-05-16 09:37:56 +0000
commit9533b19dad964fc9aa001f69146d356c42769a70 (patch)
tree53a556e60f52e74aaeed8163480a4e99d8b4e665 /Src/Zle/complist.c
parent02e0a4755f47f1eb720d5b81b37cc8e3d3a453ac (diff)
downloadzsh-9533b19dad964fc9aa001f69146d356c42769a70.tar.gz
zsh-9533b19dad964fc9aa001f69146d356c42769a70.tar.xz
zsh-9533b19dad964fc9aa001f69146d356c42769a70.zip
25051: add colour sequences to formatting strings in completion
Diffstat (limited to 'Src/Zle/complist.c')
-rw-r--r--Src/Zle/complist.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index e513a8475..6e0a89a47 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -1046,6 +1046,8 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
 	if (doesc && cchar == ZWC('%')) {
 	    p += len;
 	    if (*p) {
+		int arg = 0, is_fg;
+
 		len = MB_METACHARLENCONV(p, &cchar);
 #ifdef MULTIBYTE_SUPPORT
 		if (cchar == WEOF)
@@ -1053,6 +1055,9 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
 #endif
 		p += len;
 
+		if (idigit(*p))
+		    arg = zstrtol(p, &p, 10);
+
 		m = 0;
 		switch (cchar) {
 		case ZWC('%'):
@@ -1099,7 +1104,32 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
 		    if (dopr)
 			tcout(TCUNDERLINEEND);
 		    break;
+		case ZWC('F'):
+		case ZWC('K'):
+		    is_fg = (cchar == ZWC('F'));
+		    /* colours must be ASCII */
+		    if (*p == '{') {
+			p++;
+			arg = match_colour((const char **)&p, is_fg, 0);
+			if (*p == '}')
+			    p++;
+		    } else
+			arg = match_colour(NULL, is_fg, arg);
+		    if (arg >= 0 && dopr)
+			set_colour_attribute(arg, is_fg ? COL_SEQ_FG :
+					     COL_SEQ_BG, 0);
+		    break;
+		case ZWC('f'):
+		    if (dopr)
+			set_colour_attribute(TXTNOFGCOLOUR, COL_SEQ_FG, 0);
+		    break;
+		case ZWC('k'):
+		    if (dopr)
+			set_colour_attribute(TXTNOBGCOLOUR, COL_SEQ_BG, 0);
+		    break;
 		case ZWC('{'):
+		    if (arg)
+			cc += arg;
 		    for (; *p && (*p != '%' || p[1] != '}'); p++)
 			if (dopr)
 			    putc(*p == Meta ? *++p ^ 32 : *p, shout);