X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fmodules%2Fconfig.jsm;h=4da5a88d6f50249a4fdba6cfaa07d3945cf0186c;hb=70740024f9c028c1fd63e1a1850ab062ff956054;hp=9fb101a97746fb4a4b91d4bfdc318f215a6eba48;hpb=eeed0be1a8abf7e3c97f43b63c1d595e940fef21;p=dactyl.git
diff --git a/common/modules/config.jsm b/common/modules/config.jsm
index 9fb101a..4da5a88 100644
--- a/common/modules/config.jsm
+++ b/common/modules/config.jsm
@@ -13,7 +13,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("config", {
exports: ["ConfigBase", "Config", "config"],
require: ["services", "storage", "util", "template"],
- use: ["io", "prefs"]
+ use: ["io", "messages", "prefs", "styles"]
}, this);
var ConfigBase = Class("ConfigBase", {
@@ -22,25 +22,24 @@ var ConfigBase = Class("ConfigBase", {
* initialization code. Must call superclass's init function.
*/
init: function init() {
- this.features.push = deprecated("set.add", function push(feature) set.add(this, feature));
+ this.features.push = deprecated("Set.add", function push(feature) Set.add(this, feature));
if (util.haveGecko("2b"))
- set.add(this.features, "Gecko2");
+ Set.add(this.features, "Gecko2");
this.timeout(function () {
- services["dactyl:"].pages.dtd = function () [null,
- iter(config.dtdExtra,
- (["dactyl." + k, v] for ([k, v] in iter(config.dtd))),
- (["dactyl." + s, config[s]] for each (s in config.dtdStrings)))
- .map(function ([k, v]) [""].join(""))
- .join("\n")]
+ services["dactyl:"].pages.dtd = function () [null, util.makeDTD(config.dtd)];
});
},
- loadStyles: function loadStyles() {
+ loadStyles: function loadStyles(force) {
const { highlight } = require("highlight");
+ const { _ } = require("messages");
+
highlight.styleableChrome = this.styleableChrome;
- highlight.loadCSS(this.CSS);
- highlight.loadCSS(this.helpCSS);
+
+ highlight.loadCSS(this.CSS.replace(/__MSG_(.*?)__/g, function (m0, m1) _(m1)));
+ highlight.loadCSS(this.helpCSS.replace(/__MSG_(.*?)__/g, function (m0, m1) _(m1)));
+
if (!util.haveGecko("2b"))
highlight.loadCSS();
+
+ let hl = highlight.set("Find", "");
+ hl.onChange = function () {
+ function hex(val) ("#" + util.regexp.iterate(/\d+/g, val)
+ .map(function (num) ("0" + Number(num).toString(16)).slice(-2))
+ .join("")
+ ).slice(0, 7);
+
+ let elem = services.appShell.hiddenDOMWindow.document.createElement("div");
+ elem.style.cssText = this.cssText;
+ let style = util.computedStyle(elem);
+
+ let keys = iter(Styles.propertyIter(this.cssText)).map(function (p) p.name).toArray();
+ let bg = keys.some(function (k) /^background/.test(k));
+ let fg = keys.indexOf("color") >= 0;
+
+ prefs[bg ? "safeSet" : "safeReset"]("ui.textHighlightBackground", hex(style.backgroundColor));
+ prefs[fg ? "safeSet" : "safeReset"]("ui.textHighlightForeground", hex(style.color));
+ };
},
get addonID() this.name + "@dactyl.googlecode.com",
@@ -124,50 +142,59 @@ var ConfigBase = Class("ConfigBase", {
* @returns {string}
*/
bestLocale: function (list) {
- let langs = set(list);
+ let langs = Set(list);
return values([this.appLocale, this.appLocale.replace(/-.*/, ""),
"en", "en-US", iter(langs).next()])
- .nth(function (l) set.has(langs, l), 0);
+ .nth(function (l) Set.has(langs, l), 0);
},
- haveHg: Class.memoize(function () {
+ /**
+ * @property {string} The pathname of the VCS repository clone's root
+ * directory if the application is running from one via an extension
+ * proxy file.
+ */
+ VCSPath: Class.memoize(function () {
if (/pre$/.test(this.addon.version)) {
- let uri = this.addon.getResourceURI("../.hg");
+ let uri = util.newURI(this.addon.getResourceURI("").spec + "../.hg");
if (uri instanceof Ci.nsIFileURL &&
- uri.QueryInterface(Ci.nsIFileURL).file.exists() &&
+ uri.file.exists() &&
io.pathSearch("hg"))
- return ["hg", "-R", uri.file.parent.path];
+ return uri.file.parent.path;
}
return null;
}),
+ /**
+ * @property {string} The name of the VCS branch that the application is
+ * running from if using an extension proxy file or was built from if
+ * installed as an XPI.
+ */
branch: Class.memoize(function () {
- if (this.haveHg)
- return io.system(this.haveHg.concat(["branch"])).output;
+ if (this.VCSPath)
+ return io.system(["hg", "-R", this.VCSPath, "branch"]).output;
return (/pre-hg\d+-(\S*)/.exec(this.version) || [])[1];
}),
/** @property {string} The Dactyl version string. */
version: Class.memoize(function () {
- if (/pre$/.test(this.addon.version)) {
- let uri = this.addon.getResourceURI("../.hg");
- if (uri instanceof Ci.nsIFileURL &&
- uri.QueryInterface(Ci.nsIFileURL).file.exists() &&
- io.pathSearch("hg")) {
- return io.system(["hg", "-R", uri.file.parent.path,
- "log", "-r.",
- "--template=hg{rev}-" + this.branch + " ({date|isodate})"]).output;
- }
- }
+ if (this.VCSPath)
+ return io.system(["hg", "-R", this.VCSPath, "log", "-r.",
+ "--template=hg{rev}-" + this.branch + " ({date|isodate})"]).output;
let version = this.addon.version;
if ("@DATE@" !== "@" + "DATE@")
- version += " (created: @DATE@)";
+ version += " " + _("dactyl.created", "@DATE@");
return version;
}),
- get fileExt() this.name.slice(0, -5),
+ get fileExt() this.name.slice(0, -6),
- dtd: memoize({
+ dtd: Class.memoize(function ()
+ iter(this.dtdExtra,
+ (["dactyl." + k, v] for ([k, v] in iter(config.dtdDactyl))),
+ (["dactyl." + s, config[s]] for each (s in config.dtdStrings)))
+ .toObject()),
+
+ dtdDactyl: memoize({
get name() config.name,
get home() "http://dactyl.sourceforge.net/",
get apphome() this.home + this.name,
@@ -188,8 +215,9 @@ var ConfigBase = Class("ConfigBase", {
"xmlns.html": "http://www.w3.org/1999/xhtml",
"xmlns.xul": "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
- "tag.command-line": 'command line',
- "tag.status-line": 'status line',
+ "tag.command-line": command line,
+ "tag.status-line": status line,
+ "mode.command-line": Command Line,
},
dtdStrings: [
@@ -202,7 +230,7 @@ var ConfigBase = Class("ConfigBase", {
"version"
],
- helpStyles: /^(Help|StatusLine|REPL)|^(Boolean|Indicator|MoreMsg|Number|Object|Logo|Key(word)?|String)$/,
+ helpStyles: /^(Help|StatusLine|REPL)|^(Boolean|Dense|Indicator|MoreMsg|Number|Object|Logo|Key(word)?|String)$/,
styleHelp: function styleHelp() {
if (!this.helpStyled) {
const { highlight } = require("highlight");
@@ -222,12 +250,12 @@ var ConfigBase = Class("ConfigBase", {
;
for each (let [id, [name, key, uri]] in Iterator(this.sidebars)) {
append.XUL::menupopup[0].* +=
-