mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-11 13:01:28 +02:00
35627: make reverse-menu-complete start with the last match in
menu selection
This commit is contained in:
parent
fbc97e72e8
commit
44c56f3af5
7 changed files with 40 additions and 68 deletions
|
@ -1,5 +1,9 @@
|
||||||
2015-06-29 Oliver Kiddle <opk@zsh.org>
|
2015-06-29 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
|
* 35627: Src/Zle/compcore.c, Src/Zle/compctl.c, Src/Zle/complete.c,
|
||||||
|
Src/Zle/complist.c, Src/Zle/compresult.c, Src/Zle/zle_tricky.c:
|
||||||
|
make reverse-menu-complete start with last match in menu selection
|
||||||
|
|
||||||
* 35623: Src/Zle/complist.c: fix menu-selection where initial
|
* 35623: Src/Zle/complist.c: fix menu-selection where initial
|
||||||
selection would not be displayed without scrolling
|
selection would not be displayed without scrolling
|
||||||
|
|
||||||
|
|
|
@ -327,9 +327,7 @@ do_completion(UNUSED(Hookdef dummy), Compldat dat)
|
||||||
haspattern = 0;
|
haspattern = 0;
|
||||||
complistmax = getiparam("LISTMAX");
|
complistmax = getiparam("LISTMAX");
|
||||||
zsfree(complastprompt);
|
zsfree(complastprompt);
|
||||||
complastprompt = ztrdup(((isset(ALWAYSLASTPROMPT) && zmult == 1) ||
|
complastprompt = ztrdup(isset(ALWAYSLASTPROMPT) ? "yes" : "");
|
||||||
(unset(ALWAYSLASTPROMPT) && zmult != 1)) ?
|
|
||||||
"yes" : "");
|
|
||||||
dolastprompt = 1;
|
dolastprompt = 1;
|
||||||
zsfree(complist);
|
zsfree(complist);
|
||||||
complist = ztrdup(isset(LISTROWSFIRST) ?
|
complist = ztrdup(isset(LISTROWSFIRST) ?
|
||||||
|
@ -975,7 +973,7 @@ makecomplist(char *s, int incmd, int lst)
|
||||||
mnum = 0;
|
mnum = 0;
|
||||||
unambig_mnum = -1;
|
unambig_mnum = -1;
|
||||||
isuf = NULL;
|
isuf = NULL;
|
||||||
insmnum = 1;
|
insmnum = zmult;
|
||||||
#if 0
|
#if 0
|
||||||
/* group-numbers in compstate[insert] */
|
/* group-numbers in compstate[insert] */
|
||||||
insgnum = 1;
|
insgnum = 1;
|
||||||
|
|
|
@ -1803,7 +1803,7 @@ ccmakehookfn(UNUSED(Hookdef dummy), struct ccmakedat *dat)
|
||||||
mnum = 0;
|
mnum = 0;
|
||||||
unambig_mnum = -1;
|
unambig_mnum = -1;
|
||||||
isuf = NULL;
|
isuf = NULL;
|
||||||
insmnum = 1;
|
insmnum = zmult;
|
||||||
#if 0
|
#if 0
|
||||||
/* group-numbers in compstate[insert] */
|
/* group-numbers in compstate[insert] */
|
||||||
insgnum = 1;
|
insgnum = 1;
|
||||||
|
|
|
@ -1625,7 +1625,6 @@ boot_(Module m)
|
||||||
addhookfunc("before_complete", (Hookfn) before_complete);
|
addhookfunc("before_complete", (Hookfn) before_complete);
|
||||||
addhookfunc("after_complete", (Hookfn) after_complete);
|
addhookfunc("after_complete", (Hookfn) after_complete);
|
||||||
addhookfunc("accept_completion", (Hookfn) accept_last);
|
addhookfunc("accept_completion", (Hookfn) accept_last);
|
||||||
addhookfunc("reverse_menu", (Hookfn) reverse_menu);
|
|
||||||
addhookfunc("list_matches", (Hookfn) list_matches);
|
addhookfunc("list_matches", (Hookfn) list_matches);
|
||||||
addhookfunc("invalidate_list", (Hookfn) invalidate_list);
|
addhookfunc("invalidate_list", (Hookfn) invalidate_list);
|
||||||
(void)addhookdefs(m, comphooks, sizeof(comphooks)/sizeof(*comphooks));
|
(void)addhookdefs(m, comphooks, sizeof(comphooks)/sizeof(*comphooks));
|
||||||
|
@ -1640,7 +1639,6 @@ cleanup_(Module m)
|
||||||
deletehookfunc("before_complete", (Hookfn) before_complete);
|
deletehookfunc("before_complete", (Hookfn) before_complete);
|
||||||
deletehookfunc("after_complete", (Hookfn) after_complete);
|
deletehookfunc("after_complete", (Hookfn) after_complete);
|
||||||
deletehookfunc("accept_completion", (Hookfn) accept_last);
|
deletehookfunc("accept_completion", (Hookfn) accept_last);
|
||||||
deletehookfunc("reverse_menu", (Hookfn) reverse_menu);
|
|
||||||
deletehookfunc("list_matches", (Hookfn) list_matches);
|
deletehookfunc("list_matches", (Hookfn) list_matches);
|
||||||
deletehookfunc("invalidate_list", (Hookfn) invalidate_list);
|
deletehookfunc("invalidate_list", (Hookfn) invalidate_list);
|
||||||
(void)deletehookdefs(m, comphooks,
|
(void)deletehookdefs(m, comphooks,
|
||||||
|
|
|
@ -2581,6 +2581,7 @@ domenuselect(Hookdef dummy, Chdata dat)
|
||||||
getk:
|
getk:
|
||||||
|
|
||||||
if (!do_last_key) {
|
if (!do_last_key) {
|
||||||
|
zmult = 1;
|
||||||
cmd = getkeycmd();
|
cmd = getkeycmd();
|
||||||
if (mtab_been_reallocated) {
|
if (mtab_been_reallocated) {
|
||||||
do_last_key = 1;
|
do_last_key = 1;
|
||||||
|
|
|
@ -1220,25 +1220,39 @@ do_menucmp(int lst)
|
||||||
was_meta = 1;
|
was_meta = 1;
|
||||||
|
|
||||||
/* Otherwise go to the next match in the array... */
|
/* Otherwise go to the next match in the array... */
|
||||||
do {
|
while (zmult) {
|
||||||
if (!*++(minfo.cur)) {
|
do {
|
||||||
do {
|
if (zmult > 0) {
|
||||||
if (!(minfo.group = (minfo.group)->next)) {
|
if (!*++(minfo.cur)) {
|
||||||
minfo.group = amatches;
|
do {
|
||||||
|
if (!(minfo.group = (minfo.group)->next)) {
|
||||||
|
minfo.group = amatches;
|
||||||
#ifdef ZSH_HEAP_DEBUG
|
#ifdef ZSH_HEAP_DEBUG
|
||||||
if (memory_validate(minfo.group->heap_id)) {
|
if (memory_validate(minfo.group->heap_id)) {
|
||||||
HEAP_ERROR(minfo.group->heap_id);
|
HEAP_ERROR(minfo.group->heap_id);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
} while (!(minfo.group)->mcount);
|
||||||
|
minfo.cur = minfo.group->matches;
|
||||||
}
|
}
|
||||||
} while (!(minfo.group)->mcount);
|
} else {
|
||||||
minfo.cur = minfo.group->matches;
|
if (minfo.cur == (minfo.group)->matches) {
|
||||||
}
|
do {
|
||||||
} while ((menuacc &&
|
if (!(minfo.group = (minfo.group)->prev))
|
||||||
!hasbrpsfx(*(minfo.cur), minfo.prebr, minfo.postbr)) ||
|
minfo.group = lmatches;
|
||||||
((*minfo.cur)->flags & CMF_DUMMY) ||
|
} while (!(minfo.group)->mcount);
|
||||||
(((*minfo.cur)->flags & (CMF_NOLIST | CMF_MULT)) &&
|
minfo.cur = (minfo.group)->matches + (minfo.group)->mcount - 1;
|
||||||
(!(*minfo.cur)->str || !*(*minfo.cur)->str)));
|
} else
|
||||||
|
minfo.cur--;
|
||||||
|
}
|
||||||
|
} while ((menuacc &&
|
||||||
|
!hasbrpsfx(*(minfo.cur), minfo.prebr, minfo.postbr)) ||
|
||||||
|
((*minfo.cur)->flags & CMF_DUMMY) ||
|
||||||
|
(((*minfo.cur)->flags & (CMF_NOLIST | CMF_MULT)) &&
|
||||||
|
(!(*minfo.cur)->str || !*(*minfo.cur)->str)));
|
||||||
|
zmult -= (0 < zmult) - (zmult < 0);
|
||||||
|
}
|
||||||
/* ... and insert it into the command line. */
|
/* ... and insert it into the command line. */
|
||||||
do_single(*minfo.cur);
|
do_single(*minfo.cur);
|
||||||
|
|
||||||
|
@ -1246,43 +1260,6 @@ do_menucmp(int lst)
|
||||||
unmetafy_line();
|
unmetafy_line();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
|
||||||
int
|
|
||||||
reverse_menu(UNUSED(Hookdef dummy), UNUSED(void *dummy2))
|
|
||||||
{
|
|
||||||
int was_meta;
|
|
||||||
|
|
||||||
if (minfo.cur == NULL)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (minfo.cur == (minfo.group)->matches) {
|
|
||||||
do {
|
|
||||||
if (!(minfo.group = (minfo.group)->prev))
|
|
||||||
minfo.group = lmatches;
|
|
||||||
} while (!(minfo.group)->mcount);
|
|
||||||
minfo.cur = (minfo.group)->matches + (minfo.group)->mcount - 1;
|
|
||||||
} else
|
|
||||||
minfo.cur--;
|
|
||||||
} while ((menuacc &&
|
|
||||||
!hasbrpsfx(*(minfo.cur), minfo.prebr, minfo.postbr)) ||
|
|
||||||
((*minfo.cur)->flags & CMF_DUMMY) ||
|
|
||||||
(((*minfo.cur)->flags & (CMF_NOLIST | CMF_MULT)) &&
|
|
||||||
(!(*minfo.cur)->str || !*(*minfo.cur)->str)));
|
|
||||||
/* May already be metafied if called from within a selection */
|
|
||||||
if (zlemetaline == NULL) {
|
|
||||||
metafy_line();
|
|
||||||
was_meta = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
was_meta = 1;
|
|
||||||
do_single(*(minfo.cur));
|
|
||||||
if (!was_meta)
|
|
||||||
unmetafy_line();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Accepts the current completion and starts a new arg, *
|
/* Accepts the current completion and starts a new arg, *
|
||||||
* with the next completions. This gives you a way to *
|
* with the next completions. This gives you a way to *
|
||||||
* accept several selections from the list of matches. */
|
* accept several selections from the list of matches. */
|
||||||
|
|
|
@ -345,14 +345,8 @@ mod_export int
|
||||||
reversemenucomplete(char **args)
|
reversemenucomplete(char **args)
|
||||||
{
|
{
|
||||||
wouldinstab = 0;
|
wouldinstab = 0;
|
||||||
if (!menucmp) {
|
zmult = -zmult;
|
||||||
menucomplete(args);
|
menucomplete(args);
|
||||||
/*
|
|
||||||
* Drop through, since we are now on the first item instead of
|
|
||||||
* the last. We've already updated the display, so this is a
|
|
||||||
* bit inefficient, but it's simple and it works.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
runhookdef(REVERSEMENUHOOK, NULL);
|
runhookdef(REVERSEMENUHOOK, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue