summaryrefslogtreecommitdiff
path: root/Src/Zle/zle_tricky.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/zle_tricky.c
parent02e0a4755f47f1eb720d5b81b37cc8e3d3a453ac (diff)
downloadzsh-9533b19dad964fc9aa001f69146d356c42769a70.tar.gz
zsh-9533b19dad964fc9aa001f69146d356c42769a70.zip
25051: add colour sequences to formatting strings in completion
Diffstat (limited to 'Src/Zle/zle_tricky.c')
-rw-r--r--Src/Zle/zle_tricky.c29
1 files changed, 27 insertions, 2 deletions
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)