Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Explanation string fixes



-----BEGIN PGP SIGNED MESSAGE-----

The patch below fixes various problems with completion explanation
strings (compctl -X).  They are fairly self-explanatory.

 -zefram

      *** Src/zle_tricky.c.1.1	1995/07/19 02:37:42
      --- Src/zle_tricky.c	1995/07/19 06:05:16
      ***************
      *** 2187,2193 ****
        docompletion(char *s, int lst, int incmd)
        {
            static int delit, compadd;
      -     int shownexpl;
        
            heapalloc();
            pushheap();
      --- 2187,2192 ----
      ***************
      *** 2199,2212 ****
                goto compend;
            }
        
      !     /* To make sure we only print the explanation once... */
      !     shownexpl = 0;
      ! 
      !     if (lst == COMP_LIST_COMPLETE) {
        	/* All this and the guy only wants to see the list, sigh. */
        	showinglist = -2;
      ! 	shownexpl = 1;
      !     } else {
        	/* We have matches. */
        	if (delit) {
        	    /* If we have to delete the word from the command line, do it
      --- 2198,2207 ----
                goto compend;
            }
        
      !     if (lst == COMP_LIST_COMPLETE)
        	/* All this and the guy only wants to see the list, sigh. */
        	showinglist = -2;
      !     else {
        	/* We have matches. */
        	if (delit) {
        	    /* If we have to delete the word from the command line, do it
      ***************
      *** 2226,2232 ****
            }
        
            /* Print the explanation string if needed. */
      !     if (!shownexpl && expl && nmatches!=1) {
        	int up;
        
        	trashzle();
      --- 2221,2227 ----
            }
        
            /* Print the explanation string if needed. */
      !     if (!showinglist && expl && nmatches!=1) {
        	int up;
        
        	trashzle();
      ***************
      *** 2239,2244 ****
      --- 2234,2241 ----
        
        	if (clearflag)
        	    tcmultout(TCUP, TCMULTUP, up + nlnct);
      + 	else
      + 	    putc('\n', shout);
        	fflush(shout);
            }
          compend:
      ***************
      *** 3466,3478 ****
        int
        printfmt(char *fmt, int n, int dopr)
        {
      !     char *p = fmt, nc[14];
      !     int l = 1, cc = 0;
        
            for (; *p; p++) {
        	/* Handle the `%' stuff (%% == %, %n == <number of matches>). */
      ! 	if (*p == '%')
      ! 	    if (*++p)
        		switch (*p) {
        		case '%':
        		    if (dopr)
      --- 3463,3475 ----
        int
        printfmt(char *fmt, int n, int dopr)
        {
      !     char *p = fmt, nc[DIGBUFSIZE];
      !     int l = 0, cc = 0;
        
            for (; *p; p++) {
        	/* Handle the `%' stuff (%% == %, %n == <number of matches>). */
      ! 	if (*p == '%') {
      ! 	    if (*++p) {
        		switch (*p) {
        		case '%':
        		    if (dopr)
      ***************
      *** 3484,3492 ****
        		    if (dopr)
        			fprintf(shout, nc);
        		    cc += strlen(nc);
        	    } else
        		break;
      ! 	else {
        	    cc++;
        	    if (*p == '\n') {
        		l += 1 + (cc / columns);
      --- 3481,3491 ----
        		    if (dopr)
        			fprintf(shout, nc);
        		    cc += strlen(nc);
      + 		    break;
      + 		}
        	    } else
        		break;
      ! 	} else {
        	    cc++;
        	    if (*p == '\n') {
        		l += 1 + (cc / columns);
      ***************
      *** 3496,3503 ****
        		putc(*p, shout);
        	}
            }
      -     if (dopr)
      - 	putc('\n', shout);
        
            return l + (cc / columns);
        }
      --- 3495,3500 ----
      ***************
      *** 3508,3514 ****
        void
        listmatches(void)
        {
      !     int longest = 1, fct, fw, colsz, t0, t1, ct, up, cl;
            int off, boff, nboff;
            int of = (isset(LISTTYPES) && !(haswhat & HAS_MISC));
            char **arr, **ap, sav;
      --- 3505,3511 ----
        void
        listmatches(void)
        {
      !     int longest = 1, fct, fw, colsz, t0, t1, ct, up, cl, xup = 0;
            int off, boff, nboff;
            int of = (isset(LISTTYPES) && !(haswhat & HAS_MISC));
            char **arr, **ap, sav;
      ***************
      *** 3577,3612 ****
            }
        
            /* Print the explanation string, if any. */
      !     if (expl)
      ! 	up += printfmt(expl, ct, 0);
        
            /* Maybe we have to ask if the user wants to see the list. */
            if ((listmax && ct > listmax) || (!listmax && up >= lines)) {
        	setterm();
      ! 	fprintf(shout, "zsh: do you wish to see all %d possibilities? ", ct);
        	fflush(shout);
        	if (getzlequery() != 'y') {
        	    if (clearflag) {
        		putc('\r', shout);
        		if (tccan(TCCLEAREOD))
        		    tcout(TCCLEAREOD);
      ! 		tcmultout(TCUP, TCMULTUP, nlnct);
        	    } else
        		putc('\n', shout);
        	    return;
        	}
        	if (clearflag) {
        	    putc('\r', shout);
        	    if (tccan(TCCLEAREOD))
        		tcout(TCCLEAREOD);
        	} else
        	    putc('\n', shout);
        	settyinfo(&shttyinfo);
            }
      -     /* After the query, the explanation string was deleted, print it
      -        again. */
      -     if (expl)
      - 	printfmt(expl, ct, 1);
        
            /* Now print the matches. */
            for (t1 = 0; t1 != colsz; t1++) {
      --- 3574,3611 ----
            }
        
            /* Print the explanation string, if any. */
      !     if (expl) {
      ! 	xup = printfmt(expl, ct, 1) + 1;
      ! 	putc('\n', shout);
      ! 	up += xup;
      !     }
        
            /* Maybe we have to ask if the user wants to see the list. */
            if ((listmax && ct > listmax) || (!listmax && up >= lines)) {
      + 	int qup;
        	setterm();
      ! 	qup = printfmt("zsh: do you wish to see all %n possibilities? ", ct, 1);
        	fflush(shout);
        	if (getzlequery() != 'y') {
        	    if (clearflag) {
        		putc('\r', shout);
      + 		tcmultout(TCUP, TCMULTUP, qup);
        		if (tccan(TCCLEAREOD))
        		    tcout(TCCLEAREOD);
      ! 		tcmultout(TCUP, TCMULTUP, nlnct + xup);
        	    } else
        		putc('\n', shout);
        	    return;
        	}
        	if (clearflag) {
        	    putc('\r', shout);
      + 	    tcmultout(TCUP, TCMULTUP, qup);
        	    if (tccan(TCCLEAREOD))
        		tcout(TCCLEAREOD);
        	} else
        	    putc('\n', shout);
        	settyinfo(&shttyinfo);
            }
        
            /* Now print the matches. */
            for (t1 = 0; t1 != colsz; t1++) {

-----BEGIN PGP SIGNATURE-----
Version: 2.6.i

iQBVAgUBMAykvGWJ8JfKi+e9AQE6dQH/TFNtI22JELFKCvWdCMz/zvdBV0VoWCp3
YxXJ+avvCN5ag22PedmQFDqjL+wJTQMD1UO49n+CE0F2GrhNFdDSTg==
=N8NJ
-----END PGP SIGNATURE-----



Messages sorted by: Reverse Date, Date, Thread, Author