about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-10-25 12:36:41 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-10-25 12:36:41 +0000
commit8cdb92e6c6192be5e57721151beb3198448c1367 (patch)
tree254ac37e16c6ed6242c21334754b3bda339b260d
parentfe45089a5545f6bfad52da591a823bf4c565c2d4 (diff)
downloadzsh-8cdb92e6c6192be5e57721151beb3198448c1367.tar.gz
zsh-8cdb92e6c6192be5e57721151beb3198448c1367.tar.xz
zsh-8cdb92e6c6192be5e57721151beb3198448c1367.zip
zsh-workers/8412
-rw-r--r--Doc/Zsh/mod_complist.yo7
-rw-r--r--Src/Zle/complist.c73
2 files changed, 43 insertions, 37 deletions
diff --git a/Doc/Zsh/mod_complist.yo b/Doc/Zsh/mod_complist.yo
index 8aab13c68..ca8fa2be3 100644
--- a/Doc/Zsh/mod_complist.yo
+++ b/Doc/Zsh/mod_complist.yo
@@ -61,6 +61,13 @@ for the left code (see below)
 item(tt(rc m))(
 for the right code
 )
+item(tt(tc) var(0))(
+for the character indicating the file type  printed after filenames if
+the tt(LIST_TYPES) option is set
+)
+item(tt(sp) var(0))(
+for the spaces printed after matches to align the next column
+)
 item(tt(ec) var(none))(
 for the end code
 )
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 1ff6721c8..38609663a 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -54,22 +54,24 @@ static Keymap mskeymap;
 #define COL_LC 10
 #define COL_RC 11
 #define COL_EC 12
-#define COL_MA 13
+#define COL_TC 13
+#define COL_SP 14
+#define COL_MA 15
 
-#define NUM_COLS 14
+#define NUM_COLS 16
 
 /* Names of the terminal strings. */
 
 static char *colnames[] = {
     "no", "fi", "di", "ln", "pi", "so", "bd", "cd", "ex", "mi",
-    "lc", "rc", "ec", "ma", NULL
+    "lc", "rc", "ec", "tc", "sp", "ma", 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, "7"
+    "\033[", "m", NULL, "0", "0", "7"
 };
 
 /* This describes a terminal string for a filename extension. */
@@ -246,6 +248,15 @@ getcols(Listcols c)
     return;
 }
 
+/* Information about the list shown. */
+
+static int noselect, mselect, inselect, mcol, mline, mcols, mlines, mmlen;
+static Cmatch **mtab, **mmtabp;
+static Cmgroup *mgtab, *mgtabp;
+static struct listcols mcolors;
+
+/* The last color used. */
+
 static int last_col = COL_NO;
 
 static void
@@ -272,6 +283,17 @@ zcputs(Listcols c, int colour)
     return;
 }
 
+/* Turn off colouring. */
+
+static void
+zcoff(void)
+{
+    if (mcolors.cols[COL_EC])
+	tputs(mcolors.cols[COL_EC], 1, putshout);
+    else
+	zcputs(&mcolors, COL_NO);
+}
+
 /* Get the terminal color string for the file with the given name and
  * file modes. */
 
@@ -312,14 +334,6 @@ putcolstr(Listcols c, char *n, mode_t m)
     return;
 }
 
-/* Information about the list shown. */
-
-static int noselect, mselect, inselect, mcol, mline, mcols, mlines, mmlen;
-static Cmatch **mtab, **mmtabp;
-static Cmgroup *mgtab, *mgtabp;
-static struct listcols mcolors;
-
-
 static void
 clprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width,
 	 char *path, struct stat *buf)
@@ -361,10 +375,7 @@ clprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width,
 	    cc = COL_NO;
 	zcputs(&mcolors, cc);
 	printfmt(m->disp, 0, 1, 0);
-	if (mcolors.cols[COL_EC])
-	    tputs(mcolors.cols[COL_EC], 1, putshout);
-	else
-	    zcputs(&mcolors, COL_NO);
+	zcoff();
     } else {
 	int mx;
 
@@ -401,39 +412,27 @@ clprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width,
 	nicezputs((m->disp ? m->disp : m->str), shout);
 	len = niceztrlen(m->disp ? m->disp : m->str);
 
-	if (m->gnum != mselect) {
-	    if (mcolors.cols[COL_EC])
-		tputs(mcolors.cols[COL_EC], 1, putshout);
-	    else
-		zcputs(&mcolors, COL_NO);
-	}
-
 	if (isset(LISTTYPES)) {
+	    zcoff();
+	    zcputs(&mcolors, COL_TC);
 	    if (buf)
 		putc(file_type(buf->st_mode), shout);
 	    else
 		putc(' ', shout);
 	    len++;
 	}
-	len = width - len - 2;
+	if ((len = width - len - 2) > 0) {
+	    zcoff();
+	    zcputs(&mcolors, COL_SP);
 
-	while (len-- > 0)
-	    putc(' ', shout);
-
-	if (m->gnum == mselect) {
-	    if (mcolors.cols[COL_EC])
-		tputs(mcolors.cols[COL_EC], 1, putshout);
-	    else
-		zcputs(&mcolors, COL_NO);
+	    while (len-- > 0)
+		putc(' ', shout);
 	}
-
+	zcoff();
 	if (!lastc) {
 	    zcputs(&mcolors, COL_NO);
 	    fputs("  ", shout);
-	    if (mcolors.cols[COL_EC])
-		tputs(mcolors.cols[COL_EC], 1, putshout);
-	    else
-		zcputs(&mcolors, COL_NO);
+	    zcoff();
 	}
     }
 }