about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/complist.c30
-rw-r--r--Src/Zle/zle_tricky.c29
-rw-r--r--Src/prompt.c4
3 files changed, 58 insertions, 5 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);
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index a6083764b..4786f30de 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -2272,7 +2272,10 @@ printfmt(char *fmt, int n, int dopr, int doesc)
     for (; *p; ) {
 	/* Handle the `%' stuff (%% == %, %n == <number of matches>). */
 	if (doesc && *p == '%') {
-	    if (*++p) {
+	    int arg = 0, is_fg;
+	    if (idigit(*++p))
+		arg = zstrtol(p, &p, 10);
+	    if (*p) {
 		m = 0;
 		switch (*p) {
 		case '%':
@@ -2316,11 +2319,33 @@ printfmt(char *fmt, int n, int dopr, int doesc)
 		    if (dopr)
 			tcout(TCUNDERLINEEND);
 		    break;
+		case 'F':
+		case 'K':
+		    is_fg = (*p == 'F');
+		    if (p[1] == '{') {
+			p += 2;
+			arg = match_colour((const char **)&p, is_fg, 0);
+			if (*p != '}')
+			    p--;
+		    } else
+			arg = match_colour(NULL, is_fg, arg);
+		    if (arg >= 0)
+			set_colour_attribute(arg, is_fg ? COL_SEQ_FG :
+					     COL_SEQ_BG, 0);
+		    break;
+		case 'f':
+		    set_colour_attribute(TXTNOFGCOLOUR, COL_SEQ_FG, 0);
+		    break;
+		case 'k':
+		    set_colour_attribute(TXTNOBGCOLOUR, COL_SEQ_BG, 0);
+		    break;
 		case '{':
+		    if (arg)
+			cc += arg;
 		    for (p++; *p && (*p != '%' || p[1] != '}'); p++) {
 			if (*p == Meta) {
 			    p++;
-			    if (dopr) 
+			    if (dopr)
 				putc(*p ^ 32, shout);
 			}
 			else if (dopr)
diff --git a/Src/prompt.c b/Src/prompt.c
index 004080577..034a4fa29 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -471,7 +471,6 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
 		    break;
 		}
 		/* else FALLTHROUGH */
-		break;
 	    case 'f':
 		txtchangeset(txtchangep, TXTNOFGCOLOUR, TXT_ATTR_FG_ON_MASK);
 		txtunset(TXT_ATTR_FG_ON_MASK);
@@ -493,7 +492,6 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
 		    break;
 		}
 		/* else FALLTHROUGH */
-		break;
 	    case 'k':
 		txtchangeset(txtchangep, TXTNOBGCOLOUR, TXT_ATTR_BG_ON_MASK);
 		txtunset(TXT_ATTR_BG_ON_MASK);
@@ -1472,7 +1470,7 @@ match_named_colour(const char **teststrp)
  */
 
 /**/
-static int
+mod_export int
 match_colour(const char **teststrp, int is_fg, int colour)
 {
     int shft, on, named = 0, tc;