Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: patches to nice*
- X-seq: zsh-workers 647
- From: Zefram <A.Main@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (Z Shell workers mailing list)
- Subject: Re: patches to nice*
- Date: Sat, 25 Nov 1995 13:56:56 +0000 (GMT)
-----BEGIN PGP SIGNED MESSAGE-----
Here's a comment patch for the nice* functions and stradd(), after my
recent patch to them.
-zefram
*** 1.1.1.1 1995/11/25 05:12:26
--- utils.c 1995/11/25 13:35:54
***************
*** 135,140 ****
--- 135,150 ----
return 0;
}
+ /* Turn a character into a visible representation thereof. The visible *
+ * string is put together in a static buffer, and this function returns *
+ * a pointer to it. Printable characters stand for themselves, DEL is *
+ * represented as "^?", newline and tab are represented as "\n" and *
+ * "\t", and normal control characters are represented in "^C" form. *
+ * Characters with bit 7 set, if unprintable, are represented as "\M-" *
+ * followed by the visible representation of the character with bit 7 *
+ * stripped off. Tokens are interpreted, rather than being treated as *
+ * literal characters. */
+
/**/
char *
nicechar(int c)
*** 1.2 1995/11/25 05:12:26
--- zle_misc.c 1995/11/25 13:52:34
***************
*** 639,668 ****
--- 639,690 ----
static char *truncstr;
static int dontcount, lensb, trunclen;
+ /* stradd() adds a string to the prompt, in a *
+ * visible representation, doing truncation. */
+
/**/
void
stradd(char *d)
{
+ /* dlen is the full length of the string we want to add */
int dlen = nicestrlen(d);
char *ps, *pd, *pc, *t;
int tlen, maxlen;
addbufspc(dlen);
+ /* This loop puts the nice representation of the string into the prompt *
+ * buffer. It might be modified later. Note that bp isn't changed. */
for(ps=d, pd=bp; *ps; ps++)
for(pc=nicechar(STOUC(*ps)); *pc; pc++)
*pd++=*pc;
if(!trunclen || dlen <= trunclen) {
+ /* No truncation is needed, so update bp and return, *
+ * leaving the full string in the prompt. */
bp += dlen;
return;
}
+ /* We need to truncate. t points to the truncation string -- which is *
+ * inserted literally, without nice representation. tlen is its *
+ * length, and maxlen is the amout of the main string that we want to *
+ * keep. Note that if the truncation string is longer than the *
+ * truncation length (tlen > trunclen), the truncation string is used *
+ * in full. */
t = truncstr + 1;
tlen = strlen(t);
maxlen = tlen < trunclen ? trunclen - tlen : 0;
addbufspc(tlen);
if(*truncstr == '>') {
+ /* '>' means truncate at the right. We just move past the first *
+ * maxlen characters of the string, and write the truncation *
+ * string there. */
bp += maxlen;
while(*t)
pputc(*t++);
} else {
+ /* Truncation at the left: ps is initialised to the start of the *
+ * part of the string that we want to keep. pc points to the *
+ * end of the string. The truncation string is added to the *
+ * prompt, then the desired part of the string is copied into *
+ * the right place. */
ps = bp + dlen - maxlen;
pc = bp + dlen;
while(*t)
-----BEGIN PGP SIGNATURE-----
Version: 2.6.i
iQCVAgUBMLcgPXD/+HJTpU/hAQFV+wP/TaJcOxiebGwEdb6YeIw0zZMnvrxXvibF
kYM9X/NQyEkNoY4SDqP41Na11P8eDaAzGb/6nnx08F/JyfRqZUCSzpYabHxG1mpX
XSBPD1uG1uR+5pdFOYMOi4sYLAVq+7yKSIVBVelxDyVgbY5pXLR/wbFZBp5pViqk
HWJyMN7irn8=
=q9Ml
-----END PGP SIGNATURE-----
Messages sorted by:
Reverse Date,
Date,
Thread,
Author