about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-12-08 09:48:04 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-12-08 09:48:04 +0000
commit37b3d62f8e55b022b107ac0ef553e400202a6ee1 (patch)
tree7d2dff0a751c544165f5ebd7079bcb583dd5b16f /Src
parentb8787e39cf78c9212a4816cbe978d77d3f63289f (diff)
downloadzsh-37b3d62f8e55b022b107ac0ef553e400202a6ee1.tar.gz
zsh-37b3d62f8e55b022b107ac0ef553e400202a6ee1.tar.xz
zsh-37b3d62f8e55b022b107ac0ef553e400202a6ee1.zip
zsh-workers/8939
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/comp.h3
-rw-r--r--Src/Zle/compcore.c10
-rw-r--r--Src/Zle/complist.c30
-rw-r--r--Src/Zle/compresult.c52
4 files changed, 58 insertions, 37 deletions
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index a177be614..59ca5be06 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -120,6 +120,8 @@ struct cmatch {
 #define CMF_NOSPACE  (1<< 8)	/* don't add a space */
 #define CMF_PACKED   (1<< 9)	/* prefer LIST_PACKED */
 #define CMF_ROWS     (1<<10)	/* prefer LIST_ROWS_FIRST */
+#define CMF_MULT     (1<<11)	/* string appears more than once */
+#define CMF_FMULT    (1<<12)	/* first of multiple equal strings */
 
 /* Stuff for completion matcher control. */
 
@@ -269,6 +271,7 @@ struct cldata {
     int nlines;			/* number of lines needed */
     int hidden;			/* != 0 if there are hidden matches */
     int onlyexpl;		/* != 0 if only explanations to print */
+    int showall;		/* != 0 if hidden matches should be shown */
 };
 
 typedef void (*CLPrintFunc)(Cmgroup, Cmatch *, int, int, int, int,
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index d6f21f46d..c2767f90c 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -2376,14 +2376,15 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
 		    /* Mark those, that would show the same string in the list. */
 		    for (; bp[1] && !(*ap)->disp && !(bp[1])->disp &&
 			     !strcmp((*ap)->str, (bp[1])->str); bp++)
-			(bp[1])->flags |= CMF_NOLIST;
+			(bp[1])->flags |= CMF_MULT;
+		    (*ap)->flags |= CMF_FMULT;
 		}
 		*cp = NULL;
 	    }
 	    for (ap = rp; *ap; ap++) {
 		if ((*ap)->disp && ((*ap)->flags & CMF_DISPLINE))
 		    ll++;
-		if ((*ap)->flags & CMF_NOLIST)
+		if ((*ap)->flags & (CMF_NOLIST | CMF_MULT))
 		    nl++;
 	    }
 	} else {
@@ -2404,14 +2405,15 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
 		    ap = bp;
 		    for (; bp[1] && !(*ap)->disp && !(bp[1])->disp &&
 			     !strcmp((*ap)->str, (bp[1])->str); bp++)
-			(bp[1])->flags |= CMF_NOLIST;
+			(bp[1])->flags |= CMF_MULT;
+		    (*ap)->flags |= CMF_FMULT;
 		}
 		*cp = NULL;
 	    }
 	    for (ap = rp; *ap; ap++) {
 		if ((*ap)->disp && ((*ap)->flags & CMF_DISPLINE))
 		    ll++;
-		if ((*ap)->flags & CMF_NOLIST)
+		if ((*ap)->flags & (CMF_NOLIST | CMF_MULT))
 		    nl++;
 	    }
 	}
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 00d1fb954..6d4648446 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -57,8 +57,10 @@ static Keymap mskeymap;
 #define COL_TC 13
 #define COL_SP 14
 #define COL_MA 15
+#define COL_HI 16
+#define COL_MU 17
 
-#define NUM_COLS 16
+#define NUM_COLS 18
 
 /* Maximum number of in-string colours supported. */
 
@@ -68,14 +70,14 @@ static Keymap mskeymap;
 
 static char *colnames[] = {
     "no", "fi", "di", "ln", "pi", "so", "bd", "cd", "ex", "mi",
-    "lc", "rc", "ec", "tc", "sp", "ma", NULL
+    "lc", "rc", "ec", "tc", "sp", "ma", "hi", "mu", NULL
 };
 
 /* Default values. */
 
 static char *defcols[] = {
     "0", "0", "1;34", "1;36", "33", "1;35", "1;33", "1;33", "1;32", NULL,
-    "\033[", "m", NULL, "0", "0", "7"
+    "\033[", "m", NULL, "0", "0", "7", "0", "0"
 };
 
 /* This describes a terminal string for a file type. */
@@ -654,7 +656,11 @@ clprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width,
 	    mgtabp = mgtab + mm;
 	    mmlen = mcols;
 	    zcputs(&mcolors, g->name, COL_MA);
