diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-07-12 17:02:40 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-07-12 17:02:40 +0000 |
commit | 1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1 (patch) | |
tree | 608d6471d477e8d4d9eafa62f521be50c3248f6e /Src/Zle | |
parent | 7c670f1e6a0e154f0b1a2d4b6eed0e71c9404b56 (diff) | |
download | zsh-1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1.tar.gz zsh-1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1.tar.xz zsh-1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1.zip |
zsh-3.1.6-test-1 zsh-3.1.6-test-1
Diffstat (limited to 'Src/Zle')
-rw-r--r-- | Src/Zle/compctl.c | 4 | ||||
-rw-r--r-- | Src/Zle/complist.c | 106 | ||||
-rw-r--r-- | Src/Zle/zle.export | 10 | ||||
-rw-r--r-- | Src/Zle/zle_bindings.c | 8 | ||||
-rw-r--r-- | Src/Zle/zle_main.c | 8 | ||||
-rw-r--r-- | Src/Zle/zle_misc.c | 2 | ||||
-rw-r--r-- | Src/Zle/zle_params.c | 8 | ||||
-rw-r--r-- | Src/Zle/zle_refresh.c | 4 | ||||
-rw-r--r-- | Src/Zle/zle_thingy.c | 44 | ||||
-rw-r--r-- | Src/Zle/zle_tricky.c | 57 |
10 files changed, 207 insertions, 44 deletions
diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c index 2b426492e..694af8429 100644 --- a/Src/Zle/compctl.c +++ b/Src/Zle/compctl.c @@ -2096,9 +2096,7 @@ bin_compset(char *name, char **argv, char *ops, int func) case 'P': test = CVT_PREPAT; break; case 's': test = CVT_SUFNUM; break; case 'S': test = CVT_SUFPAT; break; - case 'q': return !(compquote && *compquote && - (*compquote == '\'' || *compquote == '"') && - !set_comp_sepptr()); + case 'q': return set_comp_sepptr(); default: zerrnam(name, "bad option -%c", NULL, argv[0][1]); return 1; diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index aac8b410d..0e7152866 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -309,7 +309,7 @@ complistmatches(Hookdef dummy, Chdata dat) Cexpl *e; int nlines = 0, ncols, nlist = 0, longest = 1, pnl = 0, opl = 0; int of = isset(LISTTYPES); - int mc, ml = 0, cc, hasm = 0; + int mc, ml = 0, cc, hasm = 0, cl; struct listcols col; if (minfo.asked == 2) { @@ -448,7 +448,12 @@ complistmatches(Hookdef dummy, Chdata dat) mgtab = (Cmgroup *) zalloc(i * sizeof(Cmgroup)); memset(mgtab, 0, i * sizeof(Cmgroup)); mcols = ncols; - mlines = nlines; + mlines = cl = nlines; + if (cl < 2) { + cl = -1; + if (tccan(TCCLEAREOD)) + tcout(TCCLEAREOD); + } } /* Now print the matches. */ g = amatches; @@ -456,14 +461,27 @@ complistmatches(Hookdef dummy, Chdata dat) char **pp = g->ylist; if ((e = g->expls)) { + int l; + while (*e) { if ((*e)->count) { if (pnl) { putc('\n', shout); pnl = 0; ml++; + if (cl >= 0 && --cl <= 1) { + cl = -1; + if (tccan(TCCLEAREOD)) + tcout(TCCLEAREOD); + } + } + l = printfmt((*e)->str, (*e)->count, 1); + ml += l; + if (cl >= 0 && (cl -= l) <= 1) { + cl = -1; + if (tccan(TCCLEAREOD)) + tcout(TCCLEAREOD); } - ml += printfmt((*e)->str, (*e)->count, 1); pnl = 1; } e++; @@ -474,6 +492,11 @@ complistmatches(Hookdef dummy, Chdata dat) putc('\n', shout); pnl = 0; ml++; + if (cl >= 0 && --cl <= 1) { + cl = -1; + if (tccan(TCCLEAREOD)) + tcout(TCCLEAREOD); + } } if (g->flags & CGF_LINES) { while (*pp) { @@ -504,6 +527,11 @@ complistmatches(Hookdef dummy, Chdata dat) if (n) { putc('\n', shout); ml++; + if (cl >= 0 && --cl <= 1) { + cl = -1; + if (tccan(TCCLEAREOD)) + tcout(TCCLEAREOD); + } } pp++; } @@ -517,6 +545,11 @@ complistmatches(Hookdef dummy, Chdata dat) putc('\n', shout); pnl = 0; ml++; + if (cl >= 0 && --cl <= 1) { + cl = -1; + if (tccan(TCCLEAREOD)) + tcout(TCCLEAREOD); + } } for (p = skipnolist(g->matches); n && nl--;) { i = ncols; @@ -607,6 +640,11 @@ complistmatches(Hookdef dummy, Chdata dat) if (n) { putc('\n', shout); ml++; + if (cl >= 0 && --cl <= 1) { + cl = -1; + if (tccan(TCCLEAREOD)) + tcout(TCCLEAREOD); + } if (n && nl) p = skipnolist(p + 1); } @@ -640,11 +678,13 @@ struct menustack { char *line; int cs; struct menuinfo info; + Cmgroup amatches, pmatches, lmatches; }; static int domenuselect(Hookdef dummy, Chdata dat) { + static Chdata fdat = NULL; Cmatch **p; Cmgroup *pg; Thingy cmd; @@ -652,10 +692,15 @@ domenuselect(Hookdef dummy, Chdata dat) int i = 0, acc = 0; char *s; - if (dummy && (!(s = getsparam("SELECTMIN")) || - (dat && dat->num < atoi(s)))) + if (fdat || (dummy && (!(s = getsparam("SELECTMIN")) || + (dat && dat->num < atoi(s))))) { + if (fdat) { + fdat->matches = dat->matches; + fdat->num = dat->num; + } return 0; - + } + fdat = dat; selectlocalmap(mskeymap); noselect = 0; mselect = (*(minfo.cur))->gnum; @@ -686,6 +731,32 @@ domenuselect(Hookdef dummy, Chdata dat) else if (cmd == Th(z_acceptline)) { acc = 1; break; + } else if (cmd == Th(z_acceptandinfernexthistory)) { + Menustack s = (Menustack) zhalloc(sizeof(*s)); + + s->prev = u; + u = s; + s->line = dupstring((char *) line); + s->cs = cs; + memcpy(&(s->info), &minfo, sizeof(struct menuinfo)); + s->amatches = amatches; + s->pmatches = pmatches; + s->lmatches = lmatches; + menucmp = 0; + fixsuffix(); + validlist = 0; + pmatches = NULL; + invalidatelist(); + menucomplete(zlenoargs); + if (dat->num < 2 || !minfo.cur || !*(minfo.cur)) { + noselect = 1; + clearlist = 1; + zrefresh(); + break; + } + clearlist = 1; + mselect = (*(minfo.cur))->gnum; + continue; } else if (cmd == Th(z_acceptandhold) || cmd == Th(z_acceptandmenucomplete)) { Menustack s = (Menustack) zhalloc(sizeof(*s)); @@ -695,6 +766,7 @@ domenuselect(Hookdef dummy, Chdata dat) s->line = dupstring((char *) line); s->cs = cs; memcpy(&(s->info), &minfo, sizeof(struct menuinfo)); + s->amatches = s->pmatches = s->lmatches = NULL; acceptlast(); do_menucmp(0); mselect = (*(minfo.cur))->gnum; @@ -712,7 +784,15 @@ domenuselect(Hookdef dummy, Chdata dat) cs = u->cs; memcpy(&minfo, &(u->info), sizeof(struct menuinfo)); p = &(minfo.cur); + if (u->pmatches && pmatches != u->pmatches) { + freematches(); + amatches = u->amatches; + pmatches = u->pmatches; + lmatches = u->lmatches; + hasperm = 1; + } u = u->prev; + clearlist = 1; } else if (cmd == Th(z_redisplay)) { redisplay(zlenoargs); continue; @@ -846,6 +926,19 @@ domenuselect(Hookdef dummy, Chdata dat) do_single(**p); mselect = (**p)->gnum; } + if (u) { + int hp = hasperm; + Cmgroup m = pmatches; + + for (; u; u = u->prev) { + if (u->pmatches != m) { + pmatches = u->pmatches; + freematches(); + } + } + pmatches = m; + hasperm = hp; + } selectlocalmap(NULL); mselect = -1; inselect = 0; @@ -858,6 +951,7 @@ domenuselect(Hookdef dummy, Chdata dat) showinglist = -2; zrefresh(); } + fdat = NULL; return (!noselect ^ acc); } diff --git a/Src/Zle/zle.export b/Src/Zle/zle.export index e6f469ad0..8bc049e16 100644 --- a/Src/Zle/zle.export +++ b/Src/Zle/zle.export @@ -1,23 +1,29 @@ #! acceptlast addzlefunction +amatches backdel backkill bindkey clearflag +clearlist clearscreen deletezlefunction do_menucmp do_single -feep +fixsuffix foredel forekill +freematches getkey getkeycmd getzlequery +hasperm +invalidatelist lastambig linkkeymap listshown +lmatches menucmp menucomplete menucur @@ -25,6 +31,7 @@ menugrp minfo newkeymap nlnct +pmatches printfmt redisplay refthingy @@ -39,6 +46,7 @@ thingies trashzle ungetkeycmd unlinkkeymap +validlist zlenoargs zmod zrefresh diff --git a/Src/Zle/zle_bindings.c b/Src/Zle/zle_bindings.c index 40e555ad1..940d578d9 100644 --- a/Src/Zle/zle_bindings.c +++ b/Src/Zle/zle_bindings.c @@ -200,9 +200,9 @@ int metabind[128] = { /* M-K */ z_undefinedkey, /* M-L */ z_downcaseword, /* M-M */ z_undefinedkey, - /* M-N */ z_historybeginningsearchforward, + /* M-N */ z_historysearchforward, /* M-O */ z_undefinedkey, - /* M-P */ z_historybeginningsearchbackward, + /* M-P */ z_historysearchbackward, /* M-Q */ z_pushline, /* M-R */ z_undefinedkey, /* M-S */ z_spellword, @@ -232,9 +232,9 @@ int metabind[128] = { /* M-k */ z_undefinedkey, /* M-l */ z_downcaseword, /* M-m */ z_undefinedkey, - /* M-n */ z_historybeginningsearchforward, + /* M-n */ z_historysearchforward, /* M-o */ z_undefinedkey, - /* M-p */ z_historybeginningsearchbackward, + /* M-p */ z_historysearchbackward, /* M-q */ z_pushline, /* M-r */ z_undefinedkey, /* M-s */ z_spellword, diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 8f6dfdf75..beef708fb 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -307,7 +307,7 @@ getkey(int keytmout) unsigned int ret; long exp100ths; int die = 0, r, icnt = 0; - int old_errno = errno; + int old_errno = errno, obreaks = breaks; #ifdef HAVE_SELECT fd_set foofd; @@ -397,6 +397,7 @@ getkey(int keytmout) if (!errflag && !retflag && !breaks) continue; errflag = 0; + breaks = obreaks; errno = old_errno; return EOF; } else if (errno == EWOULDBLOCK) { @@ -717,7 +718,7 @@ bin_vared(char *name, char **args, char *ops, int func) Value v; Param pm = 0; int create = 0; - int type = PM_SCALAR; + int type = PM_SCALAR, obreaks = breaks; char *p1 = NULL, *p2 = NULL; if (zleactive) { @@ -809,6 +810,7 @@ bin_vared(char *name, char **args, char *ops, int func) if (!t || errflag) { /* error in editing */ errflag = 0; + breaks = obreaks; return 1; } /* strip off trailing newline, if any */ @@ -948,7 +950,7 @@ trashzle(void) static struct builtin bintab[] = { BUILTIN("bindkey", 0, bin_bindkey, 0, -1, 0, "evaMldDANmrsLR", NULL), BUILTIN("vared", 0, bin_vared, 1, 7, 0, NULL, NULL), - BUILTIN("zle", 0, bin_zle, 0, -1, 0, "lDANCLmMgGcRa", NULL), + BUILTIN("zle", 0, bin_zle, 0, -1, 0, "lDANCLmMgGcRaU", NULL), }; /* The order of the entries in this table has to match the *HOOK diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c index a51cdf92e..fedb9d5cf 100644 --- a/Src/Zle/zle_misc.c +++ b/Src/Zle/zle_misc.c @@ -736,6 +736,7 @@ executenamedcommand(char *prmt) statusll = l + len + 1; zmult = 1; listlist(cmdll); + showinglist = 0; zmult = zmultsav; } else if (!nextnode(firstnode(cmdll))) { strcpy(ptr = cmdbuf, peekfirst(cmdll)); @@ -754,6 +755,7 @@ executenamedcommand(char *prmt) statusll = l + cmdambig + 1; zmult = 1; listlist(cmdll); + showinglist = 0; zmult = zmultsav; } len = cmdambig; diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c index bac399e7d..dc4e27685 100644 --- a/Src/Zle/zle_params.c +++ b/Src/Zle/zle_params.c @@ -137,6 +137,8 @@ set_buffer(Param pm, char *x) cs = ll; } else cs = ll = 0; + fixsuffix(); + menucmp = 0; } /**/ @@ -156,6 +158,8 @@ set_cursor(Param pm, zlong x) cs = ll; else cs = x; + fixsuffix(); + menucmp = 0; } /**/ @@ -182,6 +186,8 @@ set_lbuffer(Param pm, char *x) ll = ll - cs + len; cs = len; zsfree(x); + fixsuffix(); + menucmp = 0; } /**/ @@ -205,6 +211,8 @@ set_rbuffer(Param pm, char *x) sizeline(ll = cs + len); memcpy(line + cs, y, len); zsfree(x); + fixsuffix(); + menucmp = 0; } /**/ diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index dd4310078..48e1071b8 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -281,7 +281,9 @@ zrefresh(void) clearflag = 0; resetneeded = 1; } - listshown = showinglist = 0; + listshown = 0; + if (showinglist != -2) + showinglist = 0; } clearlist = 0; diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c index cf01f2fc1..f753b4769 100644 --- a/Src/Zle/zle_thingy.c +++ b/Src/Zle/zle_thingy.c @@ -340,7 +340,8 @@ bin_zle(char *name, char **args, char *ops, int func) { 'A', bin_zle_link, 2, 2 }, { 'N', bin_zle_new, 1, 2 }, { 'C', bin_zle_complete, 3, 3 }, - { 'R', bin_zle_refresh, 0, 1 }, + { 'R', bin_zle_refresh, 0, -1 }, + { 'U', bin_zle_unget, 1, 1 }, { 0, bin_zle_call, 0, -1 }, }; struct opn const *op, *opp; @@ -396,23 +397,50 @@ static int bin_zle_refresh(char *name, char **args, char *ops, char func) { char *s = statusline; - int sl = statusll; + int sl = statusll, ocl = clearlist; + statusline = NULL; + statusll = 0; if (*args) { - statusline = *args; - statusll = strlen(statusline); - } else { - statusline = NULL; - statusll = 0; - } + if (**args) { + statusline = *args; + statusll = strlen(statusline); + } + if (*++args) { + LinkList l = newlinklist(); + int zmultsav = zmult; + + for (; *args; args++) + addlinknode(l, *args); + + zmult = 1; + listlist(l); + showinglist = clearlist = 0; + zmult = zmultsav; + } else if (ops['c']) + clearlist = 1; + } else if (ops['c']) + clearlist = 1; zrefresh(); + clearlist = ocl; statusline = s; statusll = sl; return 0; } /**/ +static int +bin_zle_unget(char *name, char **args, char *ops, char func) +{ + char *p = *args; + + while (*p) + ungetkey((int) *p++); + return 0; +} + +/**/ static void scanlistwidgets(HashNode hn, int list) { diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index f7b243d31..5461079cb 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -133,7 +133,8 @@ static LinkList matches, fmatches; /* This holds the list of matches-groups. lmatches is a pointer to the * * last element in this list. */ -static Cmgroup pmatches, amatches, lmatches; +/**/ +Cmgroup pmatches, amatches, lmatches; /* Non-zero if we have permanently allocated matches. */ @@ -150,7 +151,8 @@ static int nmatches, smatches; /* !=0 if we have a valid completion list. */ -static int validlist; +/**/ +int validlist; /* This flag is non-zero if we are completing a pattern (with globcomplete) */ @@ -818,7 +820,8 @@ docomplete(int lst) * string inserted by the last completion. */ if (fromcomp & FC_INWORD) - cs = lastend; + if ((cs = lastend) > ll) + cs = ll; /* Check if we have to start a menu-completion (via automenu). */ @@ -1773,6 +1776,7 @@ doexpansion(char *s, int lst, int olst, int explincmd) if (lst == COMP_LIST_EXPAND) { /* Only the list of expansions was requested. */ listlist(vl); + showinglist = 0; goto end; } /* Remove the current word and put the expansions there. */ @@ -2577,7 +2581,8 @@ comp_match(char *pfx, char *sfx, char *w, Comp cp, return NULL; r = (qu ? quotename(r, NULL) : dupstring(r)); - + if (qu == 2 && r[0] == '\\' && r[1] == '~') + chuck(r); /* We still break it into parts here, trying to build a sensible * cline list for these matches, too. */ wl = strlen(w); @@ -2590,6 +2595,8 @@ comp_match(char *pfx, char *sfx, char *w, Comp cp, int mpl, rpl, wl; w = (qu ? quotename(w, NULL) : dupstring(w)); + if (qu == 2 && w[0] == '\\' && w[1] == '~') + chuck(w); wl = strlen(w); @@ -3814,15 +3821,20 @@ addmatches(Cadata dat, char **argv) dat->rems = dupstring(dat->rems); /* Probably quote the prefix and suffix for testing. */ - if (!cp && (dat->aflags & CAF_MATCH) && - !(dat->aflags & CAF_QUOTE)) { - lpre = quotename(lpre, NULL); - lsuf = quotename(lsuf, NULL); + if (!(dat->aflags & CAF_QUOTE)) { + if (!cp && (dat->aflags & CAF_MATCH)) { + lpre = quotename(lpre, NULL); + lsuf = quotename(lsuf, NULL); + } + if (dat->ppre) { + dat->ppre = quotename(dat->ppre, NULL); + if ((dat->flags & CMF_FILE) && + dat->ppre[0] == '\\' && dat->ppre[1] == '~') + chuck(dat->ppre); + } + if (dat->psuf) + dat->psuf = quotename(dat->psuf, NULL); } - if (dat->ppre) - dat->ppre = quotename(dat->ppre, NULL); - if (dat->psuf) - dat->psuf = quotename(dat->psuf, NULL); } /* Walk through the matches given. */ for (; (s = *argv); argv++) { @@ -3855,7 +3867,9 @@ addmatches(Cadata dat, char **argv) lc = bld_parts(ms, sl, -1, NULL); isexact = 0; } else if (!(ms = comp_match(lpre, lsuf, s, cp, &lc, - !(dat->aflags & CAF_QUOTE), + (!(dat->aflags & CAF_QUOTE) ? + ((dat->ppre && dat->ppre) || + !(dat->flags & CMF_FILE) ? 1 : 2) : 0), &bpl, &bsl, &isexact))) { if (dparr && !*++dparr) dparr = NULL; @@ -3962,7 +3976,7 @@ addmatch(char *s, char *t) } ms = ((addwhat == CC_FILES || addwhat == -6 || addwhat == -5 || addwhat == -8) ? - comp_match(qfpre, qfsuf, s, filecomp, &lc, 1, + comp_match(qfpre, qfsuf, s, filecomp, &lc, (ppre && *ppre ? 1 : 2), &bpl, &bsl, &isexact) : comp_match(fpre, fsuf, s, filecomp, &lc, 0, &bpl, &bsl, &isexact)); @@ -4361,6 +4375,7 @@ docompletion(char *s, int lst, int incmd) cs = origcs; clearlist = 1; ret = 1; + minfo.cur = NULL; goto compend; } if (comppatmatch && *comppatmatch && comppatmatch != opm) @@ -5156,10 +5171,16 @@ sep_comp_string(char *ss, char *s, int noffs, int rec) zsfree(compisuffix); compisuffix = ztrdup(""); zsfree(compqiprefix); - compqiprefix = qp; zsfree(compqisuffix); - compqisuffix = qs; - + if (instring) { + compqiprefix = qp; + compqisuffix = qs; + } else { + compqiprefix = ztrdup(quotename(qp, NULL)); + zsfree(qp); + compqisuffix = ztrdup(quotename(qs, NULL)); + zsfree(qs); + } freearray(compwords); i = countlinknodes(foo); compwords = (char **) zalloc((i + 1) * sizeof(char *)); @@ -7028,7 +7049,7 @@ freematch(Cmatch m) /* This frees the groups of matches. */ /**/ -static void +void freematches(void) { Cmgroup g = pmatches, n; |