zsh-workers
 help / color / mirror / code / Atom feed
From: Zefram <A.Main@dcs.warwick.ac.uk>
To: zsh-workers@math.gatech.edu (Z Shell workers mailing list)
Subject: Re: patches to nice*
Date: Sat, 25 Nov 1995 13:56:56 +0000 (GMT)	[thread overview]
Message-ID: <1808.199511251356@stone.dcs.warwick.ac.uk> (raw)

-----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-----


                 reply	other threads:[~1995-11-25 14:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1808.199511251356@stone.dcs.warwick.ac.uk \
    --to=a.main@dcs.warwick.ac.uk \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).