-	} else
+	} else if (m->flags & CMF_NOLIST)
+	    zcputs(&mcolors, g->name, COL_HI);
+	else if (mselect >= 0 && (m->flags & (CMF_MULT | CMF_FMULT)))
+	    zcputs(&mcolors, g->name, COL_MU);
+	else
 	    subcols = putmatchcol(&mcolors, g->name, m->disp);
 	if (subcols)
 	    clprintfmt(&mcolors, m->disp);
@@ -689,7 +695,11 @@ clprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width,
 	    mgtabp = mgtab + mx + mm;
 	    mmlen = width;
 	    zcputs(&mcolors, g->name, COL_MA);
-	} else if (buf)
+	} else if (m->flags & CMF_NOLIST)
+	    zcputs(&mcolors, g->name, COL_HI);
+	else if (mselect >= 0 && (m->flags & (CMF_MULT | CMF_FMULT)))
+	    zcputs(&mcolors, g->name, COL_MU);
+	else if (buf)
 	    subcols = putfilecol(&mcolors, g->name, path, buf->st_mode);
 	else
 	    subcols = putmatchcol(&mcolors, g->name, (m->disp ? m->disp : m->str));
@@ -739,7 +749,7 @@ complistmatches(Hookdef dummy, Chdata dat)
     }
     getcols(&mcolors);
 
