mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 16:27:59 +01:00
Make <Esc> a normal mapping rather than a grotesque hack.
This commit is contained in:
@@ -994,7 +994,7 @@ var CommandLine = Module("commandline", {
|
|||||||
if (this._completions)
|
if (this._completions)
|
||||||
this._completions.previewClear();
|
this._completions.previewClear();
|
||||||
if (!this.currentExtendedMode)
|
if (!this.currentExtendedMode)
|
||||||
return Events.isEscape(event) ? KILL : PASS;
|
return PASS;
|
||||||
|
|
||||||
// user pressed <Enter> to carry out a command
|
// user pressed <Enter> to carry out a command
|
||||||
// user pressing <Esc> is handled in the global onEscape
|
// 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
|
// allow this event to be handled by the host app
|
||||||
return Events.isEscape(event) ? KILL : PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
else if (event.type == "keyup") {
|
else if (event.type == "keyup") {
|
||||||
let key = events.toString(event);
|
let key = events.toString(event);
|
||||||
|
|||||||
@@ -713,27 +713,6 @@ var Events = Module("events", {
|
|||||||
modes.remove(modes.MENU);
|
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
|
* Ensures that the currently focused element is visible and blurs
|
||||||
* it if it's not.
|
* it if it's not.
|
||||||
@@ -1023,9 +1002,6 @@ var Events = Module("events", {
|
|||||||
refeed.shift();
|
refeed.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Events.isEscape(key) && !shouldPass())
|
|
||||||
res = Events.KILL;
|
|
||||||
|
|
||||||
if (res !== Events.PASS)
|
if (res !== Events.PASS)
|
||||||
kill(event);
|
kill(event);
|
||||||
|
|
||||||
@@ -1041,11 +1017,6 @@ var Events = Module("events", {
|
|||||||
catch (e) {
|
catch (e) {
|
||||||
dactyl.reportError(e);
|
dactyl.reportError(e);
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
// This is a stupid, silly, and revolting hack.
|
|
||||||
if (Events.isEscape(key) && !shouldPass())
|
|
||||||
this.onEscape();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyUpOrDown: function onKeyUpOrDown(event) {
|
onKeyUpOrDown: function onKeyUpOrDown(event) {
|
||||||
|
|||||||
@@ -944,7 +944,7 @@ var Hints = Module("hints", {
|
|||||||
return KILL;
|
return KILL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Events.isEscape(key) ? KILL : PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
//}}}
|
//}}}
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -489,6 +489,22 @@ var Modes = Module("modes", {
|
|||||||
}, desc));
|
}, 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: function () {
|
||||||
prefs.watch("accessibility.browsewithcaret", modes.closure.onCaretChange);
|
prefs.watch("accessibility.browsewithcaret", modes.closure.onCaretChange);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user