summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--Completion/Core/_main_complete26
-rw-r--r--Doc/Zsh/compsys.yo14
-rw-r--r--Doc/Zsh/mod_complist.yo60
-rw-r--r--Src/Zle/compcore.c3
-rw-r--r--Src/Zle/complete.c14
-rw-r--r--Src/Zle/complist.c30
-rw-r--r--Src/Zle/compresult.c8
-rw-r--r--Src/params.c2
9 files changed, 93 insertions, 74 deletions
diff --git a/ChangeLog b/ChangeLog
index e1050bffa..5b3315f4f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-04-27  Sven Wischnowsky  <wischnow@informatik.hu-berlin.de>
+
+	* 10959: Completion/Core/_main_complete, Doc/Zsh/compsys.yo,
+ 	Doc/Zsh/mod_complist.yo, Src/params.c, Src/Zle/compcore.c,
+ 	Src/Zle/complete.c, Src/Zle/complist.c, Src/Zle/compresult.c:
+ 	renamed parameters for menu selection to MENUSELECT, MENUPROMPT
+ 	and MENUSCROLL; no special value for LISTMAX to turn on list
+ 	scrolling, this is done by setting LISTPROMPT now; default values
+ 	for LISTPROMPT and MENUPROMPT when set but empty
+	
 2000-04-27  Adam Spiers <adam@spiers.net>
 
 	* 10949: Completion/User/_perl_modules: print warning when
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index 5513a3629..7c1135959 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -47,25 +47,27 @@ fi
 _setup default
 _def_menu_style=( "$_last_menu_style[@]"
 
-# We can't really do that because the current value of $SELECTMIN
+# We can't really do that because the current value of $MENUSELECT
 # may be the one set by this function.
 # There is a similar problem with $ZLS_COLORS in _setup.
 
-#                  ${SELECTMIN+select${SELECTMIN:+\=$SELECTMIN}}
+#                  ${MENUSELECT+select${MENUSELECT:+\=$MENUSELECT}}
 
                 )
 _last_menu_style=()
 
-zstyle -s ":completion:${curcontext}:default" list-prompt LISTPROMPT ||
-    LISTPROMPT='%SAt %p: Hit TAB for more, or the character to insert%s'
-if [[ -n "$LISTPROMPT" ]]; then
+if zstyle -s ":completion:${curcontext}:default" list-prompt tmp; then
+  LISTPROMPT="$tmp"
+  zmodload -i zsh/complist
+fi
+if zstyle -s ":completion:${curcontext}:default" select-prompt tmp; then
+  MENUPROMPT="$tmp"
+  zmodload -i zsh/complist
+fi
+if zstyle -s ":completion:${curcontext}:default" select-scroll tmp; then
+  MENUSCROLL="$tmp"
   zmodload -i zsh/complist
-  compstate[list_max]=scroll
 fi
-zstyle -s ":completion:${curcontext}:default" select-prompt SELECTPROMPT ||
-    SELECTPROMPT='%SScrolling active: current selection at %p%s'
-zstyle -s ":completion:${curcontext}:default" select-scroll SELECTSCROLL ||
-    SELECTSCROLL=1
 
 # Get the names of the completers to use in the positional parameters.
 
@@ -148,7 +150,7 @@ if [[ $compstate[old_list] = keep || nm -gt 1 ]]; then
 
   if [[ "$compstate[insert]" = *menu* ]]; then
     if [[ -n "$_menu_style[(r)no-select*]" ]]; then
-      unset SELECTMIN
+      unset MENUSELECT
     else
       sel=( "${(@M)_menu_style:#select*}" )
 
@@ -168,7 +170,7 @@ if [[ $compstate[old_list] = keep || nm -gt 1 ]]; then
         done
 
         zmodload -i zsh/complist
