Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: files attributes not colored by complist
- X-seq: zsh-workers 8412
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: PATCH: files attributes not colored by complist
- Date: Mon, 25 Oct 1999 14:18:07 +0200 (MET DST)
- In-reply-to: Zefram's message of Mon, 25 Oct 1999 11:46:50 +0100 (BST)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Zefram wrote:
> Sven Wischnowsky wrote:
> >Personally I don't like this at all. But maybe we can hear other
> >opinions?
>
> I don't normally used coloured ls or completion listings at all. However...
>
> In the absence of special background colours, I find the GNU ls style,
> with only the filename coloured, to be much more pleasant. If backgrounds
> are used, I see your point; perhaps we should allow the colours for
> the type characters and spaces to be set separately. OTOH, the people
> that are setting background colours here are those that have taken the
> time to configure it themselves; they're already using colour ls, and
> so probably do want the GNU behaviour.
This patch adds the `tc' (for type-character) and `sp' (for `space')
capabilities.
> Another thought: we don't need to be compatible, but we shouldn't
> be gratuitously incompatible either. [Z]LS_COLORS strings should be
> interoperable.
I thought they are. At least we ignore unknown capabilities and I
think I checked that my GNU-ls does that, too.
Bye
Sven
--- oldsrc/Zle/complist.c Thu Oct 21 08:59:15 1999
+++ Src/Zle/complist.c Mon Oct 25 14:12:28 1999
@@ -54,22 +54,24 @@
#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 @@
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 @@
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 @@
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 @@
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;
@@ -402,28 +413,26 @@
len = niceztrlen(m->disp ? m->disp : m->str);
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;
-
- while (len-- > 0)
- putc(' ', shout);
+ if ((len = width - len - 2) > 0) {
+ zcoff();
+ zcputs(&mcolors, COL_SP);
- 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();
}
}
}
--- olddoc/Zsh/mod_complist.yo Thu Oct 21 08:59:20 1999
+++ Doc/Zsh/mod_complist.yo Mon Oct 25 14:11:26 1999
@@ -61,6 +61,13 @@
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
)
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author