mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-11 20:31:11 +01:00
default for list-prompt style, %[MLP] use fixed-width strings, %[mlp] use variable-width strings (10816)
This commit is contained in:
parent
44ee911749
commit
6a7c002a7c
5 changed files with 85 additions and 32 deletions
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,13 +791,27 @@ 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);
|
||||
|
@ -805,10 +819,10 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
|
|||
}
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue