1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 23:37:59 +01:00

Fix a typo in styles.jsm. Closes issue #49.

This commit is contained in:
Kris Maglione
2010-10-06 17:38:23 -04:00
parent 28f51ef202
commit 312244c00c
3 changed files with 61 additions and 55 deletions

View File

@@ -211,37 +211,10 @@ const Dactyl = Module("dactyl", {
} }
}, },
/** dump: deprecated("Use util.dump instead",
* Prints a message to the console. If <b>msg</b> is an object it is function dump() util.dump.apply(util, arguments)),
* pretty printed. dumpStack: deprecated("Use util.dumpStack instead",
* function dumpStack() util.dumpStack.apply(util, arguments)),
* NOTE: the "browser.dom.window.dump.enabled" preference needs to be
* set.
*
* @param {string|Object} msg The message to print.
*/
dump: function dump() {
let msg = Array.map(arguments, function (msg) {
if (typeof msg == "object")
msg = util.objectToString(msg);
return msg;
}).join(", ");
msg = String.replace(msg, /\n?$/, "\n");
window.dump(msg.replace(/^./gm, ("config" in modules && config.name) + ": $&"));
},
/**
* Dumps a stack trace to the console.
*
* @param {string} msg The trace message.
* @param {number} frames The number of frames to print.
*/
dumpStack: function dumpStack(msg, frames) {
let stack = Error().stack.replace(/(?:.*\n){1}/, "");
if (frames != null)
[stack] = stack.match(RegExp("(?:.*\n){0," + frames + "}"));
dactyl.dump((msg || "Stack") + "\n" + stack + "\n");
},
/** /**
* Outputs a plain message to the command line. * Outputs a plain message to the command line.
@@ -1001,29 +974,7 @@ const Dactyl = Module("dactyl", {
return; return;
if (echo) if (echo)
dactyl.echoerr(error); dactyl.echoerr(error);
util.reportError(error);
if (Cu.reportError)
Cu.reportError(error);
try {
let obj = {
toString: function () String(error),
stack: <>{String.replace(error.stack || Error().stack, /^/mg, "\t")}</>
};
for (let [k, v] in Iterator(error)) {
if (!(k in obj))
obj[k] = v;
}
if (dactyl.storeErrors) {
let errors = storage.newArray("errors", { store: false });
errors.toString = function () [String(v[0]) + "\n" + v[1] for ([k, v] in this)].join("\n\n");
errors.push([new Date, obj + obj.stack]);
}
dactyl.dump(String(error));
dactyl.dump(obj);
dactyl.dump("");
}
catch (e) { window.dump(e); }
}, },
/** /**

View File

@@ -81,7 +81,7 @@ const Highlights = Module("Highlight", {
if (/^[[>+ ]/.test(args[1])) if (/^[[>+ ]/.test(args[1]))
obj.selector = this.selector(obj.class) + args[1]; obj.selector = this.selector(obj.class) + args[1];
if (old && old.value != old.default) if (old && old.value != old.default)
obj.value = old.style; obj.value = old.value;
if (!old && obj.base && obj.base.enabled) if (!old && obj.base && obj.base.enabled)
obj.style.enabled = true; obj.style.enabled = true;

View File

@@ -226,6 +226,38 @@ const Util = Module("Util", {
dequote: function dequote(pattern, chars) dequote: function dequote(pattern, chars)
pattern.replace(/\\(.)/, function (m0, m1) chars.indexOf(m1) >= 0 ? m1 : m0), pattern.replace(/\\(.)/, function (m0, m1) chars.indexOf(m1) >= 0 ? m1 : m0),
/**
* Prints a message to the console. If <b>msg</b> is an object it is
* pretty printed.
*
* NOTE: the "browser.dom.window.dump.enabled" preference needs to be
* set.
*
* @param {string|Object} msg The message to print.
*/
dump: function dump_() {
let msg = Array.map(arguments, function (msg) {
if (typeof msg == "object")
msg = util.objectToString(msg);
return msg;
}).join(", ");
msg = String.replace(msg, /\n?$/, "\n");
dump(msg.replace(/^./gm, services.get("dactyl:").name + ": $&"));
},
/**
* Dumps a stack trace to the console.
*
* @param {string} msg The trace message.
* @param {number} frames The number of frames to print.
*/
dumpStack: function dumpStack(msg, frames) {
let stack = Error().stack.replace(/(?:.*\n){1}/, "");
if (frames != null)
[stack] = stack.match(RegExp("(?:.*\n){0," + frames + "}"));
util.dump((msg || "Stack") + "\n" + stack + "\n");
},
/** /**
* Converts HTML special characters in <b>str</b> to the equivalent HTML * Converts HTML special characters in <b>str</b> to the equivalent HTML
* entities. * entities.
@@ -644,6 +676,29 @@ const Util = Module("Util", {
} }
}, },
reportError: function (error) {
if (Cu.reportError)
Cu.reportError(error);
try {
let obj = update({}, error, {
toString: function () String(error),
stack: <>{String.replace(error.stack || Error().stack, /^/mg, "\t")}</>
});
let errors = storage.newArray("errors", { store: false });
errors.toString = function () [String(v[0]) + "\n" + v[1] for ([k, v] in this)].join("\n\n");
errors.push([new Date, obj + obj.stack]);
util.dump(String(error));
util.dump(obj);
util.dump("");
}
catch (e) {
dump(e);
}
},
/** /**
* An interruptible generator that returns all values between <b>start</b> * An interruptible generator that returns all values between <b>start</b>
* and <b>end</b>. The thread yields every <b>time</b> milliseconds. * and <b>end</b>. The thread yields every <b>time</b> milliseconds.