mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-11 17:25:46 +01:00
Add 'linenumbers'.
This commit is contained in:
@@ -122,7 +122,12 @@ if (!Object.keys)
|
||||
|
||||
let getGlobalForObject = Cu.getGlobalForObject || function (obj) obj.__parent__;
|
||||
|
||||
let jsmodules = {};
|
||||
let jsmodules = {
|
||||
lazyRequire: function lazyRequire(module, names, target) {
|
||||
for each (let name in names)
|
||||
memoize(target || this, name, function (name) require(module)[name]);
|
||||
}
|
||||
};
|
||||
let use = {};
|
||||
let loaded = {};
|
||||
let currentModule;
|
||||
@@ -229,6 +234,8 @@ defineModule("base", {
|
||||
]
|
||||
}, this);
|
||||
|
||||
this.lazyRequire("messages", ["_", "Messages"]);
|
||||
|
||||
/**
|
||||
* Returns a list of all of the top-level properties of an object, by
|
||||
* way of the debugger.
|
||||
@@ -325,7 +332,7 @@ deprecated.warn = function warn(func, name, alternative, frame) {
|
||||
let filename = util.fixURI(frame.filename || "unknown");
|
||||
if (!Set.add(func.seenCaller, filename))
|
||||
util.dactyl(func).warn([util.urlPath(filename), frame.lineNumber, " "].join(":")
|
||||
+ require("messages")._("warn.deprecated", name, alternative));
|
||||
+ _("warn.deprecated", name, alternative));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1242,7 +1249,7 @@ var StructBase = Class("StructBase", Array, {
|
||||
|
||||
localize: function localize(key, defaultValue) {
|
||||
let i = this.prototype.members[key];
|
||||
Object.defineProperty(this.prototype, i, require("messages").Messages.Localized(defaultValue).init(key, this.prototype));
|
||||
Object.defineProperty(this.prototype, i, Messages.Localized(defaultValue).init(key, this.prototype));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -13,6 +13,10 @@ defineModule("config", {
|
||||
require: ["dom", "protocol", "services", "storage", "util", "template"]
|
||||
}, this);
|
||||
|
||||
this.lazyRequire("addons", ["AddonManager"]);
|
||||
this.lazyRequire("highlight", ["highlight"]);
|
||||
this.lazyRequire("messages", ["_"]);
|
||||
|
||||
function AboutHandler() {}
|
||||
AboutHandler.prototype = {
|
||||
get classDescription() "About " + config.appName + " Page",
|
||||
@@ -102,9 +106,6 @@ var ConfigBase = Class("ConfigBase", {
|
||||
},
|
||||
|
||||
loadStyles: function loadStyles(force) {
|
||||
const { highlight } = require("highlight");
|
||||
const { _ } = require("messages");
|
||||
|
||||
highlight.styleableChrome = this.styleableChrome;
|
||||
|
||||
highlight.loadCSS(this.CSS.replace(/__MSG_(.*?)__/g, function (m0, m1) _(m1)));
|
||||
@@ -145,7 +146,7 @@ var ConfigBase = Class("ConfigBase", {
|
||||
|
||||
addon: Class.Memoize(function () {
|
||||
return (JSMLoader.bootstrap || {}).addon ||
|
||||
require("addons").AddonManager.getAddonByID(this.addonID);
|
||||
AddonManager.getAddonByID(this.addonID);
|
||||
}),
|
||||
|
||||
/**
|
||||
@@ -311,6 +312,21 @@ var ConfigBase = Class("ConfigBase", {
|
||||
return (/pre-hg\d+-(\S*)/.exec(this.version) || [])[1];
|
||||
}),
|
||||
|
||||
/** @property {string} The name of the current user profile. */
|
||||
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
|
||||
// current profile. These will differ if the current process was run
|
||||
// without explicitly selecting a profile.
|
||||
|
||||
let dir = services.directory.get("ProfD", Ci.nsIFile);
|
||||
for (let prof in iter(services.profile.profiles))
|
||||
if (prof.QueryInterface(Ci.nsIToolkitProfile).rootDir.path === dir.path)
|
||||
return prof.name;
|
||||
return "unknown";
|
||||
}),
|
||||
|
||||
/** @property {string} The Dactyl version string. */
|
||||
version: Class.Memoize(function () {
|
||||
if (this.VCSPath)
|
||||
@@ -375,7 +391,6 @@ var ConfigBase = Class("ConfigBase", {
|
||||
helpStyles: /^(Help|StatusLine|REPL)|^(Boolean|Dense|Indicator|MoreMsg|Number|Object|Logo|Key(word)?|String)$/,
|
||||
styleHelp: function styleHelp() {
|
||||
if (!this.helpStyled) {
|
||||
const { highlight } = require("highlight");
|
||||
for (let k in keys(highlight.loaded))
|
||||
if (this.helpStyles.test(k))
|
||||
highlight.loaded[k] = true;
|
||||
@@ -1064,7 +1079,6 @@ config.INIT = update(Object.create(config.INIT), config.INIT, {
|
||||
let img = window.Image();
|
||||
img.src = this.logo || "resource://dactyl-local-content/logo.png";
|
||||
img.onload = util.wrapCallback(function () {
|
||||
const { highlight } = require("highlight");
|
||||
highlight.loadCSS(<>{"!Logo {"}
|
||||
display: inline-block;
|
||||
background: url({img.src});
|
||||
|
||||
@@ -1324,7 +1324,7 @@ var DOM = Class("DOM", {
|
||||
yield elem;
|
||||
|
||||
if (matcher.css)
|
||||
for (let [, elem] in iter(node.querySelectorAll(matcher.css)))
|
||||
for (let [, elem] in iter(util.withProperErrors("querySelectorAll", node, matcher.css)))
|
||||
yield elem;
|
||||
}, {
|
||||
css: css.join(", "),
|
||||
@@ -1343,13 +1343,15 @@ var DOM = Class("DOM", {
|
||||
validateMatcher: function validateMatcher(list) {
|
||||
let evaluator = services.XPathEvaluator();
|
||||
let node = services.XMLDocument();
|
||||
return this.testValues(list, function (value) {
|
||||
if (/^xpath:/.test(value))
|
||||
evaluator.createExpression(value.substr(6), DOM.XPath.resolver);
|
||||
else
|
||||
node.querySelector(value);
|
||||
return true;
|
||||
});
|
||||
return this.testValues(list, this.closure.testMatcher);
|
||||
},
|
||||
|
||||
testMatcher: function testMatcher(value) {
|
||||
if (/^xpath:/.test(value))
|
||||
evaluator.createExpression(value.substr(6), DOM.XPath.resolver);
|
||||
else
|
||||
node.querySelector(value);
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,8 +12,6 @@ defineModule("finder", {
|
||||
|
||||
function equals(a, b) XPCNativeWrapper(a) == XPCNativeWrapper(b);
|
||||
|
||||
try {
|
||||
|
||||
/** @instance rangefinder */
|
||||
var RangeFinder = Module("rangefinder", {
|
||||
Local: function (dactyl, modules, window) ({
|
||||
@@ -265,7 +263,6 @@ var RangeFinder = Module("rangefinder", {
|
||||
},
|
||||
options: function (dactyl, modules, window) {
|
||||
const { options, rangefinder } = modules;
|
||||
const { prefs } = require("prefs");
|
||||
|
||||
options.add(["hlfind", "hlf"],
|
||||
"Highlight all /find pattern matches on the current page after submission",
|
||||
@@ -844,9 +841,8 @@ var RangeFind = Class("RangeFind", {
|
||||
}
|
||||
});
|
||||
|
||||
} catch(e){ if (typeof e === "string") e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
|
||||
// catch(e){ if (typeof e === "string") e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
|
||||
|
||||
endModule();
|
||||
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et ft=javascript:
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("storage", {
|
||||
exports: ["File", "Storage", "storage"],
|
||||
require: ["services", "util"]
|
||||
require: ["config", "services", "util"]
|
||||
}, this);
|
||||
|
||||
this.lazyRequire("io", ["IO"]);
|
||||
|
||||
var win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
||||
var myObject = JSON.parse("{}").constructor;
|
||||
|
||||
@@ -169,6 +171,10 @@ var Storage = Module("Storage", {
|
||||
this.observers = {};
|
||||
},
|
||||
|
||||
infoPath: Class.Memoize(function ()
|
||||
File(IO.runtimePath.replace(/,.*/, ""))
|
||||
.child("info").child(config.profileName)),
|
||||
|
||||
exists: function exists(name) this.infoPath.child(name).exists(),
|
||||
|
||||
newObject: function newObject(key, constructor, params) {
|
||||
@@ -270,12 +276,6 @@ var Storage = Module("Storage", {
|
||||
skipXpcom: function skipXpcom(key, val) val instanceof Ci.nsISupports ? null : val
|
||||
}
|
||||
}, {
|
||||
init: function init(dactyl, modules) {
|
||||
init.superapply(this, arguments);
|
||||
storage.infoPath = File(modules.IO.runtimePath.replace(/,.*/, ""))
|
||||
.child("info").child(dactyl.profileName);
|
||||
},
|
||||
|
||||
cleanup: function (dactyl, modules, window) {
|
||||
overlay.setData(window, "storage-refs", null);
|
||||
this.removeDeadObservers();
|
||||
|
||||
Reference in New Issue
Block a user