about summary refs log tree commit diff
path: root/Src/Zle/complist.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-11-30 17:26:47 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-11-30 17:26:47 +0000
commitc969dea22f58cc86314f7a64ffdd25476cbd4a68 (patch)
tree6f0397ba96ea4890092beed9481f2f30ac24fa95 /Src/Zle/complist.c
parent1d5a54270b5e23a1d79709b1460feaebe64dbeba (diff)
downloadzsh-c969dea22f58cc86314f7a64ffdd25476cbd4a68.tar.gz
zsh-c969dea22f58cc86314f7a64ffdd25476cbd4a68.tar.xz
zsh-c969dea22f58cc86314f7a64ffdd25476cbd4a68.zip
27441: add "sa" for suffix alias completion highlighting
Diffstat (limited to 'Src/Zle/complist.c')
-rw-r--r--Src/Zle/complist.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index da7a8ce08..bac072ec3 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -187,15 +187,16 @@ static Keymap mskeymap, lskeymap;
 #define COL_MA 21
 #define COL_HI 22
 #define COL_DU 23
+#define COL_SA 24
 
-#define NUM_COLS 24
+#define NUM_COLS 25
 
 /* Names of the terminal strings. */
 
 static char *colnames[] = {
     "no", "fi", "di", "ln", "pi", "so", "bd", "cd", "or", "mi",
     "su", "sg", "tw", "ow", "st", "ex",
-    "lc", "rc", "ec", "tc", "sp", "ma", "hi", "du", NULL
+    "lc", "rc", "ec", "tc", "sp", "ma", "hi", "du", "sa", NULL
 };
 
 /* Default values. */
@@ -203,7 +204,7 @@ static char *colnames[] = {
 static char *defcols[] = {
     "0", "0", "1;31", "1;36", "33", "1;35", "1;33", "1;33", NULL, NULL,
     "37;41", "30;43", "30;42", "34;42", "37;44", "1;32", 
-    "\033[", "m", NULL, "0", "0", "7", NULL, NULL
+    "\033[", "m", NULL, "0", "0", "7", NULL, NULL, "0"
 };
 
 /* This describes a terminal string for a file type. */
@@ -872,17 +873,18 @@ putmatchcol(char *group, char *n)
  * file modes. */
 
 static int
-putfilecol(char *group, char *n, mode_t m, int special)
+putfilecol(char *group, char *filename, mode_t m, int special)
 {
     int colour = -1;
     Extcol ec;
     Patcol pc;
+    int len;
 
     nrefs = MAX_POS - 1;
 
     for (pc = mcolors.pats; pc; pc = pc->next)
 	if ((!pc->prog || !group || pattry(pc->prog, group)) &&
-	    pattryrefs(pc->pat, n, -1, -1, 0, &nrefs, begpos, endpos)) {
+	    pattryrefs(pc->pat, filename, -1, -1, 0, &nrefs, begpos, endpos)) {
 	    if (pc->cols[1]) {
 		patcols = pc->cols;
 
@@ -928,13 +930,29 @@ putfilecol(char *group, char *n, mode_t m, int special)
     }
 
     for (ec = mcolors.exts; ec; ec = ec->next)
-	if (strsfx(ec->ext, n) &&
+	if (strsfx(ec->ext, filename) &&
 	    (!ec->prog || !group || pattry(ec->prog, group))) {
 	    zlrputs(ec->col);
 
 	    return 0;
 	}
 
+    /* Check for suffix alias */
+    len = strlen(filename);
+    /* shortest valid suffix format is a.b */
+    if (len > 2) {
+	char *suf = filename + len - 1;
+	while (suf > filename+1) {
+	    if (suf[-1] == '.') {
+		if (sufaliastab->getnode(sufaliastab, suf)) {
+		    zcputs(group, COL_SA);
+		    return 0;
+		}
+		break;
+	    }
+	    suf--;
+	}
+    }
     zcputs(group, COL_FI);
 
     return 0;