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

Don't close the completion list when leaving command-line mode (e.g., opening the context menu). Fix :pageinfo (which currently lacks a unit test).

--HG--
branch : key-processing
This commit is contained in:
Kris Maglione
2011-01-29 01:41:24 -05:00
parent 09f3541a76
commit a3fa68042b
3 changed files with 26 additions and 17 deletions

View File

@@ -1420,7 +1420,7 @@ var Buffer = Module("buffer", {
let arg = args[0];
let opt = options.get("pageinfo");
dactyl.assert(opt.validator(opt.parse(arg)), "E475: Invalid argument: " + arg);
dactyl.assert(!arg || opt.validator(opt.parse(arg)), "E475: Invalid argument: " + arg);
buffer.showPageInfo(true, arg);
},
{

View File

@@ -269,22 +269,29 @@ var CommandWidgets = Class("CommandWidgets", {
},
get completionList() this._whenReady("completionList", "dactyl-completions"),
completionContainer: Class.memoize(function () this.completionList.parentNode),
get multilineOutput() this._whenReady("multilineOutput", "dactyl-multiline-output",
function (elem) {
elem.contentWindow.addEventListener("unload", function (event) { event.preventDefault(); }, true);
elem.contentDocument.documentElement.id = "dactyl-multiline-output-top";
elem.contentDocument.body.id = "dactyl-multiline-output-content";
completionContainer: Class.memoize(function () this.completionList.parentNode),
contextMenu: Class.memoize(function () {
["copy", "copylink", "selectall"].forEach(function (tail) {
// some host apps use "hostPrefixContext-copy" ids
let xpath = "//xul:menuitem[contains(@id, '" + "ontext-" + tail + "') and not(starts-with(@id, 'dactyl-'))]";
document.getElementById("dactyl-context-" + tail).style.listStyleImage =
util.computedStyle(util.evaluateXPath(xpath, document).snapshotItem(0)).listStyleImage;
});
return document.getElementById("dactyl-contextmenu");
}),
get multilineOutput() this._whenReady("multilineOutput", "dactyl-multiline-output",
function (elem) {
elem.contentWindow.addEventListener("unload", function (event) { event.preventDefault(); }, true);
elem.contentDocument.documentElement.id = "dactyl-multiline-output-top";
elem.contentDocument.body.id = "dactyl-multiline-output-content";
return elem;
}),
multilineInput: Class.memoize(function () document.getElementById("dactyl-multiline-input")),
mowContainer: Class.memoize(function () document.getElementById("dactyl-multiline-output-container"))
}, {
getEditor: function getEditor(elem) {
@@ -331,6 +338,7 @@ var CommandMode = Class("CommandMode", {
},
leave: function (stack) {
if (!stack.push) {
if (this.completions)
this.completions.cleanup();
@@ -340,7 +348,6 @@ var CommandMode = Class("CommandMode", {
commandline.hideCompletions();
this.resetCompletions();
if (!stack.push) {
modes.delay(function () {
if (!this.keepCommand || commandline.silent || commandline.quiet)
commandline.hide();
@@ -1120,6 +1127,7 @@ var CommandLine = Module("commandline", {
if (show) {
this.itemList.reset();
this.itemList.visible = true;
this.selected = null;
this.wildIndex = 0;
}

View File

@@ -172,13 +172,14 @@ var MOW = Module("mow", {
},
contextEvents: {
popupshowing: function (event) {
let menu = commandline.widgets.contextMenu;
let enabled = {
link: window.document.popupNode instanceof HTMLAnchorElement,
path: window.document.popupNode.hasAttribute("path"),
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed
};
for (let node in array.iterValues(event.target.children)) {
for (let node in array.iterValues(menu.children)) {
let group = node.getAttributeNS(NS, "group");
node.hidden = group && !group.split(/\s+/).every(function (g) enabled[g]);
}