mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-19 22:17:59 +01:00
Add dom.jsm. And stuff.
This commit is contained in:
24
common/bootstrap.js
vendored
24
common/bootstrap.js
vendored
@@ -34,11 +34,15 @@ const BOOTSTRAP_JSM = "resource://dactyl/bootstrap.jsm";
|
|||||||
const BOOTSTRAP_CONTRACT = "@dactyl.googlecode.com/base/bootstrap";
|
const BOOTSTRAP_CONTRACT = "@dactyl.googlecode.com/base/bootstrap";
|
||||||
|
|
||||||
var JSMLoader = BOOTSTRAP_CONTRACT in Cc && Cc[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader;
|
var JSMLoader = BOOTSTRAP_CONTRACT in Cc && Cc[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader;
|
||||||
|
var name = "dactyl";
|
||||||
|
|
||||||
function reportError(e) {
|
function reportError(e) {
|
||||||
dump("\ndactyl: bootstrap: " + e + "\n" + (e.stack || Error().stack) + "\n");
|
dump("\n" + name + ": bootstrap: " + e + "\n" + (e.stack || Error().stack) + "\n");
|
||||||
Cu.reportError(e);
|
Cu.reportError(e);
|
||||||
}
|
}
|
||||||
|
function debug(msg) {
|
||||||
|
dump(name + ": " + msg + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
function httpGet(url) {
|
function httpGet(url) {
|
||||||
let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
|
let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
|
||||||
@@ -86,16 +90,17 @@ function updateVersion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startup(data, reason) {
|
function startup(data, reason) {
|
||||||
dump("dactyl: bootstrap: startup " + reasonToString(reason) + "\n");
|
debug("bootstrap: startup " + reasonToString(reason));
|
||||||
basePath = data.installPath;
|
basePath = data.installPath;
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
dump("dactyl: bootstrap: init" + " " + data.id + "\n");
|
debug("bootstrap: init" + " " + data.id);
|
||||||
|
|
||||||
addonData = data;
|
addonData = data;
|
||||||
addon = data;
|
addon = data;
|
||||||
|
name = data.id.replace(/@.*/, "");
|
||||||
AddonManager.getAddonByID(addon.id, function (a) {
|
AddonManager.getAddonByID(addon.id, function (a) {
|
||||||
addon = a;
|
addon = a;
|
||||||
updateVersion();
|
updateVersion();
|
||||||
@@ -138,12 +143,12 @@ function FactoryProxy(url, classID) {
|
|||||||
FactoryProxy.prototype = {
|
FactoryProxy.prototype = {
|
||||||
QueryInterface: XPCOMUtils.generateQI(Ci.nsIFactory),
|
QueryInterface: XPCOMUtils.generateQI(Ci.nsIFactory),
|
||||||
register: function () {
|
register: function () {
|
||||||
dump("dactyl: bootstrap: register: " + this.classID + " " + this.contractID + "\n");
|
debug("bootstrap: register: " + this.classID + " " + this.contractID);
|
||||||
|
|
||||||
JSMLoader.registerFactory(this);
|
JSMLoader.registerFactory(this);
|
||||||
},
|
},
|
||||||
get module() {
|
get module() {
|
||||||
dump("dactyl: bootstrap: create module: " + this.contractID + "\n");
|
debug("bootstrap: create module: " + this.contractID);
|
||||||
|
|
||||||
Object.defineProperty(this, "module", { value: {}, enumerable: true });
|
Object.defineProperty(this, "module", { value: {}, enumerable: true });
|
||||||
JSMLoader.load(this.url, this.module);
|
JSMLoader.load(this.url, this.module);
|
||||||
@@ -156,7 +161,7 @@ FactoryProxy.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
dump("dactyl: bootstrap: init\n");
|
debug("bootstrap: init");
|
||||||
|
|
||||||
let manifestURI = getURI("chrome.manifest");
|
let manifestURI = getURI("chrome.manifest");
|
||||||
let manifest = httpGet(manifestURI.spec)
|
let manifest = httpGet(manifestURI.spec)
|
||||||
@@ -227,6 +232,7 @@ function init() {
|
|||||||
if (!JSMLoader || JSMLoader.bump !== 6 || Cu.unload)
|
if (!JSMLoader || JSMLoader.bump !== 6 || Cu.unload)
|
||||||
Cu.import(BOOTSTRAP_JSM, global);
|
Cu.import(BOOTSTRAP_JSM, global);
|
||||||
|
|
||||||
|
JSMLoader.name = name;
|
||||||
JSMLoader.bootstrap = this;
|
JSMLoader.bootstrap = this;
|
||||||
|
|
||||||
JSMLoader.load(BOOTSTRAP_JSM, global);
|
JSMLoader.load(BOOTSTRAP_JSM, global);
|
||||||
@@ -262,7 +268,7 @@ function init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shutdown(data, reason) {
|
function shutdown(data, reason) {
|
||||||
dump("dactyl: bootstrap: shutdown " + reasonToString(reason) + "\n");
|
debug("bootstrap: shutdown " + reasonToString(reason));
|
||||||
if (reason != APP_SHUTDOWN) {
|
if (reason != APP_SHUTDOWN) {
|
||||||
try {
|
try {
|
||||||
module("resource://dactyl-content/disable-acr.jsm").cleanup();
|
module("resource://dactyl-content/disable-acr.jsm").cleanup();
|
||||||
@@ -286,7 +292,7 @@ function shutdown(data, reason) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function uninstall(data, reason) {
|
function uninstall(data, reason) {
|
||||||
dump("dactyl: bootstrap: uninstall " + reasonToString(reason) + "\n");
|
debug("bootstrap: uninstall " + reasonToString(reason));
|
||||||
if (reason == ADDON_UNINSTALL)
|
if (reason == ADDON_UNINSTALL)
|
||||||
Services.prefs.deleteBranch("extensions.dactyl.");
|
Services.prefs.deleteBranch("extensions.dactyl.");
|
||||||
}
|
}
|
||||||
@@ -300,6 +306,6 @@ function reasonToString(reason) {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function install(data, reason) { dump("dactyl: bootstrap: install " + reasonToString(reason) + "\n"); }
|
function install(data, reason) { debug("bootstrap: install " + reasonToString(reason)); }
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4 et:
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
var AutoCommand = Struct("event", "filter", "command");
|
var AutoCommand = Struct("event", "filter", "command");
|
||||||
update(AutoCommand.prototype, {
|
update(AutoCommand.prototype, {
|
||||||
eventName: Class.memoize(function () this.event.toLowerCase()),
|
eventName: Class.Memoize(function () this.event.toLowerCase()),
|
||||||
|
|
||||||
match: function (event, pattern) {
|
match: function (event, pattern) {
|
||||||
return (!event || this.eventName == event.toLowerCase()) && (!pattern || String(this.filter) === String(pattern));
|
return (!event || this.eventName == event.toLowerCase()) && (!pattern || String(this.filter) === String(pattern));
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ var Bookmarks = Module("bookmarks", {
|
|||||||
return bookmarks.get(args.join(" "), args["-tags"], null, { keyword: context.filter, title: args["-title"] });
|
return bookmarks.get(args.join(" "), args["-tags"], null, { keyword: context.filter, title: args["-title"] });
|
||||||
},
|
},
|
||||||
type: CommandOption.STRING,
|
type: CommandOption.STRING,
|
||||||
validator: function (arg) /^\S+$/.test(arg)
|
validator: bind("test", /^\S+$/)
|
||||||
};
|
};
|
||||||
|
|
||||||
commands.add(["bma[rk]"],
|
commands.add(["bma[rk]"],
|
||||||
|
|||||||
@@ -1184,8 +1184,8 @@ var Buffer = Module("buffer", {
|
|||||||
PageInfo: Struct("PageInfo", "name", "title", "action")
|
PageInfo: Struct("PageInfo", "name", "title", "action")
|
||||||
.localize("title"),
|
.localize("title"),
|
||||||
|
|
||||||
ZOOM_MIN: Class.memoize(function () prefs.get("zoom.minPercent")),
|
ZOOM_MIN: Class.Memoize(function () prefs.get("zoom.minPercent")),
|
||||||
ZOOM_MAX: Class.memoize(function () prefs.get("zoom.maxPercent")),
|
ZOOM_MAX: Class.Memoize(function () prefs.get("zoom.maxPercent")),
|
||||||
|
|
||||||
setZoom: deprecated("buffer.setZoom", function setZoom() buffer.setZoom.apply(buffer, arguments)),
|
setZoom: deprecated("buffer.setZoom", function setZoom() buffer.setZoom.apply(buffer, arguments)),
|
||||||
bumpZoomLevel: deprecated("buffer.bumpZoomLevel", function bumpZoomLevel() buffer.bumpZoomLevel.apply(buffer, arguments)),
|
bumpZoomLevel: deprecated("buffer.bumpZoomLevel", function bumpZoomLevel() buffer.bumpZoomLevel.apply(buffer, arguments)),
|
||||||
|
|||||||
@@ -252,10 +252,10 @@ var CommandWidgets = Class("CommandWidgets", {
|
|||||||
[this.commandbar.container, this.statusbar.container].forEach(check);
|
[this.commandbar.container, this.statusbar.container].forEach(check);
|
||||||
},
|
},
|
||||||
|
|
||||||
active: Class.memoize(Object),
|
active: Class.Memoize(Object),
|
||||||
activeGroup: Class.memoize(Object),
|
activeGroup: Class.Memoize(Object),
|
||||||
commandbar: Class.memoize(function () ({ group: "Cmd" })),
|
commandbar: Class.Memoize(function () ({ group: "Cmd" })),
|
||||||
statusbar: Class.memoize(function () ({ group: "Status" })),
|
statusbar: Class.Memoize(function () ({ group: "Status" })),
|
||||||
|
|
||||||
_ready: function _ready(elem) {
|
_ready: function _ready(elem) {
|
||||||
return elem.contentDocument.documentURI === elem.getAttribute("src") &&
|
return elem.contentDocument.documentURI === elem.getAttribute("src") &&
|
||||||
@@ -272,9 +272,9 @@ var CommandWidgets = Class("CommandWidgets", {
|
|||||||
yield elem;
|
yield elem;
|
||||||
},
|
},
|
||||||
|
|
||||||
completionContainer: Class.memoize(function () this.completionList.parentNode),
|
completionContainer: Class.Memoize(function () this.completionList.parentNode),
|
||||||
|
|
||||||
contextMenu: Class.memoize(function () {
|
contextMenu: Class.Memoize(function () {
|
||||||
["copy", "copylink", "selectall"].forEach(function (tail) {
|
["copy", "copylink", "selectall"].forEach(function (tail) {
|
||||||
// some host apps use "hostPrefixContext-copy" ids
|
// some host apps use "hostPrefixContext-copy" ids
|
||||||
let xpath = "//xul:menuitem[contains(@id, '" + "ontext-" + tail + "') and not(starts-with(@id, 'dactyl-'))]";
|
let xpath = "//xul:menuitem[contains(@id, '" + "ontext-" + tail + "') and not(starts-with(@id, 'dactyl-'))]";
|
||||||
@@ -284,15 +284,15 @@ var CommandWidgets = Class("CommandWidgets", {
|
|||||||
return document.getElementById("dactyl-contextmenu");
|
return document.getElementById("dactyl-contextmenu");
|
||||||
}),
|
}),
|
||||||
|
|
||||||
multilineOutput: Class.memoize(function () this._whenReady("dactyl-multiline-output", function (elem) {
|
multilineOutput: Class.Memoize(function () this._whenReady("dactyl-multiline-output", function (elem) {
|
||||||
elem.contentWindow.addEventListener("unload", function (event) { event.preventDefault(); }, true);
|
elem.contentWindow.addEventListener("unload", function (event) { event.preventDefault(); }, true);
|
||||||
elem.contentDocument.documentElement.id = "dactyl-multiline-output-top";
|
elem.contentDocument.documentElement.id = "dactyl-multiline-output-top";
|
||||||
elem.contentDocument.body.id = "dactyl-multiline-output-content";
|
elem.contentDocument.body.id = "dactyl-multiline-output-content";
|
||||||
}), true),
|
}), true),
|
||||||
|
|
||||||
multilineInput: Class.memoize(function () document.getElementById("dactyl-multiline-input")),
|
multilineInput: Class.Memoize(function () document.getElementById("dactyl-multiline-input")),
|
||||||
|
|
||||||
mowContainer: Class.memoize(function () document.getElementById("dactyl-multiline-output-container"))
|
mowContainer: Class.Memoize(function () document.getElementById("dactyl-multiline-output-container"))
|
||||||
}, {
|
}, {
|
||||||
getEditor: function getEditor(elem) {
|
getEditor: function getEditor(elem) {
|
||||||
elem.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
|
elem.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
|
||||||
@@ -584,7 +584,7 @@ var CommandLine = Module("commandline", {
|
|||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
widgets: Class.memoize(function () CommandWidgets()),
|
widgets: Class.Memoize(function () CommandWidgets()),
|
||||||
|
|
||||||
runSilently: function runSilently(func, self) {
|
runSilently: function runSilently(func, self) {
|
||||||
this.withSavedValues(["silent"], function () {
|
this.withSavedValues(["silent"], function () {
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/** @property {string} The name of the current user profile. */
|
/** @property {string} The name of the current user profile. */
|
||||||
profileName: Class.memoize(function () {
|
profileName: Class.Memoize(function () {
|
||||||
// NOTE: services.profile.selectedProfile.name doesn't return
|
// NOTE: services.profile.selectedProfile.name doesn't return
|
||||||
// what you might expect. It returns the last _actively_ selected
|
// what you might expect. It returns the last _actively_ selected
|
||||||
// profile (i.e. via the Profile Manager or -P option) rather than the
|
// profile (i.e. via the Profile Manager or -P option) rather than the
|
||||||
@@ -1221,7 +1221,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
stringToURLArray: deprecated("dactyl.parseURLs", "parseURLs"),
|
stringToURLArray: deprecated("dactyl.parseURLs", "parseURLs"),
|
||||||
urlish: Class.memoize(function () util.regexp(<![CDATA[
|
urlish: Class.Memoize(function () util.regexp(<![CDATA[
|
||||||
^ (
|
^ (
|
||||||
<domain>+ (:\d+)? (/ .*) |
|
<domain>+ (:\d+)? (/ .*) |
|
||||||
<domain>+ (:\d+) |
|
<domain>+ (:\d+) |
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
this.processors.unshift(KeyProcessor(modes.BASE, hive));
|
this.processors.unshift(KeyProcessor(modes.BASE, hive));
|
||||||
},
|
},
|
||||||
|
|
||||||
passUnknown: Class.memoize(function () options.get("passunknown").getKey(this.modes)),
|
passUnknown: Class.Memoize(function () options.get("passunknown").getKey(this.modes)),
|
||||||
|
|
||||||
notify: function () {
|
notify: function () {
|
||||||
events.dbg("NOTIFY()");
|
events.dbg("NOTIFY()");
|
||||||
|
|||||||
@@ -1103,7 +1103,7 @@ var Hints = Module("hints", {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
translitTable: Class.memoize(function () {
|
translitTable: Class.Memoize(function () {
|
||||||
const table = {};
|
const table = {};
|
||||||
[
|
[
|
||||||
[0x00c0, 0x00c6, ["A"]], [0x00c7, 0x00c7, ["C"]],
|
[0x00c0, 0x00c6, ["A"]], [0x00c7, 0x00c7, ["C"]],
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ var History = Module("history", {
|
|||||||
for (let item in iter(sh.SHistoryEnumerator, Ci.nsIHistoryEntry))
|
for (let item in iter(sh.SHistoryEnumerator, Ci.nsIHistoryEntry))
|
||||||
obj.push(update(Object.create(item), {
|
obj.push(update(Object.create(item), {
|
||||||
index: obj.length,
|
index: obj.length,
|
||||||
icon: Class.memoize(function () services.favicon.getFaviconImageForPage(this.URI).spec)
|
icon: Class.Memoize(function () services.favicon.getFaviconImageForPage(this.URI).spec)
|
||||||
}));
|
}));
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ var Map = Class("Map", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
name: Class.memoize(function () this.names[0]),
|
name: Class.Memoize(function () this.names[0]),
|
||||||
|
|
||||||
/** @property {[string]} All of this mapping's names (key sequences). */
|
/** @property {[string]} All of this mapping's names (key sequences). */
|
||||||
names: Class.memoize(function () this._keys.map(function (k) events.canonicalKeys(k))),
|
names: Class.Memoize(function () this._keys.map(function (k) events.canonicalKeys(k))),
|
||||||
|
|
||||||
get toStringParams() [this.modes.map(function (m) m.name), this.names.map(String.quote)],
|
get toStringParams() [this.modes.map(function (m) m.name), this.names.map(String.quote)],
|
||||||
|
|
||||||
@@ -293,7 +293,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
|
|||||||
delete this.states;
|
delete this.states;
|
||||||
},
|
},
|
||||||
|
|
||||||
states: Class.memoize(function () {
|
states: Class.Memoize(function () {
|
||||||
var states = {
|
var states = {
|
||||||
candidates: {},
|
candidates: {},
|
||||||
mappings: {}
|
mappings: {}
|
||||||
@@ -329,7 +329,7 @@ var Mappings = Module("mappings", {
|
|||||||
|
|
||||||
expandLeader: function expandLeader(keyString) keyString.replace(/<Leader>/i, function () options["mapleader"]),
|
expandLeader: function expandLeader(keyString) keyString.replace(/<Leader>/i, function () options["mapleader"]),
|
||||||
|
|
||||||
prefixes: Class.memoize(function () {
|
prefixes: Class.Memoize(function () {
|
||||||
let list = Array.map("CASM", function (s) s + "-");
|
let list = Array.map("CASM", function (s) s + "-");
|
||||||
|
|
||||||
return iter(util.range(0, 1 << list.length)).map(function (mask)
|
return iter(util.range(0, 1 << list.length)).map(function (mask)
|
||||||
|
|||||||
@@ -297,9 +297,9 @@ var Marks = Module("marks", {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
isLocalMark: function isLocalMark(mark) /^[a-z`']$/.test(mark),
|
isLocalMark: bind("test", /^[a-z`']$/),
|
||||||
|
|
||||||
isURLMark: function isURLMark(mark) /^[A-Z]$/.test(mark)
|
isURLMark: bind("test", /^[A-Z]$/)
|
||||||
}, {
|
}, {
|
||||||
events: function () {
|
events: function () {
|
||||||
let appContent = document.getElementById("appcontent");
|
let appContent = document.getElementById("appcontent");
|
||||||
|
|||||||
@@ -508,12 +508,12 @@ var Modes = Module("modes", {
|
|||||||
|
|
||||||
description: Messages.Localized(""),
|
description: Messages.Localized(""),
|
||||||
|
|
||||||
displayName: Class.memoize(function () this.name.split("_").map(util.capitalize).join(" ")),
|
displayName: Class.Memoize(function () this.name.split("_").map(util.capitalize).join(" ")),
|
||||||
|
|
||||||
isinstance: function isinstance(obj)
|
isinstance: function isinstance(obj)
|
||||||
this.allBases.indexOf(obj) >= 0 || callable(obj) && this instanceof obj,
|
this.allBases.indexOf(obj) >= 0 || callable(obj) && this instanceof obj,
|
||||||
|
|
||||||
allBases: Class.memoize(function () {
|
allBases: Class.Memoize(function () {
|
||||||
let seen = {}, res = [], queue = [this].concat(this.bases);
|
let seen = {}, res = [], queue = [this].concat(this.bases);
|
||||||
for (let mode in array.iterValues(queue))
|
for (let mode in array.iterValues(queue))
|
||||||
if (!Set.add(seen, mode)) {
|
if (!Set.add(seen, mode)) {
|
||||||
@@ -527,7 +527,7 @@ var Modes = Module("modes", {
|
|||||||
|
|
||||||
get count() !this.insert,
|
get count() !this.insert,
|
||||||
|
|
||||||
_display: Class.memoize(function _display() this.name.replace("_", " ", "g")),
|
_display: Class.Memoize(function _display() this.name.replace("_", " ", "g")),
|
||||||
|
|
||||||
display: function display() this._display,
|
display: function display() this._display,
|
||||||
|
|
||||||
@@ -535,15 +535,15 @@ var Modes = Module("modes", {
|
|||||||
|
|
||||||
hidden: false,
|
hidden: false,
|
||||||
|
|
||||||
input: Class.memoize(function input() this.insert || this.bases.length && this.bases.some(function (b) b.input)),
|
input: Class.Memoize(function input() this.insert || this.bases.length && this.bases.some(function (b) b.input)),
|
||||||
|
|
||||||
insert: Class.memoize(function insert() this.bases.length && this.bases.some(function (b) b.insert)),
|
insert: Class.Memoize(function insert() this.bases.length && this.bases.some(function (b) b.insert)),
|
||||||
|
|
||||||
ownsFocus: Class.memoize(function ownsFocus() this.bases.length && this.bases.some(function (b) b.ownsFocus)),
|
ownsFocus: Class.Memoize(function ownsFocus() this.bases.length && this.bases.some(function (b) b.ownsFocus)),
|
||||||
|
|
||||||
passEvent: function passEvent(event) this.input && event.charCode && !(event.ctrlKey || event.altKey || event.metaKey),
|
passEvent: function passEvent(event) this.input && event.charCode && !(event.ctrlKey || event.altKey || event.metaKey),
|
||||||
|
|
||||||
passUnknown: Class.memoize(function () options.get("passunknown").getKey(this.name)),
|
passUnknown: Class.Memoize(function () options.get("passunknown").getKey(this.name)),
|
||||||
|
|
||||||
get mask() this,
|
get mask() this,
|
||||||
|
|
||||||
|
|||||||
@@ -81,9 +81,9 @@ var MOW = Module("mow", {
|
|||||||
__noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.body].concat(args)),
|
__noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.body].concat(args)),
|
||||||
|
|
||||||
get widget() this.widgets.multilineOutput,
|
get widget() this.widgets.multilineOutput,
|
||||||
widgets: Class.memoize(function widgets() commandline.widgets),
|
widgets: Class.Memoize(function widgets() commandline.widgets),
|
||||||
|
|
||||||
body: Class.memoize(function body() this.widget.contentDocument.documentElement),
|
body: Class.Memoize(function body() this.widget.contentDocument.documentElement),
|
||||||
get document() this.widget.contentDocument,
|
get document() this.widget.contentDocument,
|
||||||
get window() this.widget.contentWindow,
|
get window() this.widget.contentWindow,
|
||||||
|
|
||||||
|
|||||||
@@ -99,9 +99,9 @@ var QuickMarks = Module("quickmarks", {
|
|||||||
*/
|
*/
|
||||||
list: function list(filter) {
|
list: function list(filter) {
|
||||||
let marks = [k for ([k, v] in this._qmarks)];
|
let marks = [k for ([k, v] in this._qmarks)];
|
||||||
let lowercaseMarks = marks.filter(function (x) /[a-z]/.test(x)).sort();
|
let lowercaseMarks = marks.filter(bind("test", /[a-z]/)).sort();
|
||||||
let uppercaseMarks = marks.filter(function (x) /[A-Z]/.test(x)).sort();
|
let uppercaseMarks = marks.filter(bind("test", /[A-Z]/)).sort();
|
||||||
let numberMarks = marks.filter(function (x) /[0-9]/.test(x)).sort();
|
let numberMarks = marks.filter(bind("test", /[0-9]/)).sort();
|
||||||
|
|
||||||
marks = Array.concat(lowercaseMarks, uppercaseMarks, numberMarks);
|
marks = Array.concat(lowercaseMarks, uppercaseMarks, numberMarks);
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ var Tabs = Module("tabs", {
|
|||||||
|
|
||||||
_mappingCount: 0,
|
_mappingCount: 0,
|
||||||
|
|
||||||
_alternates: Class.memoize(function () [config.tabbrowser.mCurrentTab, null]),
|
_alternates: Class.Memoize(function () [config.tabbrowser.mCurrentTab, null]),
|
||||||
|
|
||||||
cleanup: function cleanup() {
|
cleanup: function cleanup() {
|
||||||
for (let [i, tab] in Iterator(this.allTabs)) {
|
for (let [i, tab] in Iterator(this.allTabs)) {
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ var updateAddons = Class("UpgradeListener", AddonListener, {
|
|||||||
|
|
||||||
},
|
},
|
||||||
onUpdateAvailable: function (addon, install) {
|
onUpdateAvailable: function (addon, install) {
|
||||||
util.dump("onUpdateAvailable");
|
|
||||||
this.upgrade.push(addon);
|
this.upgrade.push(addon);
|
||||||
install.addListener(this);
|
install.addListener(this);
|
||||||
install.install();
|
install.install();
|
||||||
@@ -278,7 +277,7 @@ var AddonList = Class("AddonList", {
|
|||||||
this.update();
|
this.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
message: Class.memoize(function () {
|
message: Class.Memoize(function () {
|
||||||
|
|
||||||
XML.ignoreWhitespace = true;
|
XML.ignoreWhitespace = true;
|
||||||
util.xmlToDom(<table highlight="Addons" key="list" xmlns={XHTML}>
|
util.xmlToDom(<table highlight="Addons" key="list" xmlns={XHTML}>
|
||||||
@@ -348,7 +347,7 @@ var AddonList = Class("AddonList", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var Addons = Module("addons", {
|
var Addons = Module("addons", {
|
||||||
errors: Class.memoize(function ()
|
errors: Class.Memoize(function ()
|
||||||
array(["ERROR_NETWORK_FAILURE", "ERROR_INCORRECT_HASH",
|
array(["ERROR_NETWORK_FAILURE", "ERROR_INCORRECT_HASH",
|
||||||
"ERROR_CORRUPT_FILE", "ERROR_FILE_ACCESS"])
|
"ERROR_CORRUPT_FILE", "ERROR_FILE_ACCESS"])
|
||||||
.map(function (e) [AddonManager[e], _("AddonManager." + e)])
|
.map(function (e) [AddonManager[e], _("AddonManager." + e)])
|
||||||
@@ -539,7 +538,7 @@ else
|
|||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
|
|
||||||
installLocation: Class.memoize(function () services.extensionManager.getInstallLocation(this.id)),
|
installLocation: Class.Memoize(function () services.extensionManager.getInstallLocation(this.id)),
|
||||||
getResourceURI: function getResourceURI(path) {
|
getResourceURI: function getResourceURI(path) {
|
||||||
let file = this.installLocation.getItemFile(this.id, path);
|
let file = this.installLocation.getItemFile(this.id, path);
|
||||||
return services.io.newFileURI(file);
|
return services.io.newFileURI(file);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
var { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
var { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||||
|
|
||||||
|
Cu.import("resource://dactyl/bootstrap.jsm");
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
try {
|
try {
|
||||||
var ctypes;
|
var ctypes;
|
||||||
@@ -14,7 +15,8 @@ try {
|
|||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
let objproto = Object.prototype;
|
let objproto = Object.prototype;
|
||||||
let { __lookupGetter__, __lookupSetter__, hasOwnProperty, propertyIsEnumerable } = objproto;
|
let { __lookupGetter__, __lookupSetter__, __defineGetter__, __defineSetter__,
|
||||||
|
hasOwnProperty, propertyIsEnumerable } = objproto;
|
||||||
|
|
||||||
if (typeof XPCSafeJSObjectWrapper === "undefined")
|
if (typeof XPCSafeJSObjectWrapper === "undefined")
|
||||||
this.XPCSafeJSObjectWrapper = XPCNativeWrapper;
|
this.XPCSafeJSObjectWrapper = XPCNativeWrapper;
|
||||||
@@ -44,15 +46,15 @@ if (!Object.defineProperty)
|
|||||||
}
|
}
|
||||||
catch (e if e instanceof TypeError) {}
|
catch (e if e instanceof TypeError) {}
|
||||||
else {
|
else {
|
||||||
objproto.__defineGetter__.call(obj, prop, function () value);
|
__defineGetter__.call(obj, prop, function () value);
|
||||||
if (desc.writable)
|
if (desc.writable)
|
||||||
objproto.__defineSetter__.call(obj, prop, function (val) { value = val; });
|
__defineSetter__.call(obj, prop, function (val) { value = val; });
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("get" in desc)
|
if ("get" in desc)
|
||||||
objproto.__defineGetter__.call(obj, prop, desc.get);
|
__defineGetter__.call(obj, prop, desc.get);
|
||||||
if ("set" in desc)
|
if ("set" in desc)
|
||||||
objproto.__defineSetter__.call(obj, prop, desc.set);
|
__defineSetter__.call(obj, prop, desc.set);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
throw e.stack ? e : Error(e);
|
throw e.stack ? e : Error(e);
|
||||||
@@ -163,9 +165,8 @@ defineModule.dump = function dump_() {
|
|||||||
msg = util.objectToString(msg);
|
msg = util.objectToString(msg);
|
||||||
return msg;
|
return msg;
|
||||||
}).join(", ");
|
}).join(", ");
|
||||||
let name = loaded.config ? config.name : "dactyl";
|
|
||||||
dump(String.replace(msg, /\n?$/, "\n")
|
dump(String.replace(msg, /\n?$/, "\n")
|
||||||
.replace(/^./gm, name + ": $&"));
|
.replace(/^./gm, JSMLoader.name + ": $&"));
|
||||||
}
|
}
|
||||||
defineModule.modules = [];
|
defineModule.modules = [];
|
||||||
defineModule.time = function time(major, minor, func, self) {
|
defineModule.time = function time(major, minor, func, self) {
|
||||||
@@ -851,7 +852,7 @@ Class.extend = function extend(subclass, superclass, overrides) {
|
|||||||
* property's value.
|
* property's value.
|
||||||
* @returns {Class.Property}
|
* @returns {Class.Property}
|
||||||
*/
|
*/
|
||||||
Class.Memoize = Class.memoize = function Memoize(getter, wait)
|
Class.Memoize = Class.Memoize = function Memoize(getter, wait)
|
||||||
Class.Property({
|
Class.Property({
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
@@ -1265,7 +1266,7 @@ var Timer = Class("Timer", {
|
|||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (typeof util === "undefined")
|
if (typeof util === "undefined")
|
||||||
dump("dactyl: " + e + "\n" + (e.stack || Error().stack));
|
dump(JSMLoader.name + ": " + e + "\n" + (e.stack || Error().stack));
|
||||||
else
|
else
|
||||||
util.reportError(e);
|
util.reportError(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
|
|||||||
|
|
||||||
get bookmarks() Class.replaceProperty(this, "bookmarks", this.load()),
|
get bookmarks() Class.replaceProperty(this, "bookmarks", this.load()),
|
||||||
|
|
||||||
keywords: Class.memoize(function () array.toObject([[b.keyword, b] for (b in this) if (b.keyword)])),
|
keywords: Class.Memoize(function () array.toObject([[b.keyword, b] for (b in this) if (b.keyword)])),
|
||||||
|
|
||||||
rootFolders: ["toolbarFolder", "bookmarksMenuFolder", "unfiledBookmarksFolder"]
|
rootFolders: ["toolbarFolder", "bookmarksMenuFolder", "unfiledBookmarksFolder"]
|
||||||
.map(function (s) services.bookmarks[s]),
|
.map(function (s) services.bookmarks[s]),
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ else
|
|||||||
|
|
||||||
factories: [],
|
factories: [],
|
||||||
|
|
||||||
|
name: "dactyl",
|
||||||
|
|
||||||
global: this,
|
global: this,
|
||||||
|
|
||||||
globals: JSMLoader ? JSMLoader.globals : {},
|
globals: JSMLoader ? JSMLoader.globals : {},
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ var Command = Class("Command", {
|
|||||||
extra: extra
|
extra: extra
|
||||||
}),
|
}),
|
||||||
|
|
||||||
complained: Class.memoize(function () ({})),
|
complained: Class.Memoize(function () ({})),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {[string]} All of this command's name specs. e.g., "com[mand]"
|
* @property {[string]} All of this command's name specs. e.g., "com[mand]"
|
||||||
@@ -286,7 +286,7 @@ var Command = Class("Command", {
|
|||||||
*/
|
*/
|
||||||
options: [],
|
options: [],
|
||||||
|
|
||||||
optionMap: Class.memoize(function () array(this.options)
|
optionMap: Class.Memoize(function () array(this.options)
|
||||||
.map(function (opt) opt.names.map(function (name) [name, opt]))
|
.map(function (opt) opt.names.map(function (name) [name, opt]))
|
||||||
.flatten().toObject()),
|
.flatten().toObject()),
|
||||||
|
|
||||||
@@ -297,19 +297,19 @@ var Command = Class("Command", {
|
|||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
argsPrototype: Class.memoize(function argsPrototype() {
|
argsPrototype: Class.Memoize(function argsPrototype() {
|
||||||
let res = update([], {
|
let res = update([], {
|
||||||
__iterator__: function AP__iterator__() array.iterItems(this),
|
__iterator__: function AP__iterator__() array.iterItems(this),
|
||||||
|
|
||||||
command: this,
|
command: this,
|
||||||
|
|
||||||
explicitOpts: Class.memoize(function () ({})),
|
explicitOpts: Class.Memoize(function () ({})),
|
||||||
|
|
||||||
has: function AP_has(opt) Set.has(this.explicitOpts, opt) || typeof opt === "number" && Set.has(this, opt),
|
has: function AP_has(opt) Set.has(this.explicitOpts, opt) || typeof opt === "number" && Set.has(this, opt),
|
||||||
|
|
||||||
get literalArg() this.command.literal != null && this[this.command.literal] || "",
|
get literalArg() this.command.literal != null && this[this.command.literal] || "",
|
||||||
|
|
||||||
// TODO: string: Class.memoize(function () { ... }),
|
// TODO: string: Class.Memoize(function () { ... }),
|
||||||
|
|
||||||
verify: function verify() {
|
verify: function verify() {
|
||||||
if (this.command.argCount) {
|
if (this.command.argCount) {
|
||||||
@@ -1175,9 +1175,9 @@ var Commands = Module("commands", {
|
|||||||
]]>, /U/g, "\\u"), "x")
|
]]>, /U/g, "\\u"), "x")
|
||||||
}),
|
}),
|
||||||
|
|
||||||
validName: Class.memoize(function validName() util.regexp("^" + this.nameRegexp.source + "$")),
|
validName: Class.Memoize(function validName() util.regexp("^" + this.nameRegexp.source + "$")),
|
||||||
|
|
||||||
commandRegexp: Class.memoize(function commandRegexp() util.regexp(<![CDATA[
|
commandRegexp: Class.Memoize(function commandRegexp() util.regexp(<![CDATA[
|
||||||
^
|
^
|
||||||
(?P<spec>
|
(?P<spec>
|
||||||
(?P<prespace> [:\s]*)
|
(?P<prespace> [:\s]*)
|
||||||
@@ -1514,7 +1514,7 @@ var Commands = Module("commands", {
|
|||||||
["+", "One or more arguments are allowed"]],
|
["+", "One or more arguments are allowed"]],
|
||||||
default: "0",
|
default: "0",
|
||||||
type: CommandOption.STRING,
|
type: CommandOption.STRING,
|
||||||
validator: function (arg) /^[01*?+]$/.test(arg)
|
validator: bind("test", /^[01*?+]$/)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
names: ["-nopersist", "-n"],
|
names: ["-nopersist", "-n"],
|
||||||
|
|||||||
@@ -405,7 +405,7 @@ var CompletionContext = Class("CompletionContext", {
|
|||||||
this.noUpdate = false;
|
this.noUpdate = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
ignoreCase: Class.memoize(function () {
|
ignoreCase: Class.Memoize(function () {
|
||||||
let mode = this.wildcase;
|
let mode = this.wildcase;
|
||||||
if (mode == "match")
|
if (mode == "match")
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ let global = this;
|
|||||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("config", {
|
defineModule("config", {
|
||||||
exports: ["ConfigBase", "Config", "config"],
|
exports: ["ConfigBase", "Config", "config"],
|
||||||
require: ["protocol", "services", "storage", "util", "template"],
|
require: ["dom", "protocol", "services", "storage", "util", "template"],
|
||||||
use: ["io", "messages", "prefs", "styles"]
|
use: ["io", "messages", "prefs", "styles"]
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
@@ -67,6 +67,7 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
"completion",
|
"completion",
|
||||||
"config",
|
"config",
|
||||||
"contexts",
|
"contexts",
|
||||||
|
"dom",
|
||||||
"downloads",
|
"downloads",
|
||||||
"finder",
|
"finder",
|
||||||
"help",
|
"help",
|
||||||
@@ -130,7 +131,7 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
elem.style.cssText = this.cssText;
|
elem.style.cssText = this.cssText;
|
||||||
|
|
||||||
let keys = iter(Styles.propertyIter(this.cssText)).map(function (p) p.name).toArray();
|
let keys = iter(Styles.propertyIter(this.cssText)).map(function (p) p.name).toArray();
|
||||||
let bg = keys.some(function (k) /^background/.test(k));
|
let bg = keys.some(bind("test", /^background/));
|
||||||
let fg = keys.indexOf("color") >= 0;
|
let fg = keys.indexOf("color") >= 0;
|
||||||
|
|
||||||
let style = DOM(elem).style;
|
let style = DOM(elem).style;
|
||||||
@@ -141,7 +142,7 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
|
|
||||||
get addonID() this.name + "@dactyl.googlecode.com",
|
get addonID() this.name + "@dactyl.googlecode.com",
|
||||||
|
|
||||||
addon: Class.memoize(function () {
|
addon: Class.Memoize(function () {
|
||||||
return (JSMLoader.bootstrap || {}).addon ||
|
return (JSMLoader.bootstrap || {}).addon ||
|
||||||
require("addons").AddonManager.getAddonByID(this.addonID);
|
require("addons").AddonManager.getAddonByID(this.addonID);
|
||||||
}),
|
}),
|
||||||
@@ -149,17 +150,17 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
/**
|
/**
|
||||||
* The current application locale.
|
* The current application locale.
|
||||||
*/
|
*/
|
||||||
appLocale: Class.memoize(function () services.chromeRegistry.getSelectedLocale("global")),
|
appLocale: Class.Memoize(function () services.chromeRegistry.getSelectedLocale("global")),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current dactyl locale.
|
* The current dactyl locale.
|
||||||
*/
|
*/
|
||||||
locale: Class.memoize(function () this.bestLocale(this.locales)),
|
locale: Class.Memoize(function () this.bestLocale(this.locales)),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current application locale.
|
* The current application locale.
|
||||||
*/
|
*/
|
||||||
locales: Class.memoize(function () {
|
locales: Class.Memoize(function () {
|
||||||
// TODO: Merge with completion.file code.
|
// TODO: Merge with completion.file code.
|
||||||
function getDir(str) str.match(/^(?:.*[\/\\])?/)[0];
|
function getDir(str) str.match(/^(?:.*[\/\\])?/)[0];
|
||||||
|
|
||||||
@@ -283,7 +284,7 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
* directory if the application is running from one via an extension
|
* directory if the application is running from one via an extension
|
||||||
* proxy file.
|
* proxy file.
|
||||||
*/
|
*/
|
||||||
VCSPath: Class.memoize(function () {
|
VCSPath: Class.Memoize(function () {
|
||||||
if (/pre$/.test(this.addon.version)) {
|
if (/pre$/.test(this.addon.version)) {
|
||||||
let uri = util.newURI(this.addon.getResourceURI("").spec + "../.hg");
|
let uri = util.newURI(this.addon.getResourceURI("").spec + "../.hg");
|
||||||
if (uri instanceof Ci.nsIFileURL &&
|
if (uri instanceof Ci.nsIFileURL &&
|
||||||
@@ -299,14 +300,14 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
* running from if using an extension proxy file or was built from if
|
* running from if using an extension proxy file or was built from if
|
||||||
* installed as an XPI.
|
* installed as an XPI.
|
||||||
*/
|
*/
|
||||||
branch: Class.memoize(function () {
|
branch: Class.Memoize(function () {
|
||||||
if (this.VCSPath)
|
if (this.VCSPath)
|
||||||
return io.system(["hg", "-R", this.VCSPath, "branch"]).output;
|
return io.system(["hg", "-R", this.VCSPath, "branch"]).output;
|
||||||
return (/pre-hg\d+-(\S*)/.exec(this.version) || [])[1];
|
return (/pre-hg\d+-(\S*)/.exec(this.version) || [])[1];
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/** @property {string} The Dactyl version string. */
|
/** @property {string} The Dactyl version string. */
|
||||||
version: Class.memoize(function () {
|
version: Class.Memoize(function () {
|
||||||
if (this.VCSPath)
|
if (this.VCSPath)
|
||||||
return io.system(["hg", "-R", this.VCSPath, "log", "-r.",
|
return io.system(["hg", "-R", this.VCSPath, "log", "-r.",
|
||||||
"--template=hg{rev}-{branch}"]).output;
|
"--template=hg{rev}-{branch}"]).output;
|
||||||
@@ -314,7 +315,7 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
return this.addon.version;
|
return this.addon.version;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
buildDate: Class.memoize(function () {
|
buildDate: Class.Memoize(function () {
|
||||||
if (this.VCSPath)
|
if (this.VCSPath)
|
||||||
return io.system(["hg", "-R", this.VCSPath, "log", "-r.",
|
return io.system(["hg", "-R", this.VCSPath, "log", "-r.",
|
||||||
"--template={date|isodate}"]).output;
|
"--template={date|isodate}"]).output;
|
||||||
@@ -324,7 +325,7 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
|
|
||||||
get fileExt() this.name.slice(0, -6),
|
get fileExt() this.name.slice(0, -6),
|
||||||
|
|
||||||
dtd: Class.memoize(function ()
|
dtd: Class.Memoize(function ()
|
||||||
iter(this.dtdExtra,
|
iter(this.dtdExtra,
|
||||||
(["dactyl." + k, v] for ([k, v] in iter(config.dtdDactyl))),
|
(["dactyl." + k, v] for ([k, v] in iter(config.dtdDactyl))),
|
||||||
(["dactyl." + s, config[s]] for each (s in config.dtdStrings)))
|
(["dactyl." + s, config[s]] for each (s in config.dtdStrings)))
|
||||||
@@ -339,10 +340,10 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
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.mailto": Class.Memoize(function () config.name + "@googlegroups.com"),
|
||||||
"list.href": Class.memoize(function () "http://groups.google.com/group/" + config.name),
|
"list.href": Class.Memoize(function () "http://groups.google.com/group/" + config.name),
|
||||||
|
|
||||||
"hg.latest": Class.memoize(function () this.code + "source/browse/"), // XXX
|
"hg.latest": Class.Memoize(function () this.code + "source/browse/"), // XXX
|
||||||
"irc": "irc://irc.oftc.net/#pentadactyl",
|
"irc": "irc://irc.oftc.net/#pentadactyl",
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -397,8 +398,8 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
util.overlayWindow(window, { append: append.elements() });
|
util.overlayWindow(window, { append: append.elements() });
|
||||||
},
|
},
|
||||||
|
|
||||||
browser: Class.memoize(function () window.gBrowser),
|
browser: Class.Memoize(function () window.gBrowser),
|
||||||
tabbrowser: Class.memoize(function () window.gBrowser),
|
tabbrowser: Class.Memoize(function () window.gBrowser),
|
||||||
|
|
||||||
get browserModes() [modules.modes.NORMAL],
|
get browserModes() [modules.modes.NORMAL],
|
||||||
|
|
||||||
@@ -413,7 +414,7 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
*/
|
*/
|
||||||
get outputHeight() this.browser.mPanelContainer.boxObject.height,
|
get outputHeight() this.browser.mPanelContainer.boxObject.height,
|
||||||
|
|
||||||
tabStrip: Class.memoize(function () window.document.getElementById("TabsToolbar") || this.tabbrowser.mTabContainer),
|
tabStrip: Class.Memoize(function () window.document.getElementById("TabsToolbar") || this.tabbrowser.mTabContainer),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ var Group = Class("Group", {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
defaultFilter: Class.memoize(function () this.compileFilter(["*"]))
|
defaultFilter: Class.Memoize(function () this.compileFilter(["*"]))
|
||||||
});
|
});
|
||||||
|
|
||||||
var Contexts = Module("contexts", {
|
var Contexts = Module("contexts", {
|
||||||
@@ -283,9 +283,9 @@ var Contexts = Module("contexts", {
|
|||||||
return frame;
|
return frame;
|
||||||
},
|
},
|
||||||
|
|
||||||
groups: Class.memoize(function () this.matchingGroups()),
|
groups: Class.Memoize(function () this.matchingGroups()),
|
||||||
|
|
||||||
allGroups: Class.memoize(function () Object.create(this.groupsProto, {
|
allGroups: Class.Memoize(function () Object.create(this.groupsProto, {
|
||||||
groups: { value: this.initializedGroups() }
|
groups: { value: this.initializedGroups() }
|
||||||
})),
|
})),
|
||||||
|
|
||||||
@@ -486,7 +486,7 @@ var Contexts = Module("contexts", {
|
|||||||
get persist() this.group.persist,
|
get persist() this.group.persist,
|
||||||
set persist(val) this.group.persist = val,
|
set persist(val) this.group.persist = val,
|
||||||
|
|
||||||
prefix: Class.memoize(function () this.name === "builtin" ? "" : this.name + ":"),
|
prefix: Class.Memoize(function () this.name === "builtin" ? "" : this.name + ":"),
|
||||||
|
|
||||||
get toStringParams() [this.name]
|
get toStringParams() [this.name]
|
||||||
})
|
})
|
||||||
|
|||||||
1079
common/modules/dom.jsm
Normal file
1079
common/modules/dom.jsm
Normal file
File diff suppressed because it is too large
Load Diff
@@ -74,7 +74,7 @@ var Download = Class("Download", {
|
|||||||
|
|
||||||
get alive() this.inState(["downloading", "notstarted", "paused", "queued", "scanning"]),
|
get alive() this.inState(["downloading", "notstarted", "paused", "queued", "scanning"]),
|
||||||
|
|
||||||
allowedCommands: Class.memoize(function () let (self = this) ({
|
allowedCommands: Class.Memoize(function () let (self = this) ({
|
||||||
get cancel() self.cancelable && self.inState(["downloading", "paused", "starting"]),
|
get cancel() self.cancelable && self.inState(["downloading", "paused", "starting"]),
|
||||||
get delete() !this.cancel && self.targetFile.exists(),
|
get delete() !this.cancel && self.targetFile.exists(),
|
||||||
get launch() self.targetFile.exists() && self.inState(["finished"]),
|
get launch() self.targetFile.exists() && self.inState(["finished"]),
|
||||||
@@ -213,7 +213,7 @@ var DownloadList = Class("DownloadList",
|
|||||||
services.downloadManager.removeListener(this);
|
services.downloadManager.removeListener(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
message: Class.memoize(function () {
|
message: Class.Memoize(function () {
|
||||||
|
|
||||||
util.xmlToDom(<table highlight="Downloads" key="list" xmlns={XHTML}>
|
util.xmlToDom(<table highlight="Downloads" key="list" xmlns={XHTML}>
|
||||||
<tr highlight="DownloadHead">
|
<tr highlight="DownloadHead">
|
||||||
@@ -280,7 +280,7 @@ var DownloadList = Class("DownloadList",
|
|||||||
this.cleanup();
|
this.cleanup();
|
||||||
},
|
},
|
||||||
|
|
||||||
allowedCommands: Class.memoize(function () let (self = this) ({
|
allowedCommands: Class.Memoize(function () let (self = this) ({
|
||||||
get clear() values(self.downloads).some(function (dl) dl.allowedCommands.remove)
|
get clear() values(self.downloads).some(function (dl) dl.allowedCommands.remove)
|
||||||
})),
|
})),
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm");
|
|||||||
defineModule("finder", {
|
defineModule("finder", {
|
||||||
exports: ["RangeFind", "RangeFinder", "rangefinder"],
|
exports: ["RangeFind", "RangeFinder", "rangefinder"],
|
||||||
require: ["prefs"],
|
require: ["prefs"],
|
||||||
use: ["messages", "services", "util"]
|
use: ["dom", "messages", "services", "util"]
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
function equals(a, b) XPCNativeWrapper(a) == XPCNativeWrapper(b);
|
function equals(a, b) XPCNativeWrapper(a) == XPCNativeWrapper(b);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("help", {
|
defineModule("help", {
|
||||||
exports: ["help"],
|
exports: ["help"],
|
||||||
require: ["protocol", "services", "util"],
|
require: ["dom", "protocol", "services", "util"],
|
||||||
use: ["config", "highlight", "messages", "template"]
|
use: ["config", "highlight", "messages", "template"]
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
@@ -21,7 +21,8 @@ var Help = Module("Help", {
|
|||||||
function Loop(fn)
|
function Loop(fn)
|
||||||
function (uri, path) {
|
function (uri, path) {
|
||||||
if (!help.initialized)
|
if (!help.initialized)
|
||||||
return RedirectChannel(uri.spec, uri, 1);
|
return RedirectChannel(uri.spec, uri, 2,
|
||||||
|
"Initializing. Please wait...");
|
||||||
return fn.apply(this, arguments);
|
return fn.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ var IO = Module("io", {
|
|||||||
* @property {function} File class.
|
* @property {function} File class.
|
||||||
* @final
|
* @final
|
||||||
*/
|
*/
|
||||||
File: Class.memoize(function () let (io = this)
|
File: Class.Memoize(function () let (io = this)
|
||||||
Class("File", File, {
|
Class("File", File, {
|
||||||
init: function init(path, checkCWD)
|
init: function init(path, checkCWD)
|
||||||
init.supercall(this, path, (arguments.length < 2 || checkCWD) && io.cwd)
|
init.supercall(this, path, (arguments.length < 2 || checkCWD) && io.cwd)
|
||||||
@@ -826,12 +826,12 @@ unlet s:cpo_save
|
|||||||
if (args.bang)
|
if (args.bang)
|
||||||
arg = "!" + arg;
|
arg = "!" + arg;
|
||||||
|
|
||||||
// NOTE: Vim doesn't replace ! preceded by 2 or more backslashes and documents it - desirable?
|
// This is an asinine and irritating "feature" when we have searchable
|
||||||
// pass through a raw bang when escaped or substitute the last command
|
|
||||||
|
|
||||||
// This is an asinine and irritating feature when we have searchable
|
|
||||||
// command-line history. --Kris
|
// command-line history. --Kris
|
||||||
if (modules.options["banghist"]) {
|
if (modules.options["banghist"]) {
|
||||||
|
// NOTE: Vim doesn't replace ! preceded by 2 or more backslashes and documents it - desirable?
|
||||||
|
// pass through a raw bang when escaped or substitute the last command
|
||||||
|
|
||||||
// replaceable bang and no previous command?
|
// replaceable bang and no previous command?
|
||||||
dactyl.assert(!/((^|[^\\])(\\\\)*)!/.test(arg) || io._lastRunCommand,
|
dactyl.assert(!/((^|[^\\])(\\\\)*)!/.test(arg) || io._lastRunCommand,
|
||||||
_("command.run.noPrevious"));
|
_("command.run.noPrevious"));
|
||||||
@@ -1041,7 +1041,7 @@ unlet s:cpo_save
|
|||||||
|
|
||||||
options.add(["banghist", "bh"],
|
options.add(["banghist", "bh"],
|
||||||
"Replace occurrences of ! with the previous command when executing external commands",
|
"Replace occurrences of ! with the previous command when executing external commands",
|
||||||
"boolean", true);
|
"boolean", false);
|
||||||
|
|
||||||
options.add(["fileencoding", "fenc"],
|
options.add(["fileencoding", "fenc"],
|
||||||
"The character encoding used when reading and writing files",
|
"The character encoding used when reading and writing files",
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ var JavaScript = Module("javascript", {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
globals: Class.memoize(function () [
|
globals: Class.Memoize(function () [
|
||||||
[this.modules.userContext, /*L*/"Global Variables"],
|
[this.modules.userContext, /*L*/"Global Variables"],
|
||||||
[this.modules, "modules"],
|
[this.modules, "modules"],
|
||||||
[this.window, "window"]
|
[this.window, "window"]
|
||||||
]),
|
]),
|
||||||
|
|
||||||
toplevel: Class.memoize(function () this.modules.jsmodules),
|
toplevel: Class.Memoize(function () this.modules.jsmodules),
|
||||||
|
|
||||||
lazyInit: true,
|
lazyInit: true,
|
||||||
|
|
||||||
@@ -612,13 +612,13 @@ var JavaScript = Module("javascript", {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
magicalNames: Class.memoize(function () Object.getOwnPropertyNames(Cu.Sandbox(this.window), true).sort()),
|
magicalNames: Class.Memoize(function () Object.getOwnPropertyNames(Cu.Sandbox(this.window), true).sort()),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of properties of the global object which are not
|
* A list of properties of the global object which are not
|
||||||
* enumerable by any standard method.
|
* enumerable by any standard method.
|
||||||
*/
|
*/
|
||||||
globalNames: Class.memoize(function () let (self = this) array.uniq([
|
globalNames: Class.Memoize(function () let (self = this) array.uniq([
|
||||||
"Array", "ArrayBuffer", "AttributeName", "Boolean", "Components",
|
"Array", "ArrayBuffer", "AttributeName", "Boolean", "Components",
|
||||||
"CSSFontFaceStyleDecl", "CSSGroupRuleRuleList", "CSSNameSpaceRule",
|
"CSSFontFaceStyleDecl", "CSSGroupRuleRuleList", "CSSNameSpaceRule",
|
||||||
"CSSRGBColor", "CSSRect", "ComputedCSSStyleDeclaration", "Date",
|
"CSSRGBColor", "CSSRect", "ComputedCSSStyleDeclaration", "Date",
|
||||||
@@ -700,7 +700,7 @@ var JavaScript = Module("javascript", {
|
|||||||
modes.addMode("REPL", {
|
modes.addMode("REPL", {
|
||||||
description: "JavaScript Read Eval Print Loop",
|
description: "JavaScript Read Eval Print Loop",
|
||||||
bases: [modes.COMMAND_LINE],
|
bases: [modes.COMMAND_LINE],
|
||||||
displayName: Class.memoize(function () this.name)
|
displayName: Class.Memoize(function () this.name)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
commandline: function initCommandLine(dactyl, modules, window) {
|
commandline: function initCommandLine(dactyl, modules, window) {
|
||||||
@@ -746,7 +746,7 @@ var JavaScript = Module("javascript", {
|
|||||||
|
|
||||||
count: 0,
|
count: 0,
|
||||||
|
|
||||||
message: Class.memoize(function () {
|
message: Class.Memoize(function () {
|
||||||
default xml namespace = XHTML;
|
default xml namespace = XHTML;
|
||||||
util.xmlToDom(<div highlight="REPL" key="rootNode"/>,
|
util.xmlToDom(<div highlight="REPL" key="rootNode"/>,
|
||||||
this.document, this);
|
this.document, this);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ var Messages = Module("messages", {
|
|||||||
init: function _(message) {
|
init: function _(message) {
|
||||||
this.args = arguments;
|
this.args = arguments;
|
||||||
},
|
},
|
||||||
message: Class.memoize(function () {
|
message: Class.Memoize(function () {
|
||||||
let message = this.args[0];
|
let message = this.args[0];
|
||||||
|
|
||||||
if (this.args.length > 1) {
|
if (this.args.length > 1) {
|
||||||
|
|||||||
@@ -928,7 +928,7 @@ var Options = Module("options", {
|
|||||||
setPref: deprecated("prefs.set", function setPref() prefs.set.apply(prefs, arguments)),
|
setPref: deprecated("prefs.set", function setPref() prefs.set.apply(prefs, arguments)),
|
||||||
withContext: deprecated("prefs.withContext", function withContext() prefs.withContext.apply(prefs, arguments)),
|
withContext: deprecated("prefs.withContext", function withContext() prefs.withContext.apply(prefs, arguments)),
|
||||||
|
|
||||||
cleanupPrefs: Class.memoize(function () localPrefs.Branch("cleanup.option.")),
|
cleanupPrefs: Class.Memoize(function () localPrefs.Branch("cleanup.option.")),
|
||||||
|
|
||||||
cleanup: function cleanup(reason) {
|
cleanup: function cleanup(reason) {
|
||||||
if (~["disable", "uninstall"].indexOf(reason))
|
if (~["disable", "uninstall"].indexOf(reason))
|
||||||
|
|||||||
@@ -539,7 +539,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
|||||||
/**
|
/**
|
||||||
* A list of extant dactyl windows.
|
* A list of extant dactyl windows.
|
||||||
*/
|
*/
|
||||||
windows: Class.memoize(function () [])
|
windows: Class.Memoize(function () [])
|
||||||
});
|
});
|
||||||
|
|
||||||
endModule();
|
endModule();
|
||||||
|
|||||||
@@ -50,8 +50,9 @@ function NetError(orig, error) {
|
|||||||
open: function () { throw error || Cr.NS_ERROR_FILE_NOT_FOUND }
|
open: function () { throw error || Cr.NS_ERROR_FILE_NOT_FOUND }
|
||||||
}).data.QueryInterface(Ci.nsIChannel);
|
}).data.QueryInterface(Ci.nsIChannel);
|
||||||
}
|
}
|
||||||
function RedirectChannel(to, orig, time) {
|
function RedirectChannel(to, orig, time, message) {
|
||||||
let html = <html><head><meta http-equiv="Refresh" content={(time || 0) + ";" + to}/></head></html>.toXMLString();
|
let html = <html><head><meta http-equiv="Refresh" content={(time || 0) + ";" + to}/></head>
|
||||||
|
<body><h2 style="text-align: center">{message || ""}</h2></body></html>.toXMLString();
|
||||||
return StringChannel(html, "text/html", services.io.newURI(to, null, null));
|
return StringChannel(html, "text/html", services.io.newURI(to, null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
|||||||
session: 8
|
session: 8
|
||||||
},
|
},
|
||||||
|
|
||||||
UNPERMS: Class.memoize(function () iter(this.PERMS).map(Array.reverse).toObject()),
|
UNPERMS: Class.Memoize(function () iter(this.PERMS).map(Array.reverse).toObject()),
|
||||||
|
|
||||||
COMMANDS: {
|
COMMANDS: {
|
||||||
unset: /*L*/"Unset",
|
unset: /*L*/"Unset",
|
||||||
@@ -650,7 +650,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
|||||||
"1d": "Past day",
|
"1d": "Past day",
|
||||||
"1w": "Past week"
|
"1w": "Past week"
|
||||||
},
|
},
|
||||||
validator: function (value) /^(a(ll)?|s(ession)|\d+[mhdw])$/.test(value)
|
validator: bind("test", /^(a(ll)?|s(ession)|\d+[mhdw])$/)
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["cookies", "ck"],
|
options.add(["cookies", "ck"],
|
||||||
|
|||||||
@@ -510,13 +510,13 @@ var File = Class("File", {
|
|||||||
/**
|
/**
|
||||||
* @property {string} The current platform's path separator.
|
* @property {string} The current platform's path separator.
|
||||||
*/
|
*/
|
||||||
PATH_SEP: Class.memoize(function () {
|
PATH_SEP: Class.Memoize(function () {
|
||||||
let f = services.directory.get("CurProcD", Ci.nsIFile);
|
let f = services.directory.get("CurProcD", Ci.nsIFile);
|
||||||
f.append("foo");
|
f.append("foo");
|
||||||
return f.path.substr(f.parent.path.length, 1);
|
return f.path.substr(f.parent.path.length, 1);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
pathSplit: Class.memoize(function () util.regexp("(?:/|" + util.regexp.escape(this.PATH_SEP) + ")", "g")),
|
pathSplit: Class.Memoize(function () util.regexp("(?:/|" + util.regexp.escape(this.PATH_SEP) + ")", "g")),
|
||||||
|
|
||||||
DoesNotExist: function (path, error) ({
|
DoesNotExist: function (path, error) ({
|
||||||
path: path,
|
path: path,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm");
|
|||||||
defineModule("styles", {
|
defineModule("styles", {
|
||||||
exports: ["Style", "Styles", "styles"],
|
exports: ["Style", "Styles", "styles"],
|
||||||
require: ["services", "util"],
|
require: ["services", "util"],
|
||||||
use: ["contexts", "messages", "template"]
|
use: ["contexts", "dom", "messages", "template"]
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
function cssUri(css) "chrome-data:text/css," + encodeURI(css);
|
function cssUri(css) "chrome-data:text/css," + encodeURI(css);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ var Binding = Class("Binding", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
events: Class.memoize(function () {
|
events: Class.Memoize(function () {
|
||||||
let res = [];
|
let res = [];
|
||||||
for (let obj in this.bindings)
|
for (let obj in this.bindings)
|
||||||
if (Object.getOwnPropertyDescriptor(obj, "events"))
|
if (Object.getOwnPropertyDescriptor(obj, "events"))
|
||||||
@@ -66,7 +66,7 @@ var Binding = Class("Binding", {
|
|||||||
return res;
|
return res;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
properties: Class.memoize(function () {
|
properties: Class.Memoize(function () {
|
||||||
let res = {};
|
let res = {};
|
||||||
for (let obj in this.bindings)
|
for (let obj in this.bindings)
|
||||||
for (let prop in properties(obj)) {
|
for (let prop in properties(obj)) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -83,7 +83,7 @@ var Config = Module("config", ConfigBase, {
|
|||||||
dactyl.beep();
|
dactyl.beep();
|
||||||
},
|
},
|
||||||
|
|
||||||
completers: Class.memoize(function () update({ mailfolder: "mailFolder" }, this.__proto__.completers)),
|
completers: Class.Memoize(function () update({ mailfolder: "mailFolder" }, this.__proto__.completers)),
|
||||||
|
|
||||||
dialogs: {
|
dialogs: {
|
||||||
about: ["About Thunderbird",
|
about: ["About Thunderbird",
|
||||||
@@ -143,7 +143,7 @@ var Config = Module("config", ConfigBase, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/*** optional options, there are checked for existence and a fallback provided ***/
|
/*** optional options, there are checked for existence and a fallback provided ***/
|
||||||
features: Class.memoize(function () Set(
|
features: Class.Memoize(function () Set(
|
||||||
this.isComposeWindow ? ["addressbook"]
|
this.isComposeWindow ? ["addressbook"]
|
||||||
: ["hints", "mail", "marks", "addressbook", "tabs"])),
|
: ["hints", "mail", "marks", "addressbook", "tabs"])),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user