diff options
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Zle/zle_main.c | 5 | ||||
-rw-r--r-- | Src/Zle/zle_params.c | 24 | ||||
-rw-r--r-- | Src/Zle/zle_thingy.c | 39 | ||||
-rw-r--r-- | Src/exec.c | 2 | ||||
-rw-r--r-- | Src/loop.c | 8 | ||||
-rw-r--r-- | Src/text.c | 4 |
6 files changed, 71 insertions, 11 deletions
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 992f152df..593d636cc 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1402,7 +1402,8 @@ execzlefunc(Thingy func, char **args, int set_bindk) opts[XTRACE] = oxt; sfcontext = osc; endparamscope(); - lastcmd = 0; + lastcmd = w->flags; + w->flags = 0; r = 1; redup(osi, 0); } @@ -1981,7 +1982,7 @@ zle_main_entry(int cmd, va_list ap) static struct builtin bintab[] = { BUILTIN("bindkey", 0, bin_bindkey, 0, -1, 0, "evaM:ldDANmrsLRp", NULL), BUILTIN("vared", 0, bin_vared, 1, 1, 0, "aAcef:hi:M:m:p:r:t:", NULL), - BUILTIN("zle", 0, bin_zle, 0, -1, 0, "aAcCDFgGIKlLmMNrRTUw", NULL), + BUILTIN("zle", 0, bin_zle, 0, -1, 0, "aAcCDfFgGIKlLmMNrRTUw", NULL), }; /* The order of the entries in this table has to match the *HOOK diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c index 000bc388c..b5bb288f1 100644 --- a/Src/Zle/zle_params.c +++ b/Src/Zle/zle_params.c @@ -98,9 +98,9 @@ static const struct gsu_integer undo_change_no_gsu = static const struct gsu_integer undo_limit_no_gsu = { get_undo_limit_change, set_undo_limit_change, zleunsetfn }; static const struct gsu_integer yankstart_gsu = -{ get_yankstart, NULL, zleunsetfn }; +{ get_yankstart, set_yankstart, zleunsetfn }; static const struct gsu_integer yankend_gsu = -{ get_yankend, NULL, zleunsetfn }; +{ get_yankend, set_yankend, zleunsetfn }; static const struct gsu_integer yankactive_gsu = { get_yankactive, NULL, zleunsetfn }; @@ -149,8 +149,8 @@ static struct zleparam { { "WIDGET", PM_SCALAR | PM_READONLY, GSU(widget_gsu), NULL }, { "WIDGETFUNC", PM_SCALAR | PM_READONLY, GSU(widgetfunc_gsu), NULL }, { "WIDGETSTYLE", PM_SCALAR | PM_READONLY, GSU(widgetstyle_gsu), NULL }, - { "YANK_START", PM_INTEGER | PM_READONLY, GSU(yankstart_gsu), NULL }, - { "YANK_END", PM_INTEGER | PM_READONLY, GSU(yankend_gsu), NULL }, + { "YANK_START", PM_INTEGER, GSU(yankstart_gsu), NULL }, + { "YANK_END", PM_INTEGER, GSU(yankend_gsu), NULL }, { "YANK_ACTIVE", PM_INTEGER | PM_READONLY, GSU(yankactive_gsu), NULL }, { "ZLE_STATE", PM_SCALAR | PM_READONLY, GSU(zle_state_gsu), NULL }, { NULL, 0, NULL, NULL } @@ -503,7 +503,21 @@ get_yankend(UNUSED(Param pm)) static zlong get_yankactive(UNUSED(Param pm)) { - return lastcmd & ZLE_YANK; + return !!(lastcmd & ZLE_YANK) + !!(lastcmd & ZLE_YANKAFTER); +} + +/**/ +static void +set_yankstart(UNUSED(Param pm), zlong i) +{ + yankb = i; +} + +/**/ +static void +set_yankend(UNUSED(Param pm), zlong i) +{ + yanke = i; } /**/ diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c index da3a6d458..3963d7eaf 100644 --- a/Src/Zle/zle_thingy.c +++ b/Src/Zle/zle_thingy.c @@ -352,6 +352,7 @@ bin_zle(char *name, char **args, Options ops, UNUSED(int func)) { 'U', bin_zle_unget, 1, 1 }, { 'K', bin_zle_keymap, 1, 1 }, { 'I', bin_zle_invalidate, 0, 0 }, + { 'f', bin_zle_flags, 1, -1 }, { 'F', bin_zle_fd, 0, 2 }, { 'T', bin_zle_transform, 0, 2}, { 0, bin_zle_call, 0, -1 }, @@ -625,6 +626,44 @@ bin_zle_complete(char *name, char **args, UNUSED(Options ops), UNUSED(char func) /**/ static int +bin_zle_flags(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) +{ + char **flag; + + if (!zle_usable()) { + zwarnnam(name, "can only set flags from a widget"); + return 1; + } + + if (bindk) { + Widget w = bindk->widget; + if (w) { + for (flag = args; *flag; flag++) { + if (!strcmp(*flag, "yank")) { + w->flags |= ZLE_YANKAFTER; + } else if (!strcmp(*flag, "yankbefore")) + w->flags |= ZLE_YANKBEFORE; + else if (!strcmp(*flag, "kill")) + w->flags |= ZLE_KILL; + /* + * These won't do anything yet, because of how execzlefunc + * handles user widgets + } else if (!strcmp(*flag, "menucmp")) + w->flags |= ZLE_MENUCMP; + else if (!strcmp(*flag, "linemove")) + w->flags |= ZLE_LINEMOVE; + else if (!strcmp(*flag, "keepsuffix")) + w->flags |= ZLE_KEEPSUFFIX; + */ + else + zwarnnam(name, "invalid flag `%s' given to zle -f", *flag); + } + } + } +} + +/**/ +static int zle_usable() { return zleactive && !incompctlfunc && !incompfunc diff --git a/Src/exec.c b/Src/exec.c index da808d6f1..154bbb8db 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1408,7 +1408,7 @@ sublist_done: exit(lastval); } if (errreturn) { - retflag = 1; + retflag = 2; breaks = loops; } } diff --git a/Src/loop.c b/Src/loop.c index 4def9b652..7d1528efe 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -552,8 +552,12 @@ execif(Estate state, int do_exec) run = 1; break; } - if (retflag) - break; + if (retflag) { + if (retflag == 2) + retflag = 0; /* Never ERR_RETURN here */ + else + break; + } s = 1; state->pc = next; } diff --git a/Src/text.c b/Src/text.c index 7e65f43a4..9421d70ce 100644 --- a/Src/text.c +++ b/Src/text.c @@ -632,8 +632,10 @@ gettext2(Estate state) taddstr(" in "); taddlist(state, *state->pc++); } - tindent++; taddnl(0); + taddstr("do"); + taddnl(0); + tindent++; tpush(code, 1); } else { dec_tindent(); |