From a4020e10a33f3f78681a2e18fb7add56338d4e81 Mon Sep 17 00:00:00 2001 From: Jun-ichi Takimoto Date: Wed, 3 Feb 2016 01:24:56 +0900 Subject: 37868: add 'static' to file local variables --- Src/Zle/complist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Src/Zle/complist.c') diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 0ccb88505..06a07a4e8 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -113,7 +113,7 @@ static Cmgroup *mgtab, *mgtabp; * Allow us to keep track of pointer arithmetic for mgtab; could * just as well have been for mtab but wasn't. */ -int mgtabsize; +static int mgtabsize; #endif /* -- cgit v1.2.3 From 1b923f69c7dac0e0a2c71c62bbcdb2d2de5128db Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Wed, 10 Feb 2016 10:56:55 -0800 Subject: 37927: recreate local keymaps as necessary in case the user has deleted them --- ChangeLog | 5 +++++ Src/Zle/complist.c | 55 +++++++++++++++++++++++++++++++++--------------------- 2 files changed, 39 insertions(+), 21 deletions(-) (limited to 'Src/Zle/complist.c') diff --git a/ChangeLog b/ChangeLog index 12be11c58..2e60d9eaf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,11 @@ * 37946: Src/utils.c: make rm * warnings more informative about files being deleted. +2016-02-10 Barton E. Schaefer + + * 37927: Src/Zle/complist.c: recreate local keymaps as necessary + in case the user has deleted them + 2016-02-09 Peter Stephenson * 37893: Doc/Zsh/builtins.yo: document behaviour of typeset -U diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 06a07a4e8..937e1d141 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -989,6 +989,7 @@ asklistscroll(int ml) fflush(shout); zsetterm(); + menuselect_bindings(); /* sanity in case deleted by user */ selectlocalmap(lskeymap); if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak)) ret = 1; @@ -2433,6 +2434,7 @@ domenuselect(Hookdef dummy, Chdata dat) unqueue_signals(); mhasstat = (mstatus && *mstatus); fdat = dat; + menuselect_bindings(); /* sanity in case deleted by user */ selectlocalmap(mskeymap); noselect = 1; while ((menuacc && @@ -3485,6 +3487,37 @@ enables_(Module m, int **enables) return handlefeatures(m, &module_features, enables); } +/**/ +static void +menuselect_bindings(void) +{ + if (!(mskeymap = openkeymap("menuselect"))) { + mskeymap = newkeymap(NULL, "menuselect"); + linkkeymap(mskeymap, "menuselect", 1); + bindkey(mskeymap, "\t", refthingy(t_completeword), NULL); + bindkey(mskeymap, "\n", refthingy(t_acceptline), NULL); + bindkey(mskeymap, "\r", refthingy(t_acceptline), NULL); + bindkey(mskeymap, "\33[A", refthingy(t_uplineorhistory), NULL); + bindkey(mskeymap, "\33[B", refthingy(t_downlineorhistory), NULL); + bindkey(mskeymap, "\33[C", refthingy(t_forwardchar), NULL); + bindkey(mskeymap, "\33[D", refthingy(t_backwardchar), NULL); + bindkey(mskeymap, "\33OA", refthingy(t_uplineorhistory), NULL); + bindkey(mskeymap, "\33OB", refthingy(t_downlineorhistory), NULL); + bindkey(mskeymap, "\33OC", refthingy(t_forwardchar), NULL); + bindkey(mskeymap, "\33OD", refthingy(t_backwardchar), NULL); + } + if (!(lskeymap = openkeymap("listscroll"))) { + lskeymap = newkeymap(NULL, "listscroll"); + linkkeymap(lskeymap, "listscroll", 1); + bindkey(lskeymap, "\t", refthingy(t_completeword), NULL); + bindkey(lskeymap, " ", refthingy(t_completeword), NULL); + bindkey(lskeymap, "\n", refthingy(t_acceptline), NULL); + bindkey(lskeymap, "\r", refthingy(t_acceptline), NULL); + bindkey(lskeymap, "\33[B", refthingy(t_downlineorhistory), NULL); + bindkey(lskeymap, "\33OB", refthingy(t_downlineorhistory), NULL); + } +} + /**/ int boot_(Module m) @@ -3503,27 +3536,7 @@ boot_(Module m) } addhookfunc("comp_list_matches", (Hookfn) complistmatches); addhookfunc("menu_start", (Hookfn) domenuselect); - mskeymap = newkeymap(NULL, "menuselect"); - linkkeymap(mskeymap, "menuselect", 1); - bindkey(mskeymap, "\t", refthingy(t_completeword), NULL); - bindkey(mskeymap, "\n", refthingy(t_acceptline), NULL); - bindkey(mskeymap, "\r", refthingy(t_acceptline), NULL); - bindkey(mskeymap, "\33[A", refthingy(t_uplineorhistory), NULL); - bindkey(mskeymap, "\33[B", refthingy(t_downlineorhistory), NULL); - bindkey(mskeymap, "\33[C", refthingy(t_forwardchar), NULL); - bindkey(mskeymap, "\33[D", refthingy(t_backwardchar), NULL); - bindkey(mskeymap, "\33OA", refthingy(t_uplineorhistory), NULL); - bindkey(mskeymap, "\33OB", refthingy(t_downlineorhistory), NULL); - bindkey(mskeymap, "\33OC", refthingy(t_forwardchar), NULL); - bindkey(mskeymap, "\33OD", refthingy(t_backwardchar), NULL); - lskeymap = newkeymap(NULL, "listscroll"); - linkkeymap(lskeymap, "listscroll", 1); - bindkey(lskeymap, "\t", refthingy(t_completeword), NULL); - bindkey(lskeymap, " ", refthingy(t_completeword), NULL); - bindkey(lskeymap, "\n", refthingy(t_acceptline), NULL); - bindkey(lskeymap, "\r", refthingy(t_acceptline), NULL); - bindkey(lskeymap, "\33[B", refthingy(t_downlineorhistory), NULL); - bindkey(lskeymap, "\33OB", refthingy(t_downlineorhistory), NULL); + menuselect_bindings(); return 0; } -- cgit v1.2.3 From f07a1bd00935b53e73dcbec4e039aef7cc1996b1 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Sun, 14 Feb 2016 11:13:17 -0800 Subject: 37961: fix crash on bad memory access In interactive menuselection, use of "compadd -x" (e.g. the "warnings" zstyle) may have replaced the completion list, so skip highlighting of the current selection until a subsequent keystroke has regenerated the original listing --- ChangeLog | 8 ++++++++ Src/Zle/complist.c | 30 ++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 8 deletions(-) (limited to 'Src/Zle/complist.c') diff --git a/ChangeLog b/ChangeLog index 2e60d9eaf..18e4eed59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2016-02-14 Barton E. Schaefer + + * 37961: Src/Zle/complist.c: in interactive menuselection, use of + "compadd -x" (e.g. the "warnings" zstyle) may have replaced the + completion list, so skip highlighting of the current selection + until a subsequent keystroke has regenerated the original listing; + fixes crash on bad memory access + 2016-02-11 Eric Cook * 37913: Completion/BSD/Command/_gstat, diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 937e1d141..162436b55 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -34,8 +34,9 @@ /* Information about the list shown. */ /* - * noselect: 1 if complistmatches indicated we shouldn't do selection. - * Tested in domenuselect. + * noselect: 1 if complistmatches indicated we shouldn't do selection; + * -1 if interactive mode needs to reset the selection list. + * Tested in domenuselect, and in complistmatches to skip redraw. * mselect: Local copy of the index of the currently selected match. * Initialised to the gnum entry of the current match for * each completion. @@ -1980,7 +1981,8 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) } #endif - noselect = 0; + if (noselect > 0) + noselect = 0; if ((minfo.asked == 2 && mselect < 0) || nlnct >= zterm_lines) { showinglist = 0; @@ -2078,9 +2080,11 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) last_cap = (char *) zhalloc(max_caplen + 1); *last_cap = '\0'; - if (!mnew && inselect && onlnct == nlnct && mlbeg >= 0 && mlbeg == molbeg) - singledraw(); - else if (!compprintlist(mselect >= 0) || !clearflag) + if (!mnew && inselect && + onlnct == nlnct && mlbeg >= 0 && mlbeg == molbeg) { + if (!noselect) + singledraw(); + } else if (!compprintlist(mselect >= 0) || !clearflag) noselect = 1; onlnct = nlnct; @@ -2093,7 +2097,7 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) popheap(); opts[EXTENDEDGLOB] = extendedglob; - return noselect; + return (noselect < 0 ? 0 : noselect); } static int @@ -2547,14 +2551,23 @@ domenuselect(Hookdef dummy, Chdata dat) } else { statusline = NULL; } + if (noselect < 0) { + showinglist = clearlist = 0; + clearflag = 1; + } zrefresh(); statusline = NULL; inselect = 1; + selected = 1; if (noselect) { + if (noselect < 0) { + /* no selection until after processing keystroke */ + noselect = 0; + goto getk; + } broken = 1; break; } - selected = 1; if (!i) { i = mcols * mlines; while (i--) @@ -2752,6 +2765,7 @@ domenuselect(Hookdef dummy, Chdata dat) if (nmessages) { showinglist = -2; zrefresh(); + noselect = -1; } else { trashzle(); zsetterm(); -- cgit v1.2.3 From 8c29b34032ebb714d2c593286aa29e5c64be55ab Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Mon, 7 Mar 2016 13:15:40 +0100 Subject: 38043: allow any completion widget to cycle matches for menu completion to fix reverse menu completion --- ChangeLog | 6 ++++++ Src/Zle/compcore.c | 8 +------- Src/Zle/complist.c | 2 +- Src/Zle/zle_tricky.c | 3 +-- 4 files changed, 9 insertions(+), 10 deletions(-) (limited to 'Src/Zle/complist.c') diff --git a/ChangeLog b/ChangeLog index 420eb261d..f3af39aab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-03-07 Oliver Kiddle + + * 38043: Src/Zle/compcore.c, Src/Zle/complist.c, + Src/Zle/zle_tricky.c: allow any completion widget to cycle matches + for menu completion to fix reverse menu completion + 2016-03-07 Peter Stephenson * 38111: Src/parse.c: remove redundant return values from diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index ae3a64074..ae7068fc9 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -30,10 +30,6 @@ #include "complete.mdh" #include "compcore.pro" -/* The last completion widget called. */ - -static Widget lastcompwidget; - /* Flags saying what we have to do with the result. */ /**/ @@ -471,8 +467,7 @@ before_complete(UNUSED(Hookdef dummy), int *lst) /* If we are doing a menu-completion... */ - if (minfo.cur && menucmp && *lst != COMP_LIST_EXPAND && - (menucmp != 1 || !compwidget || compwidget == lastcompwidget)) { + if (minfo.cur && menucmp && *lst != COMP_LIST_EXPAND) { do_menucmp(*lst); return 1; } @@ -481,7 +476,6 @@ before_complete(UNUSED(Hookdef dummy), int *lst) onlyexpl = listdat.valid = 0; return 1; } - lastcompwidget = compwidget; /* We may have to reset the cursor to its position after the * * string inserted by the last completion. */ diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 162436b55..8aeb6c3b8 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -3399,7 +3399,7 @@ domenuselect(Hookdef dummy, Chdata dat) do_single(*(minfo.cur)); } if (wasnext || broken) { - menucmp = 2; + menucmp = 1; showinglist = ((validlist && !nolist) ? -2 : 0); minfo.asked = 0; if (!noselect) { diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index cc4b7d673..a89b2a376 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -100,8 +100,7 @@ mod_export int usemenu, useglob; /**/ mod_export int wouldinstab; -/* != 0 if we are in the middle of a menu completion. May be == 2 to force * - * menu completion even if using different widgets. */ +/* != 0 if we are in the middle of a menu completion. */ /**/ mod_export int menucmp; -- cgit v1.2.3 From 6f071b2309283bfe0798bd317f79622cc22270e0 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 23 Oct 2016 21:32:58 +0100 Subject: 39715: Handle multibyte characters in complist listing --- ChangeLog | 5 +++++ Src/Zle/complist.c | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'Src/Zle/complist.c') diff --git a/ChangeLog b/ChangeLog index cb35290b4..f63ffa6fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-10-23 Peter Stephenson + + * 39715: Src/Zle/complist.c: handle multibyte characters when + highlighting completion listing. + 2016-10-22 Barton E. Schaefer * 39710 (cf. Alex George: 39709): Completion/Base/Completer/_expand, diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 8aeb6c3b8..39ac782eb 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -662,7 +662,9 @@ clprintfmt(char *p, int ml) initiscol(); - for (; *p; p++) { + while (*p) { + convchar_t chr; + int chrlen = MB_METACHARLENCONV(p, &chr); doiscol(i++); cc++; if (*p == '\n') { @@ -673,11 +675,16 @@ clprintfmt(char *p, int ml) if (ml == mlend - 1 && (cc % zterm_columns) == zterm_columns - 1) return 0; - if (*p == Meta) { + while (chrlen) { + if (*p == Meta) { + p++; + chrlen--; + putc(*p ^ 32, shout); + } else + putc(*p, shout); + chrlen--; p++; - putc(*p ^ 32, shout); - } else - putc(*p, shout); + } if ((beg = !(cc % zterm_columns))) ml++; if (mscroll && !(cc % zterm_columns) && -- cgit v1.2.3 From 39ae9cd10a5987ac71dee8bef7bd3bc2ba5e4eb8 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 25 Oct 2016 11:53:49 +0100 Subject: 39723: metafy string passed to pattern in complist. Also additional safety tokenizing a string with Meta characters. --- ChangeLog | 6 ++++++ Src/Zle/complist.c | 1 + Src/glob.c | 4 ++++ 3 files changed, 11 insertions(+) (limited to 'Src/Zle/complist.c') diff --git a/ChangeLog b/ChangeLog index ee1fd94dc..775ad22e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-10-25 Peter Stephenson + + * 39723: Src/Zle/complist.c, Src/glob.c: metafy string to be + used in pattern for complist. Also skip metafied characters + when tokenizing (typically this has no effect, however). + 2016-10-24 Barton E. Schaefer * unposted: NEWS, README: update for 39704. diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 39ac782eb..d4672a194 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -415,6 +415,7 @@ getcoldef(char *s) break; *s++ = '\0'; } + p = metafy(p, strlen(p), META_USEHEAP); tokenize(p); if ((prog = patcompile(p, 0, NULL))) { Patcol pc, po; diff --git a/Src/glob.c b/Src/glob.c index a845c5fbb..50f6dceb3 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -3499,6 +3499,10 @@ zshtokenize(char *s, int flags) for (; *s; s++) { cont: switch (*s) { + case Meta: + /* skip both Meta and following character */ + s++; + break; case Bnull: case Bnullkeep: case '\\': -- cgit v1.2.3 From 364c4047e710b779167d697b956e224944cb0c84 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Tue, 25 Oct 2016 12:45:51 -0700 Subject: 39725: more metafication of patterns. --- ChangeLog | 4 ++++ Src/Zle/complist.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'Src/Zle/complist.c') diff --git a/ChangeLog b/ChangeLog index 775ad22e6..4bdb8ff80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016-10-25 Barton E. Schaefer + + * 39725: Src/Zle/complist.c: more metafication of patterns. + 2016-10-25 Peter Stephenson * 39723: Src/Zle/complist.c, Src/glob.c: metafy string to be diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index d4672a194..2edaf6eca 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -347,9 +347,10 @@ getcoldef(char *s) char sav = p[1]; p[1] = '\0'; + s = metafy(s, -1, META_USEHEAP); tokenize(s); gprog = patcompile(s, 0, NULL); - p[1] =sav; + p[1] = sav; s = p + 1; } @@ -415,7 +416,7 @@ getcoldef(char *s) break; *s++ = '\0'; } - p = metafy(p, strlen(p), META_USEHEAP); + p = metafy(p, -1, META_USEHEAP); tokenize(p); if ((prog = patcompile(p, 0, NULL))) { Patcol pc, po; -- cgit v1.2.3