From d3620a02dfad71562320a90315175855b44ed4de Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Thu, 11 May 2000 08:40:09 +0000 Subject: make ^G in menu-selection restore the old command line; add select=long* values for menu style to start menu-selection if list is too long for screen (11319) --- ChangeLog | 8 ++++++++ Completion/Core/_main_complete | 20 +++++++++++++++----- Doc/Zsh/compsys.yo | 7 +++++++ Doc/Zsh/mod_complist.yo | 3 ++- Src/Zle/compcore.c | 12 +++++++++++- Src/Zle/complist.c | 4 ++-- 6 files changed, 45 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 72e96753c..e01c4b999 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2000-05-11 Sven Wischnowsky + + * 11319: Completion/Core/_main_complete, Doc/Zsh/compsys.yo, + Doc/Zsh/mod_complist.yo, Src/Zle/compcore.c, Src/Zle/complist.c: + make ^G in menu-selection restore the old command line; add + select=long* values for menu style to start menu-selection if list + is too long for screen + 2000-05-11 Oliver Kiddle * 11315: Doc/Zsh/builtins.yo, Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo, diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete index 9882639fa..1b1fdd0e6 100644 --- a/Completion/Core/_main_complete +++ b/Completion/Core/_main_complete @@ -129,11 +129,20 @@ curcontext="${curcontext/:[^:]#:/::}" nm=$compstate[nmatches] if [[ $compstate[old_list] = keep || nm -gt 1 ]]; then - [[ _last_nmatches -ge 0 && _last_nmatches -ne $compstate[nmatches] ]] && + [[ _last_nmatches -ge 0 && _last_nmatches -ne nm ]] && _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" ) - if [[ "$compstate[insert]" = "$_saved_insert" ]]; then - if [[ -n "$_menu_style[(r)(yes|true|1|on)]" || + tmp=$(( compstate[list_lines] + BUFFERLINES + 1 )) + + _menu_style=( "$_menu_style[@]" "$_def_menu_style[@]" ) + + if [[ -z "$compstate[insert]" ]]; then + [[ -n "$_menu_style[(r)select=long-list]" && tmp -gt LINES ]] && + compstate[insert]=menu + elif [[ "$compstate[insert]" = "$_saved_insert" ]]; then + if [[ -n "$_menu_style[(r)select=long]" && tmp -gt LINES ]]; then + compstate[insert]=menu + elif [[ -n "$_menu_style[(r)(yes|true|1|on)]" || ( -n "$_menu_style[(r)auto*]" && "$compstate[insert]" = automenu ) ]]; then compstate[insert]=menu @@ -154,11 +163,12 @@ if [[ $compstate[old_list] = keep || nm -gt 1 ]]; then fi fi - _menu_style=( "$_menu_style[@]" "$_def_menu_style[@]" ) - if [[ "$compstate[insert]" = *menu* ]]; then if [[ -n "$_menu_style[(r)no-select*]" ]]; then unset MENUSELECT + elif [[ -n "$_menu_style[(r)select=long*]" && tmp -gt LINES ]]; then + zmodload -i zsh/complist + MENUSELECT=0 else sel=( "${(@M)_menu_style:#select*}" ) diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 395121f31..4c7e6dd6b 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -1498,6 +1498,13 @@ it will be started only if at least that many matches are generated smallest one is taken). Starting menuselection can explicitly be turned off by defining a value containing the string `tt(no-select)'. + +There is also support to start menu-selection only when the list of +matches does not fit on the screen, turned on by using the string +`tt(select=long)' in the value. However, this will only start +menu-selection if the widget invoked does completion and not only +listing (like tt(delete-char-or-list)). To start menu-selection even +for such widgets one can include the string `tt(select=long-list)'. ) kindex(numbers, completion style) item(tt(numbers))( diff --git a/Doc/Zsh/mod_complist.yo b/Doc/Zsh/mod_complist.yo index 5dd84310d..41e12196e 100644 --- a/Doc/Zsh/mod_complist.yo +++ b/Doc/Zsh/mod_complist.yo @@ -253,7 +253,8 @@ item(tt(accept-line))( accepts the current match and leaves menu selection ) item(tt(send-break))( -leaves menu selection and continues with normal menu completion +leaves menu selection and restores the previous contents of the +command line ) item(tt(redisplay), tt(clear-screen))( execute their normal function without leaving menu selection diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index 941023769..ee218e132 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -499,12 +499,22 @@ after_complete(Hookdef dummy, Compldat dat) { if (menucmp && !oldmenucmp) { struct chdata dat; + int ret; dat.matches = amatches; dat.num = nmatches; dat.cur = NULL; - if (runhookdef(MENUSTARTHOOK, (void *) &dat)) + if ((ret = runhookdef(MENUSTARTHOOK, (void *) &dat))) { menucmp = menuacc = 0; + if (ret == 2) { + cs = 0; + foredel(ll); + inststr(origline); + cs = origcs; + clearlist = 1; + invalidatelist(); + } + } } return 0; } diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 76fbaf58b..fdda07112 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -2135,7 +2135,7 @@ domenuselect(Hookdef dummy, Chdata dat) showinglist = -2; minfo.asked = 0; } - if (!noselect) { + if (!noselect && (!dat || acc)) { showinglist = -2; onlyexpl = oe; if (!smatches) @@ -2145,7 +2145,7 @@ domenuselect(Hookdef dummy, Chdata dat) mlbeg = -1; fdat = NULL; - return (!noselect ^ acc); + return (dat ? (acc ? 1 : 2) : (!noselect ^ acc)); } /* The widget function. */ -- cgit 1.4.1