-        SELECTMIN="$min"
+        MENUSELECT="$min"
       fi
     fi
   fi
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 8267819e3..acaad3cc4 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -1273,12 +1273,14 @@ they are listed normally.
 )
 kindex(list-prompt, completion style)
 item(tt(list-prompt))(
-If this style is set to a non-empty value for the tt(default) tag,
+If this style is set for the tt(default) tag,
 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 press. It may contain the escape `tt(%l)' or `tt(%L)' which will be
+). The value, if not the empty string, will be displayed after every
+screenful, prompting for a key press. If the value is the empty
+string, a default prompt will be used. 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
@@ -1588,11 +1590,13 @@ duplicates.
 )
 kindex(select-prompt, completion style)
 item(tt(select-prompt))(
-If this is set to a non-empty string for the tt(default) tag, its
+If this is set 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, but give the number of the match or line the mark is on.
+understood, but give the number of the match or line the mark is
+on. As for tt(list-prompt), a default prompt is used when the value is 
+the empty string.
 )
 kindex(select-scroll, completion style)
 item(tt(select-scroll))(
diff --git a/Doc/Zsh/mod_complist.yo b/Doc/Zsh/mod_complist.yo
index 4a6429e79..ac0fdc252 100644
--- a/Doc/Zsh/mod_complist.yo
+++ b/Doc/Zsh/mod_complist.yo
@@ -128,12 +128,25 @@ ifnzman(noderef(Completion System Configuration))\
 ).
 
 subsect(Scrolling in completion listings)
-vindex(LISTMAX)
-To be able to scroll through a completion list, the tt(LISTMAX)
-parameter has to be set to the string `tt(scroll)'. If it has this
-value, the completion code will not ask if the list should be
-shown. Instead it immediately starts displaying the list, stopping
-after the first screenful, showing a prompt at the bottom,
+To be able to scroll through a completion list, the tt(LISTPROMPT)
+parameter has to be set. Its value will be used as the prompt, if it
+is the empty string, a default prompt will be used.  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 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.
+
+If tt(LISTPROMPT) is set, the completion code will not ask if the list
+should be shown. Instead it immediately starts displaying the list,
+stopping after the first screenful, showing the prompt at the bottom,
 waiting for a keypress after temporarily switching to the
 tt(listscroll) keymap. Some of the zle functions have special meaning:
 
@@ -156,20 +169,6 @@ as usual. Any key that is not bound in the tt(listscroll) keymap or
 that is bound to tt(undefined-key) is looked up in the keymap
 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 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
 function based completion system. Instead, the tt(list-prompt) style
@@ -177,7 +176,7 @@ should be used.
 
 subsect(Menu selection)
 cindex(completion, selecting by cursor)
-vindex(SELECTMIN)
+vindex(MENUSELECT)
 tindex(menu-select)
 The tt(zsh/complist) module also offers an alternative style of selecting
 matches from a list, called menu-selection, which can be used if the
@@ -187,16 +186,16 @@ ifzman(zmanref(zshoptions))\
 ifnzman(noderef(Options))\
 ). It can be invoked directly by
 the widget tt(menu-select) defined by the module.  Alternatively,
-the parameter tt(SELECTMIN) can be set to an integer, which give the
+the parameter tt(MENUSELECT) can be set to an integer, which give the
 minimum number of matches that must be present before menu selection is
 automatically turned on.  This second method requires that menu completion
 be started, either directly from a widget such as tt(menu-complete), or due
 to one of the options tt(MENU_COMPLETE) or tt(AUTO_MENU) being set.  If
-tt(SELECTMIN) is set, but is 0, 1 or empty, menu selection will always be
+tt(MENUSELECT) is set, but is 0, 1 or empty, menu selection will always be
 started during an ambiguous menu completion.
 
 When using the shell function based completion system, the
-tt(SELECTMIN) parameter should not be used (like the tt(ZLS_COLORS)
+tt(MENUSELECT) parameter should not be used (like the tt(ZLS_COLORS)
 and tt(ZLS_COLOURS) parameters described above). Instead, the tt(menu) 
 style should be used.
 
@@ -212,12 +211,13 @@ neither tt(ZLS_COLORS) nor tt(ZLS_COLOURS) is set, the same terminal
 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. 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.
+tt(MENUPROMPT) is set, its value will be shown below the 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. If its value is the empty string, a default prompt will be
+used.
 
-The tt(SELECTSCROLL) parameter can be used to specify how the list is
+The tt(MENUSCROLL) parameter can be used to specify how the list is
 scrolled. If the parameter is unset, this is done line by line, if it
 is set to `tt(0)' (zero), the list will scrolled half the number of
 lines of the screen. If the value is positive, it gives the number of
