1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 20:57: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: { events: {
DOMMenuBarActive: function () { DOMMenuBarActive: function () {
this._activeMenubar = true; this._activeMenubar = true;
modes.add(modes.MENU); if (modes.main != modes.MENU)
modes.push(modes.MENU);
}, },
DOMMenuBarInactive: function () { DOMMenuBarInactive: function () {
@@ -1057,11 +1058,6 @@ var Events = Module("events", {
mode = Modes.StackElement(event.dactylMode); mode = Modes.StackElement(event.dactylMode);
let ignore = false; 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) if (modes.main == modes.PASS_THROUGH)
ignore = !Events.isEscape(key) && key != "<C-v>"; ignore = !Events.isEscape(key) && key != "<C-v>";
@@ -1090,13 +1086,10 @@ var Events = Module("events", {
if (config.ignoreKeys[key] & mode.main) if (config.ignoreKeys[key] & mode.main)
return null; 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 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); this.processor = ProcessorStack(mode, hives, keyModes);
} }
@@ -1153,7 +1146,8 @@ var Events = Module("events", {
popupshown: function onPopupShown(event) { popupshown: function onPopupShown(event) {
if (event.originalTarget.localName !== "tooltip" && event.originalTarget.id !== "dactyl-visualbell") 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() { popuphidden: function onPopupHidden() {

View File

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