1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-05 11:55:47 +01:00

Merge some recent fixes into 1.0b5 branch.

This commit is contained in:
Kris Maglione
2011-01-17 13:28:14 -05:00
parent b52e78b92e
commit 2c74786f1c
13 changed files with 212 additions and 138 deletions

View File

@@ -174,15 +174,14 @@ var Buffer = Module("buffer", {
else else
ext = ""; ext = "";
let re = ext ? RegExp("(\\." + currExt + ")?$") : /$/; let re = ext ? RegExp("(\\." + currExt + ")?$") : /$/;
util.dump(ext.quote(),
isinstance(node, [Document, HTMLImageElement]),
node.contentType);
var names = []; var names = [];
if (node.title) if (node.title)
names.push([node.title, "Page Name"]); names.push([node.title, "Page Name"]);
if (node.alt) if (node.alt)
names.push([node.alt, "Alternate Text"]); names.push([node.alt, "Alternate Text"]);
if (!isinstance(node, Document) && node.textContent) if (!isinstance(node, Document) && node.textContent)
names.push([node.textContent, "Link Text"]); names.push([node.textContent, "Link Text"]);
@@ -786,6 +785,10 @@ var Buffer = Module("buffer", {
var persist = services.Persist(); var persist = services.Persist();
persist.persistFlags = persist.PERSIST_FLAGS_FROM_CACHE persist.persistFlags = persist.PERSIST_FLAGS_FROM_CACHE
| persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES; | persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
persist.progressListener = new window.DownloadListener(window,
services.Transfer(uri, services.io.newFileURI(file), "",
null, null, null, persist));
persist.saveURI(uri, null, null, null, null, file); persist.saveURI(uri, null, null, null, null, file);
}, { }, {
autocomplete: true, autocomplete: true,

View File

@@ -21,6 +21,9 @@ var CommandWidgets = Class("CommandWidgets", {
<menuitem id="dactyl-context-copylink" <menuitem id="dactyl-context-copylink"
label="Copy Link Location" dactyl:group="link" label="Copy Link Location" dactyl:group="link"
oncommand="goDoCommand('cmd_copyLink');"/> oncommand="goDoCommand('cmd_copyLink');"/>
<menuitem id="dactyl-context-copypath"
label="Copy File Path" dactyl:group="link path"
oncommand="dactyl.clipboardWrite(document.popupNode.getAttribute('path'));"/>
<menuitem id="dactyl-context-copy" <menuitem id="dactyl-context-copy"
label="Copy" dactyl:group="selection" label="Copy" dactyl:group="selection"
command="cmd_copy"/> command="cmd_copy"/>
@@ -265,10 +268,12 @@ var CommandWidgets = Class("CommandWidgets", {
while (elem.contentDocument.documentURI != elem.getAttribute("src") || while (elem.contentDocument.documentURI != elem.getAttribute("src") ||
["viewable", "complete"].indexOf(elem.contentDocument.readyState) < 0) ["viewable", "complete"].indexOf(elem.contentDocument.readyState) < 0)
util.threadYield(); 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"), get completionList() this._whenReady("completionList", "dactyl-completions"),
@@ -748,8 +753,15 @@ var CommandLine = Module("commandline", {
XML.ignoreWhitespace = false; XML.ignoreWhitespace = false;
XML.prettyPrinting = false; XML.prettyPrinting = false;
let style = typeof str === "string" ? "pre" : "nowrap"; let style = typeof str === "string" ? "pre" : "nowrap";
this._lastMowOutput = <div class="ex-command-output" style={"white-space: " + style} highlight={highlightGroup}>{str}</div>; if (callable(str)) {
let output = util.xmlToDom(this._lastMowOutput, doc); 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 // FIXME: need to make sure an open MOW is closed when commands
// that don't generate output are executed // that don't generate output are executed
@@ -824,7 +836,7 @@ var CommandLine = Module("commandline", {
let single = flags & (this.FORCE_SINGLELINE | this.DISALLOW_MULTILINE); let single = flags & (this.FORCE_SINGLELINE | this.DISALLOW_MULTILINE);
let action = this._echoLine; 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; action = this._echoMultiline;
if (single) if (single)
@@ -928,14 +940,21 @@ var CommandLine = Module("commandline", {
}, },
onContext: function onContext(event) { onContext: function onContext(event) {
let enabled = { try {
link: window.document.popupNode instanceof HTMLAnchorElement, let enabled = {
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed link: window.document.popupNode instanceof HTMLAnchorElement,
}; path: window.document.popupNode.hasAttribute("path"),
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed
};
for (let [, node] in iter(event.target.childNodes)) { for (let node in array.iterValues(event.target.children)) {
let group = node.getAttributeNS(NS, "group"); let group = node.getAttributeNS(NS, "group");
node.hidden = group && !group.split(/\s+/).some(function (g) enabled[g]); util.dump(node, group, group && !group.split(/\s+/).every(function (g) enabled[g]));
node.hidden = group && !group.split(/\s+/).every(function (g) enabled[g]);
}
}
catch (e) {
util.reportError(e);
} }
return true; return true;
}, },
@@ -1073,63 +1092,72 @@ var CommandLine = Module("commandline", {
// FIXME: if 'more' is set and the MOW is not scrollable we should still // FIXME: if 'more' is set and the MOW is not scrollable we should still
// allow a down motion after an up rather than closing // allow a down motion after an up rather than closing
onMultilineOutputEvent: function onMultilineOutputEvent(event) { onMultilineOutputEvent: function onMultilineOutputEvent(event) {
const KILL = false, PASS = true; try {
const KILL = false, PASS = true;
let win = this.widgets.multilineOutput.contentWindow; let win = this.widgets.multilineOutput.contentWindow;
let elem = win.document.documentElement; let elem = win.document.documentElement;
let key = events.toString(event); let key = events.toString(event);
function openLink(where) { const openLink = 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]) {
event.preventDefault(); event.preventDefault();
return dactyl.withSavedValues(["forceNewTab"], function () { dactyl.open(event.target.href, where);
dactyl.forceNewTab = event.ctrlKey || event.shiftKey || event.button == 1;
return dactyl.commands[command](event);
});
} }
switch (key) { // TODO: Wouldn't multiple handlers be cleaner? --djk
case "<LeftMouse>": if (event.type == "click" && (event.target instanceof HTMLAnchorElement ||
event.preventDefault(); event.originalTarget.hasAttributeNS(NS, "command"))) {
openLink(dactyl.CURRENT_TAB);
return KILL; let command = event.originalTarget.getAttributeNS(NS, "command");
case "<MiddleMouse>": if (command && event.button == 2)
case "<C-LeftMouse>": return PASS;
case "<C-M-LeftMouse>":
openLink({ where: dactyl.NEW_TAB, background: true }); if (command && dactyl.commands[command]) {
return KILL; event.preventDefault();
case "<S-MiddleMouse>": return dactyl.withSavedValues(["forceNewTab"], function () {
case "<C-S-LeftMouse>": dactyl.forceNewTab = event.ctrlKey || event.shiftKey || event.button == 1;
case "<C-M-S-LeftMouse>": return dactyl.commands[command](event);
openLink({ where: dactyl.NEW_TAB, background: false }); });
return KILL; }
case "<S-LeftMouse>":
openLink(dactyl.NEW_WINDOW); switch (key) {
return KILL; 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);
} }
catch (e) {
if (event instanceof MouseEvent) util.reportError(e);
return KILL;
function atEnd(dir) !Buffer.isScrollable(elem, dir || 1);
if (!options["more"] || atEnd(1)) {
modes.pop();
events.feedkeys(key);
} }
else
commandline.updateMorePrompt(false, true);
return PASS; return PASS;
}, },

View File

@@ -53,16 +53,18 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}, },
observers: { observers: {
"dactyl-cleanup": function () { "dactyl-cleanup": function dactyl_cleanup() {
let modules = dactyl.modules; let modules = dactyl.modules;
for (let name in values(Object.getOwnPropertyNames(modules).reverse())) { for (let name in values(Object.getOwnPropertyNames(modules).reverse())) {
let mod = Object.getOwnPropertyDescriptor(modules, name).value; let mod = Object.getOwnPropertyDescriptor(modules, name).value;
if (mod instanceof Class) { if (mod instanceof Class) {
if ("cleanup" in mod) if ("cleanup" in mod)
mod.cleanup(); this.trapErrors(mod.cleanup, mod);
if ("destroy" in mod) if ("destroy" in mod)
mod.destroy(); this.trapErrors(mod.destroy, mod);
if ("INIT" in mod && "cleanup" in mod.INIT)
this.trapErrors(mod.cleanup, mod, dactyl, modules, window);
} }
} }
@@ -360,6 +362,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}, },
userEval: function (str, context, fileName, lineNumber) { userEval: function (str, context, fileName, lineNumber) {
if (jsmodules.__proto__ != window)
str = "with (window) { with (modules) { (this.eval || eval)(" + str.quote() + ") } }";
if (fileName == null) if (fileName == null)
if (io.sourcing && io.sourcing.file[0] !== "[") if (io.sourcing && io.sourcing.file[0] !== "[")
({ file: fileName, line: lineNumber }) = io.sourcing; ({ file: fileName, line: lineNumber }) = io.sourcing;
@@ -389,9 +394,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
if (!context) if (!context)
context = _userContext; context = _userContext;
if (window.isPrototypeOf(modules)) return Cu.evalInSandbox(str, context, "1.8", fileName, lineNumber);
return Cu.evalInSandbox(str, context, "1.8", fileName, lineNumber);
return Cu.evalInSandbox("with (window) { with (modules) { this.eval(" + str.quote() + ") } }", context, "1.8", fileName, lineNumber);
}, },
/** /**
@@ -505,7 +508,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
* @param {string} feature The feature name. * @param {string} feature The feature name.
* @returns {boolean} * @returns {boolean}
*/ */
has: function (feature) config.features.indexOf(feature) >= 0, has: function (feature) set.has(config.features, feature),
/** /**
* Returns the URL of the specified help *topic* if it exists. * Returns the URL of the specified help *topic* if it exists.
@@ -2178,7 +2181,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
let init = services.environment.get(config.idName + "_INIT"); let init = services.environment.get(config.idName + "_INIT");
let rcFile = io.getRCFile("~"); let rcFile = io.getRCFile("~");
if (dactyl.userEval('typeof document') === "undefined") if (dactyl.userEval("typeof document", null, "test.js") === "undefined")
jsmodules.__proto__ = XPCSafeJSObjectWrapper(window); jsmodules.__proto__ = XPCSafeJSObjectWrapper(window);
try { try {

View File

@@ -175,6 +175,9 @@ var Modes = Module("modes", {
} }
}); });
}, },
cleanup: function () {
modes.reset();
},
_getModeMessage: function () { _getModeMessage: function () {
// when recording a macro // when recording a macro

View File

@@ -489,6 +489,7 @@ function call(fn) {
*/ */
function memoize(obj, key, getter) { function memoize(obj, key, getter) {
if (arguments.length == 1) { if (arguments.length == 1) {
obj = update({}, obj);
for (let prop in Object.getOwnPropertyNames(obj)) { for (let prop in Object.getOwnPropertyNames(obj)) {
let get = objproto.__lookupGetter__.call(obj, prop); let get = objproto.__lookupGetter__.call(obj, prop);
if (get) if (get)
@@ -737,9 +738,9 @@ Class.memoize = function memoize(getter)
configurable: true, configurable: true,
enumerable: true, enumerable: true,
init: function (key) { init: function (key) {
this.get = function replace() ( this.get = function replace() let (obj = this.instance || this) (
Class.replaceProperty(this, key, null), Class.replaceProperty(obj, key, null),
Class.replaceProperty(this, key, getter.call(this, key))) Class.replaceProperty(obj, key, getter.call(this, key)))
} }
}); });
@@ -1196,6 +1197,9 @@ update(iter, {
return undefined; return undefined;
}, },
sort: function sort(iter, fn, self)
array(this.toArray(iter).sort(fn, self)),
uniq: function uniq(iter) { uniq: function uniq(iter) {
let seen = {}; let seen = {};
for (let item in iter) for (let item in iter)

View File

@@ -4,8 +4,6 @@
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
"use strict"; "use strict";
dump(" ======================= bootstrap.jsm " + (typeof JSMLoader) + " ======================= \n");
var EXPORTED_SYMBOLS = ["JSMLoader"]; var EXPORTED_SYMBOLS = ["JSMLoader"];
let global = this; let global = this;

View File

@@ -36,14 +36,17 @@ var ConfigBase = Class("ConfigBase", {
} }
]]>); ]]>);
this.features.push = deprecated("set.add", function push(feature) set.add(this, feature));
if (util.haveGecko("2b")) if (util.haveGecko("2b"))
this.features.push("Gecko2"); set.add(this.features, "Gecko2");
this.timeout(function () { this.timeout(function () {
services["dactyl:"].pages.dtd = function () [null, services["dactyl:"].pages.dtd = function () [null,
iter(config.dtdExtra, (["dactyl." + s, config[s]] for each (s in config.dtdStrings))) iter(config.dtdExtra,
.map(function ([k, v]) ["<!ENTITY ", k, " '", String.replace(v, /'/g, "&apos;"), "'>"].join("")) (["dactyl." + k, v] for ([k, v] in iter(config.dtd))),
.join("\n")] (["dactyl." + s, config[s]] for each (s in config.dtdStrings)))
.map(function ([k, v]) ["<!ENTITY ", k, " '", String.replace(v, /'/g, "&apos;"), "'>"].join(""))
.join("\n")]
}); });
}, },
@@ -119,17 +122,20 @@ var ConfigBase = Class("ConfigBase", {
return version; return version;
}), }),
// TODO: DTD properties. Cleanup. dtd: memoize({
get home() "http://dactyl.sourceforge.net/", get home() "http://dactyl.sourceforge.net/",
get apphome() this.home + this.name, get apphome() this.home + this.name,
code: "http://code.google.com/p/dactyl/", code: "http://code.google.com/p/dactyl/",
get issues() this.home + "bug/" + this.name, get issues() this.home + "bug/" + this.name,
get plugins() "http://dactyl.sf.net/" + this.name + "/plugins", get plugins() "http://dactyl.sf.net/" + this.name + "/plugins",
get faq() this.home + this.name + "/faq", get faq() this.home + this.name + "/faq",
"list.mailto": Class.memoize(function () config.name + "@googlegroups.com"),
"list.href": Class.memoize(function () "http://groups.google.com/group/" + config.name), "list.mailto": Class.memoize(function () config.name + "@googlegroups.com"),
"hg.latest": Class.memoize(function () config.code + "source/browse/"), // XXX "list.href": Class.memoize(function () "http://groups.google.com/group/" + config.name),
"irc": "irc://irc.oftc.net/#pentadactyl",
"hg.latest": Class.memoize(function () this.code + "source/browse/"), // XXX
"irc": "irc://irc.oftc.net/#pentadactyl",
}),
dtdExtra: { dtdExtra: {
"xmlns.dactyl": "http://vimperator.org/namespaces/liberator", "xmlns.dactyl": "http://vimperator.org/namespaces/liberator",
@@ -142,21 +148,11 @@ var ConfigBase = Class("ConfigBase", {
dtdStrings: [ dtdStrings: [
"appName", "appName",
"apphome",
"code",
"faq",
"fileExt", "fileExt",
"hg.latest",
"home",
"host", "host",
"hostbin", "hostbin",
"idName", "idName",
"irc",
"issues",
"list.href",
"list.mailto",
"name", "name",
"plugins",
"version" "version"
], ],
@@ -208,11 +204,11 @@ var ConfigBase = Class("ConfigBase", {
}), }),
/** /**
* @property {[["string", "string"]]} A sequence of names and descriptions * @property {Object} A mapping of names and descriptions
* of the autocommands available in this application. Primarily used * of the autocommands available in this application. Primarily used
* for completion results. * for completion results.
*/ */
autocommands: [], autocommands: {},
commandContainer: "browser-bottombox", commandContainer: "browser-bottombox",
@@ -262,23 +258,22 @@ var ConfigBase = Class("ConfigBase", {
cleanups: {}, cleanups: {},
/** /**
* @property {[["string", "string", "function"]]} An array of * @property {Object} A map of dialogs available via the
* dialogs available via the :dialog command. * :dialog command. Property names map dialog names to an array
* [0] name - The name of the dialog, used as the first * as follows:
* argument to :dialog. * [0] description - A description of the dialog, used in
* [1] description - A description of the dialog, used in
* command completion results for :dialog. * command completion results for :dialog.
* [2] action - The function executed by :dialog. * [1] action - The function executed by :dialog.
*/ */
dialogs: [], dialogs: {},
/** /**
* @property {string[]} A list of features available in this * @property {set} A list of features available in this
* application. Used extensively in feature test macros. Use * application. Used extensively in feature test macros. Use
* dactyl.has(feature) to check for a feature's presence * dactyl.has(feature) to check for a feature's presence
* in this array. * in this array.
*/ */
features: [], features: {},
/** /**
* @property {string} The file extension used for command script files. * @property {string} The file extension used for command script files.
@@ -426,9 +421,16 @@ var ConfigBase = Class("ConfigBase", {
Keyword color: red; Keyword color: red;
Tag color: blue; Tag color: blue;
Usage position: relative; padding-right: 2em; Link position: relative; padding-right: 2em;
Usage>LineInfo position: absolute; left: 100%; padding: 1ex; margin: -1ex -1em; background: rgba(255, 255, 255, .8); border-radius: 1ex; Link:not(:hover)>LinkInfo opacity: 0; left: 0; width: 1px; height: 1px; overflow: hidden;
Usage:not(:hover)>LineInfo opacity: 0; left: 0; width: 1px; height: 1px; overflow: hidden; LinkInfo {
position: absolute;
left: 100%;
padding: 1ex;
margin: -1ex -1em;
background: rgba(255, 255, 255, .8);
border-radius: 1ex;
}
StatusLine;;;FontFixed { StatusLine;;;FontFixed {
-moz-appearance: none !important; -moz-appearance: none !important;

View File

@@ -92,7 +92,8 @@ var Highlights = Module("Highlight", {
keys: function keys() Object.keys(this.highlight).sort(), keys: function keys() Object.keys(this.highlight).sort(),
__iterator__: function () values(this.highlight), __iterator__: function () values(this.highlight).sort(function (a, b) String.localeCompare(a.class, b.class))
.iterValues(),
_create: function (agent, args) { _create: function (agent, args) {
let obj = Highlight.apply(Highlight, args); let obj = Highlight.apply(Highlight, args);
@@ -318,7 +319,7 @@ var Highlights = Module("Highlight", {
if (!modify) if (!modify)
modules.commandline.commandOutput( modules.commandline.commandOutput(
template.tabular(["Key", "Sample", "Link", "CSS"], template.tabular(["Key", "Sample", "Link", "CSS"],
["padding: 0 1em 0 0; vertical-align: top", ["padding: 0 1em 0 0; vertical-align: top; max-width: 16em; overflow: hidden;",
"text-align: center"], "text-align: center"],
([h.class, ([h.class,
<span style={"text-align: center; line-height: 1em;" + h.value + style}>XXX</span>, <span style={"text-align: center; line-height: 1em;" + h.value + style}>XXX</span>,

View File

@@ -79,6 +79,7 @@ var Services = Module("Services", {
[Ci.nsIChannel, Ci.nsIInputStreamChannel, Ci.nsIRequest], "setURI"); [Ci.nsIChannel, Ci.nsIInputStreamChannel, Ci.nsIRequest], "setURI");
this.addClass("String", "@mozilla.org/supports-string;1", Ci.nsISupportsString, "data"); this.addClass("String", "@mozilla.org/supports-string;1", Ci.nsISupportsString, "data");
this.addClass("StringStream", "@mozilla.org/io/string-input-stream;1", Ci.nsIStringInputStream, "data"); this.addClass("StringStream", "@mozilla.org/io/string-input-stream;1", Ci.nsIStringInputStream, "data");
this.addClass("Transfer", "@mozilla.org/transfer;1", Ci.nsITransfer, "init");
this.addClass("Timer", "@mozilla.org/timer;1", Ci.nsITimer, "initWithCallback"); this.addClass("Timer", "@mozilla.org/timer;1", Ci.nsITimer, "initWithCallback");
this.addClass("StreamCopier", "@mozilla.org/network/async-stream-copier;1",Ci.nsIAsyncStreamCopier, "init"); this.addClass("StreamCopier", "@mozilla.org/network/async-stream-copier;1",Ci.nsIAsyncStreamCopier, "init");
this.addClass("Xmlhttp", "@mozilla.org/xmlextras/xmlhttprequest;1", Ci.nsIXMLHttpRequest); this.addClass("Xmlhttp", "@mozilla.org/xmlextras/xmlhttprequest;1", Ci.nsIXMLHttpRequest);
@@ -113,10 +114,11 @@ var Services = Module("Services", {
} }
["aboutURL", "creator", "description", "developers", ["aboutURL", "creator", "description", "developers",
"homepageURL", "iconURL", "installDate", "homepageURL", "installDate", "optionsURL",
"optionsURL", "releaseNotesURI", "updateDate", "version"].forEach(function (item) { "releaseNotesURI", "updateDate"].forEach(function (item) {
addon[item] = getRdfProperty(addon, item); memoize(addon, item, function (item) getRdfProperty(this, item));
}); });
update(addon, { update(addon, {
appDisabled: false, appDisabled: false,
@@ -147,7 +149,7 @@ var Services = Module("Services", {
for (let [, item] in Iterator(services.extensionManager for (let [, item] in Iterator(services.extensionManager
.getItemList(Ci.nsIUpdateItem["TYPE_" + type.toUpperCase()], {}))) .getItemList(Ci.nsIUpdateItem["TYPE_" + type.toUpperCase()], {})))
res.push(this.getAddonByID(item)); res.push(this.getAddonByID(item));
callback(res); return (callback || util.identity)(res);
}, },
getInstallForFile: function (file, callback, mimetype) { getInstallForFile: function (file, callback, mimetype) {
callback({ callback({
@@ -206,14 +208,7 @@ var Services = Module("Services", {
const self = this; const self = this;
if (name in this && ifaces && !this.__lookupGetter__(name) && !(this[name] instanceof Ci.nsISupports)) if (name in this && ifaces && !this.__lookupGetter__(name) && !(this[name] instanceof Ci.nsISupports))
throw TypeError(); throw TypeError();
this.__defineGetter__(name, function () { memoize(this, name, function () self._create(class_, ifaces, meth));
let res = self._create(class_, ifaces, meth);
if (!res)
return null;
delete this[name];
return this[name] = res;
});
}, },
/** /**

View File

@@ -259,9 +259,15 @@ var Storage = Module("Storage", {
} }
}, { }, {
}, { }, {
init: function (dactyl, modules) { init: function init(dactyl, modules) {
init.superapply(this, arguments);
storage.infoPath = File(modules.IO.runtimePath.replace(/,.*/, "")) storage.infoPath = File(modules.IO.runtimePath.replace(/,.*/, ""))
.child("info").child(dactyl.profileName); .child("info").child(dactyl.profileName);
},
cleanup: function (dactyl, modules, window) {
delete window.dactylStorageRefs;
this.removeDeadObservers();
} }
}); });

View File

@@ -262,12 +262,13 @@ var Template = Module("Template", {
sourceLink: function (frame) { sourceLink: function (frame) {
let url = (frame.filename || "unknown").replace(/.* -> /, ""); let url = (frame.filename || "unknown").replace(/.* -> /, "");
let path = util.urlPath(url);
XML.ignoreWhitespace = false; XML.prettyPrinting = false; XML.ignoreWhitespace = false; XML.prettyPrinting = false;
return <a xmlns:dactyl={NS} dactyl:command="buffer.viewSource" return <a xmlns:dactyl={NS} dactyl:command="buffer.viewSource"
href={url} line={frame.lineNumber} href={url} path={path} line={frame.lineNumber}
highlight="URL">{ highlight="URL">{
util.urlPath(url) + ":" + frame.lineNumber path + ":" + frame.lineNumber
}</a> }</a>
}, },
@@ -331,11 +332,11 @@ var Template = Module("Template", {
this.map(iter, function (item) this.map(iter, function (item)
<tr> <tr>
<td style="padding-right: 2em;"> <td style="padding-right: 2em;">
<span highlight="Usage">{ <span highlight="Usage Link">{
let (name = item.name || item.names[0], frame = item.definedAt) let (name = item.name || item.names[0], frame = item.definedAt)
!frame ? name : !frame ? name :
template.helpLink(help(item), name, "Title") + template.helpLink(help(item), name, "Title") +
<span highlight="LineInfo" xmlns:dactyl={NS}>Defined at {sourceLink(frame)}</span> <span highlight="LinkInfo" xmlns:dactyl={NS}>Defined at {sourceLink(frame)}</span>
}</span> }</span>
</td> </td>
<td>{desc(item)}</td> <td>{desc(item)}</td>

View File

@@ -135,6 +135,13 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
throw FailedAssertion(message, 1); throw FailedAssertion(message, 1);
}, },
/**
* Capitalizes the first character of the given string.
* @param {string} str The string to capitalize
* @returns {string}
*/
capitalize: function capitalize(str) str && str[0].toUpperCase() + str.slice(1),
/** /**
* Returns a RegExp object that matches characters specified in the range * Returns a RegExp object that matches characters specified in the range
* expression *list*, or signals an appropriate error if *list* is invalid. * expression *list*, or signals an appropriate error if *list* is invalid.
@@ -499,9 +506,10 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
stackLines: function (stack) { stackLines: function (stack) {
let lines = []; let lines = [];
let match, re = /([^]*?)(@[^@\n]*)(?:\n|$)/g; let match, re = /([^]*?)@([^@\n]*)(?:\n|$)/g;
while (match = re.exec(stack)) while (match = re.exec(stack))
lines.push(match[1].replace(/\n/g, "\\n").substr(0, 80) + match[2]); lines.push(match[1].replace(/\n/g, "\\n").substr(0, 80) + "@" +
match[2].replace(/.* -> /, ""));
return lines; return lines;
}, },
@@ -653,6 +661,28 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
return strNum[0] + " " + unitVal[unitIndex]; return strNum[0] + " " + unitVal[unitIndex];
}, },
/**
* Converts *seconds* into a human readable time string.
*
* @param {number} seconds
* @returns {string}
*/
formatSeconds: function formatSeconds(seconds) {
function div(num, denom) [Math.round(num / denom), Math.round(num % denom)];
let days, hours, minutes;
[minutes, seconds] = div(seconds, 60);
[hours, minutes] = div(minutes, 60);
[days, hours] = div(hours, 24);
if (days)
return days + " days " + hours + " hours"
if (hours)
return hours + "h " + minutes + "m";
if (minutes)
return minutes + ":" + seconds;
return seconds + "s";
},
/** /**
* Returns the file which backs a given URL, if available. * Returns the file which backs a given URL, if available.
* *

View File

@@ -135,10 +135,10 @@ var Config = Module("config", ConfigBase, {
titlestring: "Pentadactyl" titlestring: "Pentadactyl"
}, },
features: [ features: set([
"bookmarks", "hints", "history", "marks", "quickmarks", "sanitizer", "bookmarks", "hints", "history", "marks", "quickmarks", "sanitizer",
"session", "tabs", "tabs_undo", "windows" "session", "tabs", "tabs_undo", "windows"
], ]),
guioptions: { guioptions: {
m: ["Menubar", ["toolbar-menubar"]], m: ["Menubar", ["toolbar-menubar"]],