@@ -225,7 +225,7 @@ lines to scroll and if it is negative, the list will be scrolled
 the number of lines of the screen minus the (absolute) value.
 
 As for the tt(ZLS_COLORS), tt(ZLS_COLOURS) and tt(LISTPROMPT)
-parameters, neither tt(SELECTPROMPT) nor tt(SELECTSCROLL) should be
+parameters, neither tt(MENUPROMPT) nor tt(MENUSCROLL) should be
 set directly when using the shell function based completion
 system. Instead, the tt(select-prompt) and tt(select-scroll) styles
 should be used.
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 0c989c427..0ecd7da79 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -296,8 +296,7 @@ do_completion(Hookdef dummy, Compldat dat)
     comppatinsert = ztrdup("menu");
     forcelist = 0;
     haspattern = 0;
-    zsfree(complistmax);
-    complistmax = ztrdup(getsparam("LISTMAX"));
+    complistmax = getiparam("LISTMAX");
     zsfree(complastprompt);
     complastprompt = ztrdup(((isset(ALWAYSLASTPROMPT) && zmult == 1) ||
 			     (unset(ALWAYSLASTPROMPT) && zmult != 1)) ?
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 2746f52d3..25a33b9cb 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -33,7 +33,9 @@
 /* global variables for shell parameters in new style completion */
 
 /**/
-mod_export zlong compcurrent;
+mod_export
+zlong compcurrent,
+      complistmax;
 /**/
 zlong complistlines,
       compignored;
@@ -49,8 +51,7 @@ char **compwords,
      *compquote,
      *compqstack,
      *comppatmatch,
-     *complastprompt,
-     *complistmax;
+     *complastprompt;
 /**/
 char *compiprefix,
      *compcontext,
@@ -924,7 +925,7 @@ static struct compparam compkparams[] = {
     { "unambiguous", PM_SCALAR | PM_READONLY, NULL, NULL, VAL(get_unambig) },
     { "unambiguous_cursor", PM_INTEGER | PM_READONLY, NULL, NULL,
       VAL(get_unambig_curs) },
-    { "list_max", PM_SCALAR, VAL(complistmax), NULL, NULL },
+    { "list_max", PM_INTEGER, VAL(complistmax), NULL, NULL },
     { "last_prompt", PM_SCALAR, VAL(complastprompt), NULL, NULL },
     { "to_end", PM_SCALAR, VAL(comptoend), NULL, NULL },
     { "old_list", PM_SCALAR, VAL(compoldlist), NULL, NULL },
@@ -1312,13 +1313,13 @@ setup_(Module m)
     comprpms = compkpms = NULL;
     compwords = NULL;
     compprefix = compsuffix = compiprefix = compisuffix = 
-	compqiprefix = compqisuffix = complistmax = 
+	compqiprefix = compqisuffix =
 	compcontext = compparameter = compredirect = compquote =
 	compquoting = comprestore = complist = compinsert =
 	compexact = compexactstr = comppatmatch = comppatinsert =
 	complastprompt = comptoend = compoldlist = compoldins =
 	compvared = compqstack = NULL;
-
+    complistmax = 0;
     hascompmod = 1;
 
     return 0;
@@ -1367,7 +1368,6 @@ finish_(Module m)
 {
     if (compwords)
 	freearray(compwords);
-    zsfree(complistmax);
     zsfree(compprefix);
     zsfree(compsuffix);
     zsfree(compiprefix);
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 045517a6d..55887b1de 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -384,7 +384,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, mfirstl, mlastm;
-static char *mstatus;
+static char *mstatus, *mlistp;
 static Cmatch **mtab, **mmtabp;
 static Cmgroup *mgtab, *mgtabp;
 static struct listcols mcolors;
@@ -730,8 +730,8 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
 	    if (!(fmt = mstatus))
 		return 0;
 	    cc = -1;
-	} else if (!(fmt = getsparam("LISTPROMPT")))
-	    fmt = "Continue? ";
+	} else
+	    fmt = mlistp;
     }
     for (p = fmt; *p; p++) {
 	if (doesc && *p == '%') {
@@ -1437,7 +1437,6 @@ static int
 complistmatches(Hookdef dummy, Chdata dat)
 {
     Cmgroup oamatches = amatches;
-    char *p = NULL;
 
     amatches = dat->matches;
 
@@ -1463,24 +1462,30 @@ complistmatches(Hookdef dummy, Chdata dat)
 	clearflag = 0;
 
     mscroll = 0;
+    mlistp = NULL;
 
     if (mselect >= 0 || mlbeg >= 0 ||
-	((p = complistmax) && !strcmp(p, "scroll"))) {
+	(mlistp = getsparam("LISTPROMPT"))) {
+	if (!*mlistp)
+	    mlistp = "%SAt %p: Hit TAB for more, or the character to insert%s";
 	trashzle();
 	showinglist = listshown = 0;
 
 	lastlistlen = 0;
 
-	if (p) {
+	if (mlistp) {
 	    clearflag = (isset(USEZLE) && !termflags && dolastprompt);
 	    mscroll = 1;
 	} else {
 	    clearflag = 1;
 	    minfo.asked = (listdat.nlines + nlnct <= lines);
 	}
-    } else if (asklist()) {
-	amatches = oamatches;
-	return (noselect = 1);
+    } else {
+	mlistp = NULL;
+	if (asklist()) {
+	    amatches = oamatches;
+	    return (noselect = 1);
+	}
     }
     if (mlbeg >= 0) {
 	mlend = mlbeg + lines - nlnct - mhasstat;
@@ -1569,7 +1574,7 @@ domenuselect(Hookdef dummy, Chdata dat)
     int space, lbeg = 0, step = 1;
     char *s;
 
-    if (fdat || (dummy && (!(s = getsparam("SELECTMIN")) ||
+    if (fdat || (dummy && (!(s = getsparam("MENUSELECT")) ||
 			   (dat && dat->num < atoi(s))))) {
 	if (fdat) {
 	    fdat->matches = dat->matches;
@@ -1577,14 +1582,15 @@ domenuselect(Hookdef dummy, Chdata dat)
 	}
 	return 0;
     }
-    if ((s = getsparam("SELECTSCROLL"))) {
+    if ((s = getsparam("MENUSCROLL"))) {
 	if (!(step = mathevali(s)))
 	    step = (lines - nlnct) >> 1;
 	else if (step < 0)
 	    if ((step += lines - nlnct) < 0)
 		step = 1;
     }
-    mstatus = getsparam("SELECTPROMPT");
+    if ((mstatus = getsparam("MENUPROMPT")) && !*mstatus)
+	mstatus = "%SScrolling active: current selection at %p%s";
     mhasstat = (mstatus && *mstatus);
     fdat = dat;
     selectlocalmap(mskeymap);
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index f40ee6724..c804fdcf2 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -1590,8 +1590,6 @@ calclist(int showall)
 mod_export int
 asklist(void)
 {
-    int lmax = (complistmax ? (int) mathevali(complistmax) : 0);
-
     /* Set the cursor below the prompt. */
     trashzle();
     showinglist = listshown = 0;
@@ -1601,9 +1599,9 @@ asklist(void)
 
     /* Maybe we have to ask if the user wants to see the list. */
     if ((!minfo.cur || !minfo.asked) &&
-	((lmax > 0 && listdat.nlist >= lmax) ||
-	 (lmax < 0 && listdat.nlines <= -lmax) ||
-	 (!lmax && listdat.nlines >= lines))) {
+	((complistmax > 0 && listdat.nlist >= complistmax) ||
+	 (complistmax < 0 && listdat.nlines <= -complistmax) ||
+	 (!complistmax && listdat.nlines >= lines))) {
 	int qup, l;
 
 	zsetterm();
diff --git a/Src/params.c b/Src/params.c
index 79bc5e9a9..74c4ee1c8 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -483,10 +483,10 @@ createparamtable(void)
     setiparam("MAILCHECK", 60);
     setiparam("LOGCHECK", 60);
     setiparam("KEYTIMEOUT", 40);
+    setiparam("LISTMAX", 100);
 #ifdef HAVE_SELECT
     setiparam("BAUD", getbaudrate(&shttyinfo));  /* get the output baudrate */
 #endif
-    setsparam("LISTMAX", ztrdup("100"));
     setsparam("FCEDIT", ztrdup(DEFAULT_FCEDIT));
     setsparam("TMPPREFIX", ztrdup(DEFAULT_TMPPREFIX));
     setsparam("TIMEFMT", ztrdup(DEFAULT_TIMEFMT));