-    calclist();
+    calclist(mselect >= 0);
 
     if (!listdat.nlines || (mselect >= 0 &&
 			    (!(isset(USEZLE) && !termflags &&
@@ -750,10 +760,6 @@ complistmatches(Hookdef dummy, Chdata dat)
 	amatches = oamatches;
 	return 1;
     }
-    if (listdat.hidden) {
-	noselect = 1;
-	mselect = -1;
-    }
     if (inselect)
 	clearflag = 0;
 
@@ -777,7 +783,7 @@ complistmatches(Hookdef dummy, Chdata dat)
     last_cap = (char *) zhalloc(max_caplen + 1);
     *last_cap = '\0';
 
-    if (!printlist(1, clprintm) || listdat.nlines >= lines)
+    if (!printlist(1, clprintm, (mselect >= 0)) || listdat.nlines >= lines)
 	noselect = 1;
 
     amatches = oamatches;
@@ -1159,6 +1165,8 @@ domenuselect(Hookdef dummy, Chdata dat)
 	if (!noselect) {
 	    showinglist = -2;
 	    onlyexpl = oe;
+	    if (!smatches)
+		clearlist = 1;
 	    zrefresh();
 	}
 	fdat = NULL;
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index 4aa171ea1..3bb7c60ce 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -1101,7 +1101,7 @@ list_lines(void)
     oam = amatches;
     amatches = pmatches;
     listdat.valid = 0;
-    calclist();
+    calclist(0);
     listdat.valid = 0;
     amatches = oam;
 
@@ -1122,10 +1122,13 @@ comp_list(char *v)
 
 /**/
 Cmatch *
-skipnolist(Cmatch *p)
+skipnolist(Cmatch *p, int showall)
 {
-    while (*p && (((*p)->flags & (CMF_NOLIST | CMF_HIDE)) ||
-		  ((*p)->disp && ((*p)->flags & (CMF_DISPLINE | CMF_HIDE)))))
+    int mask = (showall ? 0 : (CMF_NOLIST | CMF_MULT)) | CMF_HIDE;
+
+    while (*p && (((*p)->flags & mask) ||
+		  ((*p)->disp &&
+		   ((*p)->flags & (CMF_DISPLINE | CMF_HIDE)))))
 	p++;
 
     return p;
@@ -1133,7 +1136,7 @@ skipnolist(Cmatch *p)
 
 /**/
 mod_export void
-calclist(void)
+calclist(int showall)
 {
     Cmgroup g;
     Cmatch *p, m;
@@ -1143,7 +1146,7 @@ calclist(void)
     VARARR(int, mlens, nmatches + 1);
 
     if (listdat.valid && onlyexpl == listdat.onlyexpl &&
-	menuacc == listdat.menuacc &&
+	menuacc == listdat.menuacc && showall == listdat.showall &&
 	lines == listdat.lines && columns == listdat.columns)
 	return;
 
@@ -1169,8 +1172,8 @@ calclist(void)
 		while ((sptr = *pp)) {
 		    while (sptr && *sptr) {
 			nlines += (nlptr = strchr(sptr, '\n'))
-			    ? 1 + (nlptr-sptr)/columns
-			    : strlen(sptr)/columns;
+			    ? 1 + (nlptr-sptr) / columns
+			    : strlen(sptr) / columns;
 			sptr = nlptr ? nlptr+1 : NULL;
 		    }
 		    nlines++;
@@ -1217,7 +1220,7 @@ calclist(void)
 			g->flags &= ~CGF_PACKED;
 		    if (!(m->flags & CMF_ROWS))
 			g->flags &= ~CGF_ROWS;
-		} else if (!(m->flags & CMF_NOLIST)) {
+		} else if (showall || !(m->flags & (CMF_NOLIST | CMF_MULT))) {
 		    l = niceztrlen(m->str);
 		    ndisp++;
 		    if (l > glong)
@@ -1290,7 +1293,8 @@ calclist(void)
 			    if (m->disp) {
 				if (!(m->flags & CMF_DISPLINE))
 				    glines += 1 + (mlens[m->gnum] / columns);
-			    } else if (!(m->flags & CMF_NOLIST))
+			    } else if (showall ||
+				       !(m->flags & (CMF_NOLIST | CMF_MULT)))
 				glines += 1 + ((mlens[m->gnum]) / columns);
 			}
 		}
@@ -1385,7 +1389,7 @@ calclist(void)
 
 		    for (tcols = columns / g->shortest; tcols > g->cols;
 			 tcols--) {
-			p = first = skipnolist(g->matches);
+			p = first = skipnolist(g->matches, showall);
 			for (maxlen = width = maxlines = llines = tcol = 0,
 				 count = g->dcount;
 			     count > 0; count--) {
@@ -1394,7 +1398,7 @@ calclist(void)
 			    if (addlen > maxlen)
 				maxlen = addlen;
 			    for (i = tcols; i && *p; i--)
-				p = skipnolist(p + 1);
+				p = skipnolist(p + 1, showall);
 
 			    llines++;
 			    if (!*p) {
@@ -1407,7 +1411,7 @@ calclist(void)
 				ws[tcol++] = maxlen;
 				maxlen = 0;
 
-				p = first = skipnolist(first + 1);
+				p = first = skipnolist(first + 1, showall);
 			    }
 			}
 			if (tlines) {
@@ -1421,6 +1425,8 @@ calclist(void)
 			tlines = maxlines;
 		} else {
 		    int addlen;
+		    int smask = ((showall ? 0 : (CMF_NOLIST | CMF_MULT)) |
+				 CMF_HIDE);
 
 		    for (tlines = ((g->totl + columns) / columns);
 			 tlines < g->lins; tlines++) {
@@ -1429,7 +1435,7 @@ calclist(void)
 			     (m = *p); p++, nth++) {
 			    if (!(m->flags &
 				  (m->disp ? (CMF_DISPLINE | CMF_HIDE) :
-				   (CMF_NOLIST | CMF_HIDE)))) {
+				   smask))) {
 				addlen = mlens[m->gnum] + add;
 				if (addlen > maxlen)
 				    maxlen = addlen;
@@ -1481,6 +1487,7 @@ calclist(void)
     listdat.onlyexpl = onlyexpl;
     listdat.columns = columns;
     listdat.lines = lines;
+    listdat.showall = showall;
 }
 
 /**/
@@ -1531,7 +1538,7 @@ int asklist(void)
 
 /**/
 mod_export int
-printlist(int over, CLPrintFunc printm)
+printlist(int over, CLPrintFunc printm, int showall)
 {
     Cmgroup g;
     Cmatch *p, m;
@@ -1628,7 +1635,8 @@ printlist(int over, CLPrintFunc printm)
 		    pp += ((g->flags & CGF_ROWS) ? g->cols : 1);
 		}
 	    }
-	} else if (!listdat.onlyexpl && g->lcount) {
+	} else if (!listdat.onlyexpl &&
+		   (g->lcount || (showall && g->mcount))) {
 	    int n = g->dcount, nl, nc, i, j, wid;
 	    Cmatch *q;
 
@@ -1662,7 +1670,7 @@ printlist(int over, CLPrintFunc printm)
 			tcout(TCCLEAREOD);
 		}
 	    }
-	    for (p = skipnolist(g->matches); n && nl--;) {
+	    for (p = skipnolist(g->matches, showall); n && nl--;) {
 		i = g->cols;
 		mc = 0;
 		q = p;
@@ -1693,7 +1701,7 @@ printlist(int over, CLPrintFunc printm)
 		    if (--n)
 			for (j = ((g->flags & CGF_ROWS) ? 1 : nc);
 			     j && *q; j--)
-			    q = skipnolist(q + 1);
+			    q = skipnolist(q + 1, showall);
 		    mc++;
 		}
 		while (i-- > 0) {
@@ -1712,11 +1720,11 @@ printlist(int over, CLPrintFunc printm)
 		    if (nl)
 			for (j = ((g->flags & CGF_ROWS) ? g->cols : 1);
 			     j && *p; j--)
-			    p = skipnolist(p + 1);
+			    p = skipnolist(p + 1, showall);
 		}
 	    }
 	}
-	if (g->lcount)
+	if (g->lcount || (showall && g->mcount))
 	    pnl = 1;
 	g = g->next;
     }
@@ -1776,7 +1784,7 @@ iprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width,
 int
 ilistmatches(Hookdef dummy, Chdata dat)
 {
-    calclist();
+    calclist(0);
 
     if (!listdat.nlines) {
 	showinglist = listshown = 0;
@@ -1785,7 +1793,7 @@ ilistmatches(Hookdef dummy, Chdata dat)
     if (asklist())
 	return 0;
 
-    printlist(0, iprintm);
+    printlist(0, iprintm, 0);
 
     return 0;
 }