1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 14:57:59 +01:00

Make <Esc> a normal mapping rather than a grotesque hack.

This commit is contained in:
Kris Maglione
2011-01-19 20:30:54 -05:00
parent a8a840afc2
commit 95eb8aaf93
4 changed files with 19 additions and 32 deletions

View File

@@ -994,7 +994,7 @@ var CommandLine = Module("commandline", {
if (this._completions)
this._completions.previewClear();
if (!this.currentExtendedMode)
return Events.isEscape(event) ? KILL : PASS;
return PASS;
// user pressed <Enter> to carry out a command
// user pressing <Esc> is handled in the global onEscape
@@ -1028,7 +1028,7 @@ var CommandLine = Module("commandline", {
}
}
// allow this event to be handled by the host app
return Events.isEscape(event) ? KILL : PASS;
return PASS;
}
else if (event.type == "keyup") {
let key = events.toString(event);

View File

@@ -713,27 +713,6 @@ var Events = Module("events", {
modes.remove(modes.MENU);
},
/**
* The global escape key handler. This is called in ALL modes.
*/
onEscape: function () {
switch (modes.main) {
case modes.COMMAND_LINE:
case modes.INSERT:
case modes.OUTPUT_MULTILINE:
case modes.PASS_THROUGH:
case modes.QUOTE:
case modes.TEXT_EDIT:
case modes.VISUAL:
modes.pop();
break;
default:
modes.reset();
break;
}
},
/**
* Ensures that the currently focused element is visible and blurs
* it if it's not.
@@ -1023,9 +1002,6 @@ var Events = Module("events", {
refeed.shift();
}
if (Events.isEscape(key) && !shouldPass())
res = Events.KILL;
if (res !== Events.PASS)
kill(event);
@@ -1041,11 +1017,6 @@ var Events = Module("events", {
catch (e) {
dactyl.reportError(e);
}
finally {
// This is a stupid, silly, and revolting hack.
if (Events.isEscape(key) && !shouldPass())
this.onEscape();
}
},
onKeyUpOrDown: function onKeyUpOrDown(event) {

View File

@@ -944,7 +944,7 @@ var Hints = Module("hints", {
return KILL;
}
return Events.isEscape(key) ? KILL : PASS;
return PASS;
}
//}}}
}, {

View File

@@ -489,6 +489,22 @@ var Modes = Module("modes", {
}, desc));
}
}, {
mappings: function () {
mappings.add([modes.BASE],
["<Esc>", "<C-[>"],
"Return to NORMAL mode",
function () { modes.reset() });
mappings.add([modes.INPUT, modes.COMMAND, modes.PASS_THROUGH, modes.QUOTE],
["<Esc>", "<C-[>"],
"Return to the previous mode",
function () { modes.reset() });
mappings.add([modes.MENU],
["<Esc>", "<C-[>"],
"Close the current popup",
function () events.PASS);
},
prefs: function () {
prefs.watch("accessibility.browsewithcaret", modes.closure.onCaretChange);
}