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

Make MENU mode a "main" mode.

--HG--
branch : key-processing
This commit is contained in:
Kris Maglione
2011-01-24 06:57:39 -05:00
parent 919e5df705
commit 3fd86c2ca4
2 changed files with 25 additions and 37 deletions

View File

@@ -923,7 +923,8 @@ var Events = Module("events", {
events: {
DOMMenuBarActive: function () {
this._activeMenubar = true;
modes.add(modes.MENU);
if (modes.main != modes.MENU)
modes.push(modes.MENU);
},
DOMMenuBarInactive: function () {
@@ -1057,11 +1058,6 @@ var Events = Module("events", {
mode = Modes.StackElement(event.dactylMode);
let ignore = false;
let overrideMode = null;
// menus have their own command handlers
if (modes.extended & modes.MENU)
overrideMode = modes.MENU;
if (modes.main == modes.PASS_THROUGH)
ignore = !Events.isEscape(key) && key != "<C-v>";
@@ -1090,13 +1086,10 @@ var Events = Module("events", {
if (config.ignoreKeys[key] & mode.main)
return null;
if (overrideMode)
var keyModes = array([overrideMode]);
else
keyModes = array([mode.params.keyModes, mode.main, mode.main.allBases]).flatten().compact();
let hives = mappings.hives.slice(event.noremap ? -1 : 0);
let keyModes = array([mode.params.keyModes, mode.main, mode.main.allBases]).flatten().compact();
this.processor = ProcessorStack(mode, hives, keyModes);
}
@@ -1153,7 +1146,8 @@ var Events = Module("events", {
popupshown: function onPopupShown(event) {
if (event.originalTarget.localName !== "tooltip" && event.originalTarget.id !== "dactyl-visualbell")
modes.add(modes.MENU);
if (modes.main != modes.MENU)
modes.push(modes.MENU);
},
popuphidden: function onPopupHidden() {

View File

@@ -155,6 +155,11 @@ var Modes = Module("modes", {
bases: []
});
this.addMode("MENU", {
description: "Active when a menu or other pop-up is open",
input: true
});
// this._extended modes, can include multiple modes, and even main modes
this.addMode("EX", {
extended: true,
@@ -172,14 +177,9 @@ var Modes = Module("modes", {
hidden: true,
input: true
});
this.addMode("MENU", {
extended: true,
input: true,
description: "Active when a menu or other pop-up is open",
}); // a popupmenu is active
this.addMode("LINE", {
extended: true, hidden: true
}); // linewise visual mode
});
this.addMode("PROMPT", {
extended: true,
description: "Active when a prompt is open in the command line",
@@ -219,14 +219,9 @@ var Modes = Module("modes", {
else if (modes.replaying)
macromode = "replaying";
let ext = "";
if (this._extended & modes.MENU) // TODO: desirable?
ext += " (menu)";
ext += " --" + macromode;
let val = this._modeMap[this._main].display();
if (val)
return "-- " + val + ext;
return "-- " + val + " --" + macromode;;
return macromode;
},
@@ -270,6 +265,8 @@ var Modes = Module("modes", {
getStack: function (idx) this._modeStack[this._modeStack.length - idx - 1] || this._modeStack[0],
get stack() this._modeStack.slice(),
getCharModes: function (chr) (this.modeChars[chr] || []).slice(),
matchModes: function (obj)
@@ -285,10 +282,11 @@ var Modes = Module("modes", {
commandline.widgets.mode = msg || null;
},
// add/remove always work on the this._extended mode only
add: function add(mode) {
this._extended |= mode;
this.show();
remove: function remove(mode) {
if (this.stack.some(function (m) m.main == mode)) {
this.pop(mode);
this.pop();
}
},
delayed: [],
@@ -391,13 +389,6 @@ var Modes = Module("modes", {
this.pop();
},
remove: function remove(mode) {
if (this._extended & mode) {
this._extended &= ~mode;
this.show();
}
},
get recording() this._recording,
set recording(value) { this._recording = value; this.show(); },
@@ -505,10 +496,13 @@ var Modes = Module("modes", {
"Return to the previous mode",
function () { modes.pop(); });
mappings.add([modes.MENU],
["<Esc>", "<C-[>"],
mappings.add([modes.MENU], ["<Esc>"],
"Close the current popup",
function () Events.PASS);
mappings.add([modes.MENU], ["<C-[>"],
"Close the current popup",
function () { events.feedkeys("<Esc>") });
},
prefs: function () {
prefs.watch("accessibility.browsewithcaret", modes.closure.onCaretChange);