diff options
Diffstat (limited to 'Src/Zle')
-rw-r--r-- | Src/Zle/zle_hist.c | 6 | ||||
-rw-r--r-- | Src/Zle/zle_keymap.c | 5 | ||||
-rw-r--r-- | Src/Zle/zle_main.c | 2 | ||||
-rw-r--r-- | Src/Zle/zle_misc.c | 4 | ||||
-rw-r--r-- | Src/Zle/zle_params.c | 9 | ||||
-rw-r--r-- | Src/Zle/zle_thingy.c | 12 |
6 files changed, 33 insertions, 5 deletions
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c index 9719e5418..d7223316c 100644 --- a/Src/Zle/zle_hist.c +++ b/Src/Zle/zle_hist.c @@ -660,7 +660,7 @@ doisearch(char **args, int dir) int odir = dir, sens = zmult == 1 ? 3 : 1; int hl = histline, savekeys = -1, feep = 0; Thingy cmd; - char *okeymap = curkeymapname; + char *okeymap = ztrdup(curkeymapname); static char *previous_search = NULL; static int previous_search_len = 0; Histent he; @@ -883,6 +883,7 @@ doisearch(char **args, int dir) } statusline = NULL; selectkeymap(okeymap, 1); + zsfree(okeymap); /* * Don't allow unused characters provided as a string to the * widget to overflow and be used as separated commands. @@ -960,7 +961,7 @@ getvisrchstr(void) char *sbuf = zhalloc(80); int sptr = 1, ret = 0, ssbuf = 80, feep = 0; Thingy cmd; - char *okeymap = curkeymapname; + char *okeymap = ztrdup(curkeymapname); if (vipenultsrchstr) { zsfree(vipenultsrchstr); @@ -1044,6 +1045,7 @@ getvisrchstr(void) } statusline = NULL; selectkeymap(okeymap, 1); + zsfree(okeymap); return ret; } diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index f820a758f..9fd5a9197 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -388,7 +388,10 @@ selectkeymap(char *name, int fb) return 1; km = openkeymap(name = ".safe"); } - curkeymapname = name; + if(name != curkeymapname) { + zsfree(curkeymapname); + curkeymapname = ztrdup(name); + } curkeymap = km; return 0; } diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index d46d3b537..cec6c1b4e 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1100,7 +1100,7 @@ zleaftertrap(Hookdef dummy, void *dat) static struct builtin bintab[] = { BUILTIN("bindkey", 0, bin_bindkey, 0, -1, 0, "evaMldDANmrsLRp", NULL), BUILTIN("vared", 0, bin_vared, 1, 7, 0, NULL, NULL), - BUILTIN("zle", 0, bin_zle, 0, -1, 0, "lDANCLmMgGcRaUI", NULL), + BUILTIN("zle", 0, bin_zle, 0, -1, 0, "lDANCLmMgGcRaUKI", 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 e24d0c08b..592a590b5 100644 --- a/Src/Zle/zle_misc.c +++ b/Src/Zle/zle_misc.c @@ -669,7 +669,7 @@ executenamedcommand(char *prmt) int len, l = strlen(prmt), feep = 0, listed = 0, curlist = 0; int ols = (listshown && validlist), olll = lastlistlen; char *ptr; - char *okeymap = curkeymapname; + char *okeymap = ztrdup(curkeymapname); clearlist = 1; cmdbuf = zhalloc(l + NAMLEN + 2); @@ -685,6 +685,7 @@ executenamedcommand(char *prmt) if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak)) { statusline = NULL; selectkeymap(okeymap, 1); + zsfree(okeymap); if ((listshown = ols)) { showinglist = -2; lastlistlen = olll; @@ -752,6 +753,7 @@ executenamedcommand(char *prmt) unrefthingy(r); statusline = NULL; selectkeymap(okeymap, 1); + zsfree(okeymap); if ((listshown = ols)) { showinglist = -2; lastlistlen = olll; diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c index 7db5d6698..dfdc0dcd7 100644 --- a/Src/Zle/zle_params.c +++ b/Src/Zle/zle_params.c @@ -69,6 +69,8 @@ static struct zleparam { zleunsetfn, NULL }, { "LASTWIDGET", PM_SCALAR | PM_READONLY, NULL, FN(get_lwidget), zleunsetfn, NULL }, + { "KEYMAP", PM_SCALAR | PM_READONLY, NULL, FN(get_keymap), + zleunsetfn, NULL }, { "KEYS", PM_SCALAR | PM_READONLY, NULL, FN(get_keys), zleunsetfn, NULL }, { "NUMERIC", PM_INTEGER | PM_UNSET, FN(set_numeric), FN(get_numeric), @@ -273,6 +275,13 @@ get_lwidget(Param pm) /**/ static char * +get_keymap(Param pm) +{ + return dupstring(curkeymapname); +} + +/**/ +static char * get_keys(Param pm) { return keybuf; diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c index f5acb73b4..dd2aea40d 100644 --- a/Src/Zle/zle_thingy.c +++ b/Src/Zle/zle_thingy.c @@ -339,6 +339,7 @@ bin_zle(char *name, char **args, char *ops, int func) { 'R', bin_zle_refresh, 0, -1 }, { 'M', bin_zle_mesg, 1, 1 }, { 'U', bin_zle_unget, 1, 1 }, + { 'K', bin_zle_keymap, 1, 1 }, { 'I', bin_zle_invalidate, 0, 0 }, { 0, bin_zle_call, 0, -1 }, }; @@ -465,6 +466,17 @@ bin_zle_unget(char *name, char **args, char *ops, char func) } /**/ +static int +bin_zle_keymap(char *name, char **args, char *ops, char func) +{ + if (!zleactive) { + zwarnnam(name, "can only be called from widget function", NULL, 0); + return 1; + } + return selectkeymap(*args, 0); +} + +/**/ static void scanlistwidgets(HashNode hn, int list) { |