From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gatech.edu (gatech.edu [130.207.244.244]) by werple.mira.net.au (8.6.12/8.6.9) with SMTP id QAA10483 for ; Wed, 19 Jul 1995 16:37:18 +1000 Received: from math (math.skiles.gatech.edu) by gatech.edu with SMTP id AA23504 (5.65c/Gatech-10.0-IDA for ); Wed, 19 Jul 1995 02:25:51 -0400 Received: by math (5.x/SMI-SVR4) id AA11874; Wed, 19 Jul 1995 02:22:08 -0400 Resent-Date: Wed, 19 Jul 1995 07:23:10 +0100 (BST) Old-Return-Path: From: Zefram Message-Id: <29005.199507190623@stone.dcs.warwick.ac.uk> Subject: Explanation string fixes To: zsh-workers@math.gatech.edu (Z Shell workers mailing list) Date: Wed, 19 Jul 1995 07:23:10 +0100 (BST) X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]6001.33 Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-Id: <"uDDgM2.0.Sv2.FIA3m"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/240 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----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 == ). */ ! 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 == ). */ ! 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-----