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

Add an experimental prototype download manager replacement. Fix some bugs.

--HG--
extra : rebase_source : aea703414d4bd601bfdea779c5878a30d5b3d782
This commit is contained in:
Kris Maglione
2011-01-16 22:38:44 -05:00
parent b52e78b92e
commit ed696fe5c4
16 changed files with 444 additions and 77 deletions

View File

@@ -265,10 +265,12 @@ var CommandWidgets = Class("CommandWidgets", {
while (elem.contentDocument.documentURI != elem.getAttribute("src") ||
["viewable", "complete"].indexOf(elem.contentDocument.readyState) < 0)
util.threadYield();
return elem;
res = res || (processor || util.identity).call(self, elem);
return res;
}
});
return Class.replaceProperty(this, name, (processor || util.identity).call(this, this[name]))
let res, self = this;
return Class.replaceProperty(this, name, this[name])
},
get completionList() this._whenReady("completionList", "dactyl-completions"),
@@ -748,8 +750,15 @@ var CommandLine = Module("commandline", {
XML.ignoreWhitespace = false;
XML.prettyPrinting = false;
let style = typeof str === "string" ? "pre" : "nowrap";
this._lastMowOutput = <div class="ex-command-output" style={"white-space: " + style} highlight={highlightGroup}>{str}</div>;
let output = util.xmlToDom(this._lastMowOutput, doc);
if (callable(str)) {
this._lastMowOutput = null;
var output = util.xmlToDom(<div class="ex-command-output" style="white-space: nowrap" highlight={highlightGroup}/>, doc);
output.appendChild(str(doc));
}
else {
this._lastMowOutput = <div class="ex-command-output" style={"white-space: " + style} highlight={highlightGroup}>{str}</div>;
var output = util.xmlToDom(this._lastMowOutput, doc);
}
// FIXME: need to make sure an open MOW is closed when commands
// that don't generate output are executed
@@ -824,7 +833,7 @@ var CommandLine = Module("commandline", {
let single = flags & (this.FORCE_SINGLELINE | this.DISALLOW_MULTILINE);
let action = this._echoLine;
if ((flags & this.FORCE_MULTILINE) || (/\n/.test(str) || typeof str == "xml") && !(flags & this.FORCE_SINGLELINE))
if ((flags & this.FORCE_MULTILINE) || (/\n/.test(str) || !isString(str)) && !(flags & this.FORCE_SINGLELINE))
action = this._echoMultiline;
if (single)
@@ -1073,63 +1082,69 @@ var CommandLine = Module("commandline", {
// FIXME: if 'more' is set and the MOW is not scrollable we should still
// allow a down motion after an up rather than closing
onMultilineOutputEvent: function onMultilineOutputEvent(event) {
const KILL = false, PASS = true;
try {
const KILL = false, PASS = true;
let win = this.widgets.multilineOutput.contentWindow;
let elem = win.document.documentElement;
let win = this.widgets.multilineOutput.contentWindow;
let elem = win.document.documentElement;
let key = events.toString(event);
let key = events.toString(event);
function openLink(where) {
event.preventDefault();
dactyl.open(event.target.href, where);
}
// TODO: Wouldn't multiple handlers be cleaner? --djk
if (event.type == "click" && event.target instanceof HTMLAnchorElement) {
let command = event.originalTarget.getAttributeNS(NS.uri, "command");
if (command && dactyl.commands[command]) {
const openLink = function openLink(where) {
event.preventDefault();
return dactyl.withSavedValues(["forceNewTab"], function () {
dactyl.forceNewTab = event.ctrlKey || event.shiftKey || event.button == 1;
return dactyl.commands[command](event);
});
dactyl.open(event.target.href, where);
}
switch (key) {
case "<LeftMouse>":
event.preventDefault();
openLink(dactyl.CURRENT_TAB);
return KILL;
case "<MiddleMouse>":
case "<C-LeftMouse>":
case "<C-M-LeftMouse>":
openLink({ where: dactyl.NEW_TAB, background: true });
return KILL;
case "<S-MiddleMouse>":
case "<C-S-LeftMouse>":
case "<C-M-S-LeftMouse>":
openLink({ where: dactyl.NEW_TAB, background: false });
return KILL;
case "<S-LeftMouse>":
openLink(dactyl.NEW_WINDOW);
return KILL;
// TODO: Wouldn't multiple handlers be cleaner? --djk
if (event.type == "click" && (event.target instanceof HTMLAnchorElement ||
event.originalTarget.hasAttributeNS(NS, "command"))) {
let command = event.originalTarget.getAttributeNS(NS, "command");
if (command && dactyl.commands[command]) {
event.preventDefault();
return dactyl.withSavedValues(["forceNewTab"], function () {
dactyl.forceNewTab = event.ctrlKey || event.shiftKey || event.button == 1;
return dactyl.commands[command](event);
});
}
switch (key) {
case "<LeftMouse>":
event.preventDefault();
openLink(dactyl.CURRENT_TAB);
return KILL;
case "<MiddleMouse>":
case "<C-LeftMouse>":
case "<C-M-LeftMouse>":
openLink({ where: dactyl.NEW_TAB, background: true });
return KILL;
case "<S-MiddleMouse>":
case "<C-S-LeftMouse>":
case "<C-M-S-LeftMouse>":
openLink({ where: dactyl.NEW_TAB, background: false });
return KILL;
case "<S-LeftMouse>":
openLink(dactyl.NEW_WINDOW);
return KILL;
}
return PASS;
}
return PASS;
if (event instanceof MouseEvent)
return KILL;
const atEnd = function atEnd(dir) !Buffer.isScrollable(elem, dir || 1);
if (!options["more"] || atEnd(1)) {
modes.pop();
events.feedkeys(key);
}
else
commandline.updateMorePrompt(false, true);
}
if (event instanceof MouseEvent)
return KILL;
function atEnd(dir) !Buffer.isScrollable(elem, dir || 1);
if (!options["more"] || atEnd(1)) {
modes.pop();
events.feedkeys(key);
catch (e) {
util.reportError(e);
}
else
commandline.updateMorePrompt(false, true);
return PASS;
},