summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-19 06:49:36 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-19 06:49:36 +0000
commit6a7c002a7c9f7d695e3cb055d8285f7f18749ccd (patch)
tree0d9bc11b2742d7618d731a8576a697cd393e3ff5
parent44ee911749a56a1320e6f415d4c4da46d73bb884 (diff)
downloadzsh-6a7c002a7c9f7d695e3cb055d8285f7f18749ccd.tar.gz
zsh-6a7c002a7c9f7d695e3cb055d8285f7f18749ccd.tar.xz
zsh-6a7c002a7c9f7d695e3cb055d8285f7f18749ccd.zip
default for list-prompt style, %[MLP] use fixed-width strings, %[mlp] use variable-width strings (10816)
-rw-r--r--ChangeLog7
-rw-r--r--Completion/Core/_main_complete5
-rw-r--r--Doc/Zsh/compsys.yo20
-rw-r--r--Doc/Zsh/mod_complist.yo24
-rw-r--r--Src/Zle/complist.c61
5 files changed, 85 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 763553d01..5b0234fc9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2000-04-19  Sven Wischnowsky  <wischnow@informatik.hu-berlin.de>
+
+	* 10816: Completion/Core/_main_complete, Doc/Zsh/compsys.yo,
+ 	Doc/Zsh/mod_complist.yo, Src/Zle/complist.c: default for
+ 	list-prompt style, %[MLP] use fixed-width strings, %[mlp] use
+ 	variable-width strings
+	
 2000-04-18  Sven Wischnowsky  <wischnow@informatik.hu-berlin.de>
 
 	* 10812: Completion/Core/_path_files: fix completion after ~<num>
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index 0c0bd05b6..347326c49 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -56,8 +56,9 @@ _def_menu_style=( "$_last_menu_style[@]"
                 )
 _last_menu_style=()
 
-if zstyle -s ":completion:${curcontext}:default" list-prompt LISTPROMPT &&
-   [[ -n "$LISTPROMPT" ]]; then
+zstyle -s ":completion:${curcontext}:default" list-prompt LISTPROMPT ||
+    LISTPROMPT='Current position at %P    Continue? '
+if [[ -n "$LISTPROMPT" ]]; then
   zmodload -i zsh/complist
   compstate[list_max]=scroll
 fi
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 84d301e5a..547db492b 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -1274,11 +1274,21 @@ completion lists that don't fit on the screen can be scrolled (see
 ifzman(the description of the tt(zsh/complist) module in zmanref(zshmodules))\
 ifnzman(noderef(The zsh/complist Module))\
 ). The value will be displayed after every screenful, prompting for a
-key and may contain the escape `tt(%l)' which will be replaced by the
-number of the last line displayed and the total number of lines. As
+key press. It may contain the escape `tt(%l)' or `tt(%L)' which will be
+replaced by the number of the last line displayed and the total number
+of lines. A `tt(%m)' or `tt(%M)' will be replaced by the number of the 
+last match shown and the total number of matches and `tt(%p)' and
+`tt(%P)' will be replaced by `tt(Top)' when at the beginning of the
+list, `tt(Bottom)' when at the end and the position shown in percent
+of the total length. In each of these cases the form with the
+uppercase letter is replaced by a string of fixed width, padded to the 
+right with spaces. As
 usual, the `tt(%S)', `tt(%s)', `tt(%B)', `tt(%b)', `tt(%U)', `tt(%u)',
 and `tt(%{)...tt(%})' escapes for the terminal display modes are
 understood, too.
