about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-02-10 10:56:55 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2016-02-13 12:51:12 -0800
commit1b923f69c7dac0e0a2c71c62bbcdb2d2de5128db (patch)
tree47223527a62fd0e88d92a5cebc92b872de2795dd /Src
parent9cc6ebe7a2263e6697d497e95335369b06bec11b (diff)
downloadzsh-1b923f69c7dac0e0a2c71c62bbcdb2d2de5128db.tar.gz
zsh-1b923f69c7dac0e0a2c71c62bbcdb2d2de5128db.tar.xz
zsh-1b923f69c7dac0e0a2c71c62bbcdb2d2de5128db.zip
37927: recreate local keymaps as necessary in case the user has deleted them
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/complist.c55
1 files changed, 34 insertions, 21 deletions
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 &&
@@ -3486,6 +3488,37 @@ enables_(Module m, int **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;
 }