mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-06 09:54:12 +01:00
Add dom.jsm. And stuff.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
var AutoCommand = Struct("event", "filter", "command");
|
||||
update(AutoCommand.prototype, {
|
||||
eventName: Class.memoize(function () this.event.toLowerCase()),
|
||||
eventName: Class.Memoize(function () this.event.toLowerCase()),
|
||||
|
||||
match: function (event, 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"] });
|
||||
},
|
||||
type: CommandOption.STRING,
|
||||
validator: function (arg) /^\S+$/.test(arg)
|
||||
validator: bind("test", /^\S+$/)
|
||||
};
|
||||
|
||||
commands.add(["bma[rk]"],
|
||||
|
||||
@@ -1184,8 +1184,8 @@ var Buffer = Module("buffer", {
|
||||
PageInfo: Struct("PageInfo", "name", "title", "action")
|
||||
.localize("title"),
|
||||
|
||||
ZOOM_MIN: Class.memoize(function () prefs.get("zoom.minPercent")),
|
||||
ZOOM_MAX: Class.memoize(function () prefs.get("zoom.maxPercent")),
|
||||
ZOOM_MIN: Class.Memoize(function () prefs.get("zoom.minPercent")),
|
||||
ZOOM_MAX: Class.Memoize(function () prefs.get("zoom.maxPercent")),
|
||||
|
||||
setZoom: deprecated("buffer.setZoom", function setZoom() buffer.setZoom.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);
|
||||
},
|
||||
|
||||
active: Class.memoize(Object),
|
||||
activeGroup: Class.memoize(Object),
|
||||
commandbar: Class.memoize(function () ({ group: "Cmd" })),
|
||||
statusbar: Class.memoize(function () ({ group: "Status" })),
|
||||
active: Class.Memoize(Object),
|
||||
activeGroup: Class.Memoize(Object),
|
||||
commandbar: Class.Memoize(function () ({ group: "Cmd" })),
|
||||
statusbar: Class.Memoize(function () ({ group: "Status" })),
|
||||
|
||||
_ready: function _ready(elem) {
|
||||
return elem.contentDocument.documentURI === elem.getAttribute("src") &&
|
||||
@@ -272,9 +272,9 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
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) {
|
||||
// some host apps use "hostPrefixContext-copy" ids
|
||||
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");
|
||||
}),
|
||||
|
||||
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.contentDocument.documentElement.id = "dactyl-multiline-output-top";
|
||||
elem.contentDocument.body.id = "dactyl-multiline-output-content";
|
||||
}), 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) {
|
||||
elem.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
|
||||
@@ -584,7 +584,7 @@ var CommandLine = Module("commandline", {
|
||||
}, this);
|
||||
},
|
||||
|
||||
widgets: Class.memoize(function () CommandWidgets()),
|
||||
widgets: Class.Memoize(function () CommandWidgets()),
|
||||
|
||||
runSilently: function runSilently(func, self) {
|
||||
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. */
|
||||
profileName: Class.memoize(function () {
|
||||
profileName: Class.Memoize(function () {
|
||||
// NOTE: services.profile.selectedProfile.name doesn't return
|
||||
// what you might expect. It returns the last _actively_ selected
|
||||
// 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);
|
||||
},
|
||||
stringToURLArray: deprecated("dactyl.parseURLs", "parseURLs"),
|
||||
urlish: Class.memoize(function () util.regexp(<![CDATA[
|
||||
urlish: Class.Memoize(function () util.regexp(<![CDATA[
|
||||
^ (
|
||||
<domain>+ (:\d+)? (/ .*) |
|
||||
<domain>+ (:\d+) |
|
||||
|
||||
@@ -48,7 +48,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
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 () {
|
||||
events.dbg("NOTIFY()");
|
||||
|
||||
@@ -1103,7 +1103,7 @@ var Hints = Module("hints", {
|
||||
return true;
|
||||
},
|
||||
|
||||
translitTable: Class.memoize(function () {
|
||||
translitTable: Class.Memoize(function () {
|
||||
const table = {};
|
||||
[
|
||||
[0x00c0, 0x00c6, ["A"]], [0x00c7, 0x00c7, ["C"]],
|
||||
|
||||
@@ -60,7 +60,7 @@ var History = Module("history", {
|
||||
for (let item in iter(sh.SHistoryEnumerator, Ci.nsIHistoryEntry))
|
||||
obj.push(update(Object.create(item), {
|
||||
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;
|
||||
},
|
||||
|
||||
@@ -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). */
|
||||
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)],
|
||||
|
||||
@@ -293,7 +293,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
|
||||
delete this.states;
|
||||
},
|
||||
|
||||
states: Class.memoize(function () {
|
||||
states: Class.Memoize(function () {
|
||||
var states = {
|
||||
candidates: {},
|
||||
mappings: {}
|
||||
@@ -329,7 +329,7 @@ var Mappings = Module("mappings", {
|
||||
|
||||
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 + "-");
|
||||
|
||||
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 () {
|
||||
let appContent = document.getElementById("appcontent");
|
||||
|
||||
@@ -508,12 +508,12 @@ var Modes = Module("modes", {
|
||||
|
||||
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)
|
||||
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);
|
||||
for (let mode in array.iterValues(queue))
|
||||
if (!Set.add(seen, mode)) {
|
||||
@@ -527,7 +527,7 @@ var Modes = Module("modes", {
|
||||
|
||||
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,
|
||||
|
||||
@@ -535,15 +535,15 @@ var Modes = Module("modes", {
|
||||
|
||||
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),
|
||||
|
||||
passUnknown: Class.memoize(function () options.get("passunknown").getKey(this.name)),
|
||||
passUnknown: Class.Memoize(function () options.get("passunknown").getKey(this.name)),
|
||||
|
||||
get mask() this,
|
||||
|
||||
|
||||
@@ -81,9 +81,9 @@ var MOW = Module("mow", {
|
||||
__noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.body].concat(args)),
|
||||
|
||||
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 window() this.widget.contentWindow,
|
||||
|
||||
|
||||
@@ -99,9 +99,9 @@ var QuickMarks = Module("quickmarks", {
|
||||
*/
|
||||
list: function list(filter) {
|
||||
let marks = [k for ([k, v] in this._qmarks)];
|
||||
let lowercaseMarks = marks.filter(function (x) /[a-z]/.test(x)).sort();
|
||||
let uppercaseMarks = marks.filter(function (x) /[A-Z]/.test(x)).sort();
|
||||
let numberMarks = marks.filter(function (x) /[0-9]/.test(x)).sort();
|
||||
let lowercaseMarks = marks.filter(bind("test", /[a-z]/)).sort();
|
||||
let uppercaseMarks = marks.filter(bind("test", /[A-Z]/)).sort();
|
||||
let numberMarks = marks.filter(bind("test", /[0-9]/)).sort();
|
||||
|
||||
marks = Array.concat(lowercaseMarks, uppercaseMarks, numberMarks);
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ var Tabs = Module("tabs", {
|
||||
|
||||
_mappingCount: 0,
|
||||
|
||||
_alternates: Class.memoize(function () [config.tabbrowser.mCurrentTab, null]),
|
||||
_alternates: Class.Memoize(function () [config.tabbrowser.mCurrentTab, null]),
|
||||
|
||||
cleanup: function cleanup() {
|
||||
for (let [i, tab] in Iterator(this.allTabs)) {
|
||||
|
||||
Reference in New Issue
Block a user