+
+Note that this style has a default value. If you don't want to use
+scrolling, set this style to an empty string.
 )
 kindex(list-rows-first, completion style)
 item(tt(list-rows-first))(
@@ -1578,11 +1588,7 @@ If this is set to a non-empty string for the tt(default) tag, its
 value will be displayed during menu-selection (see the tt(menu) style
 above) when the completion list does not fit on the screen as a
 whole. The same escapes as for the tt(list-prompt) style are
-understood, plus `tt(%m)' which is replaced by the number of the
-currently selected match and the total number of matches and `tt(%p)'
-which is replaced by `tt(Top)' when the mark is on the first line,
-`tt(Bottom)' when it is on the last line and the relative position of
-the mark in the list given as a percentage.
+understood, but give the number of the match or line the mark is on.
 )
 kindex(select-scroll, completion style)
 item(tt(select-scroll))(
diff --git a/Doc/Zsh/mod_complist.yo b/Doc/Zsh/mod_complist.yo
index 63039c5d1..4a6429e79 100644
--- a/Doc/Zsh/mod_complist.yo
+++ b/Doc/Zsh/mod_complist.yo
@@ -159,10 +159,16 @@ currently selected.
 If the parameter tt(LISTPROMPT) is set, its value will be used as the
 prompt.  The value may contain escapes of the form `tt(%x)'. It
 supports the escapes `tt(%B)', `tt(%b)', `tt(%S)', `tt(%s)', `tt(%U)',
-`tt(%u)' and `tt(%{...%})' known from the shell prompts and the
-additional sequence `tt(%l)' which is replaced by the number of the
-last line shown and the total number of lines in the form
-`var(number)tt(/)var(total)'.
+`tt(%u)' and `tt(%{...%})' known from the shell prompts and three
+pairs of additional sequences. A `tt(%l)' or `tt(%L)' is replaced by
+the number of the last line shown and the total number of lines in the form
+`var(number)tt(/)var(total)'. A `tt(%m)' or `tt(%M)' is replaced with
+the number of the last match shown and the total number of matches and 
+`tt(%p)' or `tt(%P)' is replaced with `tt(Top)', `tt(Bottom)' or the
+position of the first line shown in percent of the total number of
+lines, respectively. In each of these cases the one with the uppercase 
+letter will be replaced with a string of fixed width, padded to the
+right with spaces.
 
 As for the tt(ZLS_COLORS) and tt(ZLS_COLOURS) parameters,
 tt(LISTPROMPT) should not be set directly when using the shell
@@ -207,13 +213,9 @@ control sequence as for the `tt(%S)' escape in prompts is used.
 
 If there are more matches than fit on the screen and the parameter
 tt(SELECTPROMPT) is set, its value will be shown below the
-matches. Next to the escape sequences understood for the
-tt(LISTPROMPT) parameter, a `tt(%m)' will be replaced by a string
-containing the number of the match the mark is on and the total number 
-of matches in the form `var(number)tt(/)var(total)' and the sequence
-`tt(%p)' will be replaced with `tt(Top)', `tt(Bottom)' or the position
-in percent of the total size when the mark is in the first line, in
-the last line or somewhere in between, respectively.
+matches. It supports the sames escape sequences as tt(LISTPROMPT), but 
+the number of the match or line shown will be that of the one where
+the mark is placed.
 
 The tt(SELECTSCROLL) parameter can be used to specify how the list is
 scrolled. If the parameter is unset, this is done line by line, if it
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 9b9031f14..0529077d3 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -383,7 +383,7 @@ getcols(Listcols c)
 
 static int noselect, mselect, inselect, mcol, mline, mcols, mlines, mmlen;
 static int selected, mlbeg = -1, mlend = 9999999, mscroll, mrestlines;
-static int mnew, mlastcols, mlastlines, mhasstat;
+static int mnew, mlastcols, mlastlines, mhasstat, mfirstl, mlastm;
 static char *mstatus;
 static Cmatch **mtab, **mmtabp;
 static Cmgroup *mgtab, *mgtabp;
@@ -656,7 +656,7 @@ asklistscroll(int ml)
     Thingy cmd;
     int i, ret = 0;
 
-    compprintfmt(NULL, -1, 1, 1, ml, NULL);
+    compprintfmt(NULL, 1, 1, 1, ml, NULL);
 
     fflush(shout);
     zsetterm();
@@ -791,24 +791,38 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
 			p--;
 		    break;
 		case 'm':
-		    if (stat && n >= 0) {
-			sprintf(nbuf, "%d/%d", mselect, listdat.nlist);
+		    if (stat) {
+			sprintf(nc, "%d/%d", (n ? mlastm : mselect),
+				listdat.nlist);
+			m = 2;
+		    }
+		    break;
+		case 'M':
+		    if (stat) {
+			sprintf(nbuf, "%d/%d", (n ? mlastm : mselect),
+				listdat.nlist);
 			sprintf(nc, "%-9s", nbuf);
 			m = 2;
 		    }
 		    break;
 		case 'l':
 		    if (stat) {
+			sprintf(nc, "%d/%d", ml + 1, listdat.nlines);
+			m = 2;
+		    }
+		    break;
+		case 'L':
+		    if (stat) {
 			sprintf(nbuf, "%d/%d", ml + 1, listdat.nlines);
 			sprintf(nc, "%-9s", nbuf);
 			m = 2;
 		    }
 		    break;
 		case 'p':
-		    if (stat && n >= 0) {
+		    if (stat) {
 			if (ml == listdat.nlines - 1)
 			    strcpy(nc, "Bottom");
-			else if (mlbeg || ml != n)
+			else if (n ? mfirstl : (mlbeg > 0 || ml != mfirstl))
 			    sprintf(nc, "%d%%",
 				    ((ml + 1) * 100) / listdat.nlines);
 			else
@@ -816,6 +830,18 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
 			m = 2;
 		    }
 		    break;
+		case 'P':
+		    if (stat) {
+			if (ml == listdat.nlines - 1)
+			    strcpy(nc, "Bottom");
+			else if (n ? mfirstl : (mlbeg > 0 || ml != mfirstl))
+			    sprintf(nc, "%2d%%   ",
+				    ((ml + 1) * 100) / listdat.nlines);
+			else
+			    strcpy(nc, "Top   ");
+			m = 2;
+		    }
+		    break;
 		}
 		if (m == 2 && dopr == 1) {
 		    int l = strlen(nc);
@@ -853,6 +879,8 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
 		    ml++;
 		if (mscroll && beg && !--mrestlines && (ask = asklistscroll(ml))) {
 		    *stop = 1;
+		    if (stat && n)
+			mfirstl = -1;
 		    return l + (cc / columns);
 		}
 	    }
@@ -861,6 +889,9 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
     if (dopr && mlbeg >= 0 && tccan(TCCLEAREOL))
 	tcout(TCCLEAREOL);
 
+    if (stat && n)
+	mfirstl = -1;
+
     return l + (cc / columns);
 }
 
@@ -944,8 +975,9 @@ compprintlist(int showall)
     Cmatch *p, m;
     Cexpl *e;
     int pnl = 0, cl, mc = 0, ml = 0, printed = 0, stop = 0, asked = 1;
-    int lastused = 0, fl = -1;
+    int lastused = 0;
 
+    mfirstl = -1;
     if (mnew || lastbeg != mlbeg || mlbeg < 0) {
 	lasttype = 0;
 	lastg = NULL;
@@ -988,6 +1020,8 @@ compprintlist(int showall)
 				tcout(TCCLEAREOD);
 			}
 		    }
