mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-18 01:14:12 +01:00
[bootstrap] Merge default.
--HG-- branch : bootstrapped
This commit is contained in:
@@ -8,11 +8,7 @@
|
||||
|
||||
/** @scope modules */
|
||||
|
||||
let ValueError = Class("ValueError", Error, {
|
||||
init: function (message) {
|
||||
update(this, Error(message));
|
||||
}
|
||||
});
|
||||
let ValueError = Class("ValueError", ErrorBase);
|
||||
|
||||
// do NOT create instances of this class yourself, use the helper method
|
||||
// options.add() instead
|
||||
|
||||
@@ -176,7 +176,7 @@ function require(obj, name, from) {
|
||||
defineModule("base", {
|
||||
// sed -n 's/^(const|function) ([a-zA-Z0-9_]+).*/ "\2",/p' base.jsm | sort | fmt
|
||||
exports: [
|
||||
"Cc", "Ci", "Class", "Cr", "Cu", "Module", "Object", "Runnable",
|
||||
"ErrorBase", "Cc", "Ci", "Class", "Cr", "Cu", "Module", "Object", "Runnable",
|
||||
"Struct", "StructBase", "Timer", "UTF8", "XPCOM", "XPCOMUtils", "array",
|
||||
"call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule",
|
||||
"deprecated", "endModule", "forEach", "isArray", "isGenerator",
|
||||
@@ -857,6 +857,26 @@ function XPCOM(interfaces, superClass) {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* An abstract base class for classes that wish to inherit from Error.
|
||||
*/
|
||||
const ErrorBase = Class("ErrorBase", Error, {
|
||||
level: 2,
|
||||
init: function (message, level) {
|
||||
level = level || 0;
|
||||
update(this, Error(message))
|
||||
this.message = message;
|
||||
|
||||
let frame = Components.stack;
|
||||
for (let i = 0; i < this.level + level; i++) {
|
||||
frame = frame.caller;
|
||||
this.stack = this.stack.replace(/^.*\n/, "");
|
||||
}
|
||||
this.fileName = frame.filename;
|
||||
this.lineNumber = frame.lineNumber;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Constructs a new Module class and instantiates an instance into the current
|
||||
* module global object.
|
||||
|
||||
@@ -356,17 +356,39 @@ const Styles = Module("Styles", {
|
||||
}, {
|
||||
commands: function (dactyl, modules, window) {
|
||||
const commands = modules.commands;
|
||||
|
||||
const queue = [];
|
||||
const timer = Timer(10, 10, function () {
|
||||
let args = queue.shift()
|
||||
let [filter, css] = args;
|
||||
if ("-append" in args) {
|
||||
let sheet = styles.user.get(args["-name"]);
|
||||
if (sheet) {
|
||||
filter = sheet.sites.concat(filter).join(",");
|
||||
css = sheet.css + " " + css;
|
||||
|
||||
}
|
||||
}
|
||||
styles.user.add(args["-name"], filter, css, args["-agent"]);
|
||||
|
||||
if (queue.length)
|
||||
timer.tell();
|
||||
});
|
||||
commands.add(["sty[le]"],
|
||||
"Add or list user styles",
|
||||
function (args) {
|
||||
let [filter, css] = args;
|
||||
let name = args["-name"];
|
||||
|
||||
if (!css) {
|
||||
if (css) {
|
||||
queue.push(args);
|
||||
timer.tell(args);
|
||||
}
|
||||
else {
|
||||
let list = styles.user.sheets.slice()
|
||||
.sort(function (a, b) a.name && b.name ? String.localeCompare(a.name, b.name)
|
||||
: !!b.name - !!a.name || a.id - b.id);
|
||||
let uris = util.visibleURIs(window.content);
|
||||
let name = args["-name"];
|
||||
modules.commandline.commandOutput(
|
||||
template.tabular(["", "Name", "Filter", "CSS"],
|
||||
["min-width: 1em; text-align: center; color: red; font-weight: bold;",
|
||||
@@ -379,17 +401,6 @@ const Styles = Module("Styles", {
|
||||
for (sheet in values(list))
|
||||
if ((!filter || sheet.sites.indexOf(filter) >= 0) && (!name || sheet.name == name)))));
|
||||
}
|
||||
else {
|
||||
if ("-append" in args) {
|
||||
let sheet = styles.user.get(name);
|
||||
if (sheet) {
|
||||
filter = sheet.sites.concat(filter).join(",");
|
||||
css = sheet.css + " " + css;
|
||||
|
||||
}
|
||||
}
|
||||
styles.user.add(name, filter, css, args["-agent"]);
|
||||
}
|
||||
},
|
||||
{
|
||||
bang: true,
|
||||
|
||||
@@ -28,12 +28,7 @@ memoize(this, "Commands", function () {
|
||||
return obj.Commands;
|
||||
});
|
||||
|
||||
const FailedAssertion = Class("FailedAssertion", Error, {
|
||||
init: function (message) {
|
||||
update(this, Error(message))
|
||||
this.message = message;
|
||||
}
|
||||
});
|
||||
const FailedAssertion = Class("FailedAssertion", ErrorBase);
|
||||
|
||||
function wrapCallback(fn)
|
||||
fn.wrapper = function wrappedCallback () {
|
||||
@@ -126,7 +121,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
*/
|
||||
assert: function (condition, message) {
|
||||
if (!condition)
|
||||
throw FailedAssertion(message);
|
||||
throw FailedAssertion(message, 1);
|
||||
},
|
||||
|
||||
get chromePackages() {
|
||||
|
||||
Reference in New Issue
Block a user