+		    if (mlbeg < 0 && mfirstl < 0)
+			mfirstl = ml;
 		    l = compprintfmt((*e)->str, (*e)->count, dolist(ml), 1,
 				     ml, &stop);
 		    if (stop)
@@ -1026,6 +1060,8 @@ compprintlist(int showall)
 			tcout(TCCLEAREOD);
 		}
 	    }
+	    if (mlbeg < 0 && mfirstl < 0)
+		mfirstl = ml;
 	    if (g->flags & CGF_LINES) {
 		while (*pp) {
 		    if (compzputs(*pp, ml))
@@ -1112,8 +1148,8 @@ compprintlist(int showall)
 				    tcout(TCCLEAREOD);
 			    }
 			}
-			if (fl < 0)
-			    fl = ml;
+			if (mfirstl < 0)
+			    mfirstl = ml;
 			if (dolist(ml))
 			    printed++;
 			if (clprintm(g, p, 0, ml, 1, 0, NULL, NULL))
@@ -1183,8 +1219,8 @@ compprintlist(int showall)
 
 		    if (dolist(ml))
 			printed++;
-		    if (fl < 0)
-			fl = ml;
+		    if (mfirstl < 0)
+			mfirstl = ml;
 
 		    if (--n)
 			for (j = ((g->flags & CGF_ROWS) ? 1 : nc);
@@ -1233,7 +1269,7 @@ compprintlist(int showall)
 	    if ((ml = listdat.nlines + nlnct) >= lines) {
 		if (mhasstat) {
 		    putc('\n', shout);
-		    compprintfmt(NULL, fl, 1, 1, mline, NULL);
+		    compprintfmt(NULL, 0, 1, 1, mline, NULL);
 		}
 		ml = lines - 1;
 	    } else
@@ -1287,6 +1323,7 @@ clprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width,
 	return 0;
     }
     m = *mp;
+    mlastm = m->gnum;
     if (m->disp && (m->flags & CMF_DISPLINE)) {
 	if (mselect >= 0) {
 	    int mm = (mcols * ml), i;