mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-19 22:27:58 +01:00
Merge changes from bootstrapped.
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
/** @scope modules */
|
/** @scope modules */
|
||||||
|
|
||||||
const Abbreviation = Class("Abbreviation", {
|
var Abbreviation = Class("Abbreviation", {
|
||||||
init: function (modes, lhs, rhs) {
|
init: function (modes, lhs, rhs) {
|
||||||
this.modes = modes.sort();
|
this.modes = modes.sort();
|
||||||
this.lhs = lhs;
|
this.lhs = lhs;
|
||||||
@@ -41,7 +41,7 @@ const Abbreviation = Class("Abbreviation", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const Abbreviations = Module("abbreviations", {
|
var Abbreviations = Module("abbreviations", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.abbrevs = {};
|
this.abbrevs = {};
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
/** @scope modules */
|
/** @scope modules */
|
||||||
|
|
||||||
const AutoCommand = Struct("event", "pattern", "command");
|
var AutoCommand = Struct("event", "pattern", "command");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @instance autocommands
|
* @instance autocommands
|
||||||
*/
|
*/
|
||||||
const AutoCommands = Module("autocommands", {
|
var AutoCommands = Module("autocommands", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this._store = [];
|
this._store = [];
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const DEFAULT_FAVICON = "chrome://mozapps/skin/places/defaultFavicon.png";
|
var DEFAULT_FAVICON = "chrome://mozapps/skin/places/defaultFavicon.png";
|
||||||
|
|
||||||
// also includes methods for dealing with keywords and search engines
|
// also includes methods for dealing with keywords and search engines
|
||||||
const Bookmarks = Module("bookmarks", {
|
var Bookmarks = Module("bookmarks", {
|
||||||
init: function () {
|
init: function () {
|
||||||
storage.addObserver("bookmark-cache", function (key, event, arg) {
|
storage.addObserver("bookmark-cache", function (key, event, arg) {
|
||||||
if (["add", "change", "remove"].indexOf(event) >= 0)
|
if (["add", "change", "remove"].indexOf(event) >= 0)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
/**
|
/**
|
||||||
* @instance browser
|
* @instance browser
|
||||||
*/
|
*/
|
||||||
const Browser = Module("browser", {
|
var Browser = Module("browser", {
|
||||||
}, {
|
}, {
|
||||||
climbUrlPath: function (count) {
|
climbUrlPath: function (count) {
|
||||||
let url = util.newURI(buffer.URL);
|
let url = util.newURI(buffer.URL);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
/** @scope modules */
|
/** @scope modules */
|
||||||
|
|
||||||
const Point = Struct("x", "y");
|
var Point = Struct("x", "y");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class to manage the primary web content buffer. The name comes
|
* A class to manage the primary web content buffer. The name comes
|
||||||
@@ -16,7 +16,7 @@ const Point = Struct("x", "y");
|
|||||||
* files.
|
* files.
|
||||||
* @instance buffer
|
* @instance buffer
|
||||||
*/
|
*/
|
||||||
const Buffer = Module("buffer", {
|
var Buffer = Module("buffer", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.evaluateXPath = util.evaluateXPath;
|
this.evaluateXPath = util.evaluateXPath;
|
||||||
this.pageInfo = {};
|
this.pageInfo = {};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
/** @scope modules */
|
/** @scope modules */
|
||||||
|
|
||||||
const CommandWidgets = Class("CommandWidgets", {
|
var CommandWidgets = Class("CommandWidgets", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.elements = {};
|
this.elements = {};
|
||||||
this.addElement({
|
this.addElement({
|
||||||
@@ -200,7 +200,7 @@ const CommandWidgets = Class("CommandWidgets", {
|
|||||||
* It consists of a prompt and command field be sure to only create objects of
|
* It consists of a prompt and command field be sure to only create objects of
|
||||||
* this class when the chrome is ready.
|
* this class when the chrome is ready.
|
||||||
*/
|
*/
|
||||||
const CommandLine = Module("commandline", {
|
var CommandLine = Module("commandline", {
|
||||||
init: function () {
|
init: function () {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
@@ -1766,7 +1766,7 @@ const CommandLine = Module("commandline", {
|
|||||||
* must be in its own container element, whose height it will update as
|
* must be in its own container element, whose height it will update as
|
||||||
* necessary.
|
* necessary.
|
||||||
*/
|
*/
|
||||||
const ItemList = Class("ItemList", {
|
var ItemList = Class("ItemList", {
|
||||||
init: function (id) {
|
init: function (id) {
|
||||||
this._completionElements = [];
|
this._completionElements = [];
|
||||||
|
|
||||||
|
|||||||
@@ -35,12 +35,12 @@
|
|||||||
* @property {string} description A description of the option
|
* @property {string} description A description of the option
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const CommandOption = Struct("names", "type", "validator", "completer", "multiple", "description", "default");
|
var CommandOption = Struct("names", "type", "validator", "completer", "multiple", "description", "default");
|
||||||
CommandOption.defaultValue("description", function () "");
|
CommandOption.defaultValue("description", function () "");
|
||||||
CommandOption.defaultValue("type", function () CommandOption.NOARG);
|
CommandOption.defaultValue("type", function () CommandOption.NOARG);
|
||||||
CommandOption.defaultValue("multiple", function () false);
|
CommandOption.defaultValue("multiple", function () false);
|
||||||
|
|
||||||
const ArgType = Struct("description", "parse");
|
var ArgType = Struct("description", "parse");
|
||||||
update(CommandOption, {
|
update(CommandOption, {
|
||||||
/**
|
/**
|
||||||
* @property {object} The option argument is unspecified. Any argument
|
* @property {object} The option argument is unspecified. Any argument
|
||||||
@@ -108,7 +108,7 @@ update(CommandOption, {
|
|||||||
* @optional
|
* @optional
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
const Command = Class("Command", {
|
var Command = Class("Command", {
|
||||||
init: function (specs, description, action, extraInfo) {
|
init: function (specs, description, action, extraInfo) {
|
||||||
specs = Array.concat(specs); // XXX
|
specs = Array.concat(specs); // XXX
|
||||||
let parsedSpecs = Command.parseSpecs(specs);
|
let parsedSpecs = Command.parseSpecs(specs);
|
||||||
@@ -377,7 +377,7 @@ const Command = Class("Command", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Prototype.
|
// Prototype.
|
||||||
const ex = {
|
var ex = {
|
||||||
_args: function (cmd, args) {
|
_args: function (cmd, args) {
|
||||||
args = Array.slice(args);
|
args = Array.slice(args);
|
||||||
|
|
||||||
@@ -427,7 +427,7 @@ const ex = {
|
|||||||
/**
|
/**
|
||||||
* @instance commands
|
* @instance commands
|
||||||
*/
|
*/
|
||||||
const Commands = Module("commands", {
|
var Commands = Module("commands", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this._exCommands = [];
|
this._exCommands = [];
|
||||||
this._exMap = {};
|
this._exMap = {};
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
* @author Kris Maglione <maglione.k@gmail.com>
|
* @author Kris Maglione <maglione.k@gmail.com>
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
const CompletionContext = Class("CompletionContext", {
|
var CompletionContext = Class("CompletionContext", {
|
||||||
init: function (editor, name, offset) {
|
init: function (editor, name, offset) {
|
||||||
if (!name)
|
if (!name)
|
||||||
name = "";
|
name = "";
|
||||||
@@ -825,7 +825,7 @@ const CompletionContext = Class("CompletionContext", {
|
|||||||
/**
|
/**
|
||||||
* @instance completion
|
* @instance completion
|
||||||
*/
|
*/
|
||||||
const Completion = Module("completion", {
|
var Completion = Module("completion", {
|
||||||
init: function () {
|
init: function () {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ConfigBase = Class(ModuleBase, {
|
var ConfigBase = Class(ModuleBase, {
|
||||||
/**
|
/**
|
||||||
* Called on dactyl startup to allow for any arbitrary application-specific
|
* Called on dactyl startup to allow for any arbitrary application-specific
|
||||||
* initialization code. Must call superclass's init function.
|
* initialization code. Must call superclass's init function.
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ default xml namespace = XHTML;
|
|||||||
XML.ignoreWhitespace = false;
|
XML.ignoreWhitespace = false;
|
||||||
XML.prettyPrinting = false;
|
XML.prettyPrinting = false;
|
||||||
|
|
||||||
const plugins = { __proto__: modules };
|
var plugins = { __proto__: modules };
|
||||||
const userContext = newContext(modules);
|
var userContext = newContext(modules);
|
||||||
|
|
||||||
const EVAL_ERROR = "__dactyl_eval_error";
|
var EVAL_ERROR = "__dactyl_eval_error";
|
||||||
const EVAL_RESULT = "__dactyl_eval_result";
|
var EVAL_RESULT = "__dactyl_eval_result";
|
||||||
const EVAL_STRING = "__dactyl_eval_string";
|
var EVAL_STRING = "__dactyl_eval_string";
|
||||||
|
|
||||||
const Dactyl = Module("dactyl", {
|
var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||||
init: function () {
|
init: function () {
|
||||||
window.dactyl = this;
|
window.dactyl = this;
|
||||||
// cheap attempt at compatibility
|
// cheap attempt at compatibility
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
// http://developer.mozilla.org/en/docs/Editor_Embedding_Guide
|
// http://developer.mozilla.org/en/docs/Editor_Embedding_Guide
|
||||||
|
|
||||||
/** @instance editor */
|
/** @instance editor */
|
||||||
const Editor = Module("editor", {
|
var Editor = Module("editor", {
|
||||||
get isCaret() modes.getStack(1).main == modes.CARET,
|
get isCaret() modes.getStack(1).main == modes.CARET,
|
||||||
get isTextEdit() modes.getStack(1).main == modes.TEXT_EDIT,
|
get isTextEdit() modes.getStack(1).main == modes.TEXT_EDIT,
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
/**
|
/**
|
||||||
* @instance events
|
* @instance events
|
||||||
*/
|
*/
|
||||||
const Events = Module("events", {
|
var Events = Module("events", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this._fullscreen = window.fullScreen;
|
this._fullscreen = window.fullScreen;
|
||||||
this._lastFocus = null;
|
this._lastFocus = null;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
/** @scope modules */
|
/** @scope modules */
|
||||||
|
|
||||||
/** @instance rangefinder */
|
/** @instance rangefinder */
|
||||||
const RangeFinder = Module("rangefinder", {
|
var RangeFinder = Module("rangefinder", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.lastFindPattern = "";
|
this.lastFindPattern = "";
|
||||||
},
|
},
|
||||||
@@ -251,7 +251,7 @@ const RangeFinder = Module("rangefinder", {
|
|||||||
* documents, and represents a major detriment to productivity where
|
* documents, and represents a major detriment to productivity where
|
||||||
* large amounts of data are concerned (e.g., for API documents).
|
* large amounts of data are concerned (e.g., for API documents).
|
||||||
*/
|
*/
|
||||||
const RangeFind = Class("RangeFind", {
|
var RangeFind = Class("RangeFind", {
|
||||||
init: function (matchCase, backward, elementPath, regexp) {
|
init: function (matchCase, backward, elementPath, regexp) {
|
||||||
this.window = Cu.getWeakReference(window);
|
this.window = Cu.getWeakReference(window);
|
||||||
this.baseDocument = Cu.getWeakReference(content.document);
|
this.baseDocument = Cu.getWeakReference(content.document);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
/** @scope modules */
|
/** @scope modules */
|
||||||
/** @instance hints */
|
/** @instance hints */
|
||||||
|
|
||||||
const Hints = Module("hints", {
|
var Hints = Module("hints", {
|
||||||
init: function init() {
|
init: function init() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const History = Module("history", {
|
var History = Module("history", {
|
||||||
get format() bookmarks.format,
|
get format() bookmarks.format,
|
||||||
|
|
||||||
get service() services.history,
|
get service() services.history,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ function Script(file) {
|
|||||||
* Provides a basic interface to common system I/O operations.
|
* Provides a basic interface to common system I/O operations.
|
||||||
* @instance io
|
* @instance io
|
||||||
*/
|
*/
|
||||||
const IO = Module("io", {
|
var IO = Module("io", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this._processDir = services.directory.get("CurWorkD", Ci.nsIFile);
|
this._processDir = services.directory.get("CurWorkD", Ci.nsIFile);
|
||||||
this._cwd = this._processDir.path;
|
this._cwd = this._processDir.path;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
// TODO: Clean this up.
|
// TODO: Clean this up.
|
||||||
|
|
||||||
const JavaScript = Module("javascript", {
|
var JavaScript = Module("javascript", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this._stack = [];
|
this._stack = [];
|
||||||
this._functions = [];
|
this._functions = [];
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
* @optional
|
* @optional
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
const Map = Class("Map", {
|
var Map = Class("Map", {
|
||||||
init: function (modes, keys, description, action, extraInfo) {
|
init: function (modes, keys, description, action, extraInfo) {
|
||||||
modes = Array.concat(modes).map(function (m) isObject(m) ? m.mask : m);
|
modes = Array.concat(modes).map(function (m) isObject(m) ? m.mask : m);
|
||||||
if (!modes.every(util.identity))
|
if (!modes.every(util.identity))
|
||||||
@@ -127,7 +127,7 @@ const Map = Class("Map", {
|
|||||||
/**
|
/**
|
||||||
* @instance mappings
|
* @instance mappings
|
||||||
*/
|
*/
|
||||||
const Mappings = Module("mappings", {
|
var Mappings = Module("mappings", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this._main = []; // default mappings
|
this._main = []; // default mappings
|
||||||
this._user = []; // user created mappings
|
this._user = []; // user created mappings
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
* @scope modules
|
* @scope modules
|
||||||
* @instance marks
|
* @instance marks
|
||||||
*/
|
*/
|
||||||
const Marks = Module("marks", {
|
var Marks = Module("marks", {
|
||||||
init: function init() {
|
init: function init() {
|
||||||
function replacer(key, val) val instanceof Ci.nsISupports ? null : val;
|
function replacer(key, val) val instanceof Ci.nsISupports ? null : val;
|
||||||
this._localMarks = storage.newMap("local-marks", { privateData: true, replacer: replacer, store: true });
|
this._localMarks = storage.newMap("local-marks", { privateData: true, replacer: replacer, store: true });
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
/** @scope modules */
|
/** @scope modules */
|
||||||
|
|
||||||
const Modes = Module("modes", {
|
var Modes = Module("modes", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.modeChars = {};
|
this.modeChars = {};
|
||||||
this._main = 1; // NORMAL
|
this._main = 1; // NORMAL
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
* @class ModuleBase
|
* @class ModuleBase
|
||||||
* The base class for all modules.
|
* The base class for all modules.
|
||||||
*/
|
*/
|
||||||
const ModuleBase = Class("ModuleBase", {
|
var ModuleBase = Class("ModuleBase", {
|
||||||
/**
|
/**
|
||||||
* @property {[string]} A list of module prerequisites which
|
* @property {[string]} A list of module prerequisites which
|
||||||
* must be initialized before this module is loaded.
|
* must be initialized before this module is loaded.
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ let ValueError = Class("ValueError", ErrorBase);
|
|||||||
* @optional
|
* @optional
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
const Option = Class("Option", {
|
var Option = Class("Option", {
|
||||||
init: function (names, description, type, defaultValue, extraInfo) {
|
init: function (names, description, type, defaultValue, extraInfo) {
|
||||||
this.name = names[0];
|
this.name = names[0];
|
||||||
this.names = names;
|
this.names = names;
|
||||||
@@ -618,7 +618,7 @@ const Option = Class("Option", {
|
|||||||
/**
|
/**
|
||||||
* @instance options
|
* @instance options
|
||||||
*/
|
*/
|
||||||
const Options = Module("options", {
|
var Options = Module("options", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.needInit = [];
|
this.needInit = [];
|
||||||
this._options = [];
|
this._options = [];
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
/**
|
/**
|
||||||
* @instance quickmarks
|
* @instance quickmarks
|
||||||
*/
|
*/
|
||||||
const QuickMarks = Module("quickmarks", {
|
var QuickMarks = Module("quickmarks", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this._qmarks = storage.newMap("quickmarks", { store: true });
|
this._qmarks = storage.newMap("quickmarks", { store: true });
|
||||||
storage.addObserver("quickmarks", function () {
|
storage.addObserver("quickmarks", function () {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
/** @scope modules */
|
/** @scope modules */
|
||||||
|
|
||||||
const StatusLine = Module("statusline", {
|
var StatusLine = Module("statusline", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this._statusLine = document.getElementById("status-bar");
|
this._statusLine = document.getElementById("status-bar");
|
||||||
this.statusBar = document.getElementById("addon-bar") || this._statusLine;
|
this.statusBar = document.getElementById("addon-bar") || this._statusLine;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
/**
|
/**
|
||||||
* @instance tabs
|
* @instance tabs
|
||||||
*/
|
*/
|
||||||
const Tabs = Module("tabs", {
|
var Tabs = Module("tabs", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this._alternates = [config.tabbrowser.mCurrentTab, null];
|
this._alternates = [config.tabbrowser.mCurrentTab, null];
|
||||||
|
|
||||||
|
|||||||
@@ -13,19 +13,19 @@ if (!JSMLoader)
|
|||||||
dump("dactyl: load: " + url + "\n");
|
dump("dactyl: load: " + url + "\n");
|
||||||
if (this.stale[url]) {
|
if (this.stale[url]) {
|
||||||
delete this.stale[url];
|
delete this.stale[url];
|
||||||
dump("dactyl: load stale\n");
|
|
||||||
|
|
||||||
let global = this.globals[url];
|
let global = this.globals[url];
|
||||||
|
|
||||||
for each (let prop in Object.getOwnPropertyNames(global))
|
for each (let prop in Object.getOwnPropertyNames(global))
|
||||||
try {
|
try {
|
||||||
if (!set.has(this.builtin, prop) && [this, set].indexOf(global[prop]) < 0)
|
if (!set.has(this.builtin, prop) &&
|
||||||
|
[this, set].indexOf(Object.getOwnPropertyDescriptor(global, prop).value) < 0)
|
||||||
delete global[prop];
|
delete global[prop];
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
||||||
.getService(Components.interfaces.mozIJSSubScriptLoader)
|
.getService(Components.interfaces.mozIJSSubScriptLoader)
|
||||||
.loadSubScript(url, this.globals[url]);
|
.loadSubScript(url, global);
|
||||||
dump("dactyl: load reloaded: " + url + "\n");
|
dump("dactyl: load reloaded: " + url + "\n");
|
||||||
}
|
}
|
||||||
Components.utils.import(url, target);
|
Components.utils.import(url, target);
|
||||||
@@ -859,10 +859,10 @@ Class.prototype = {
|
|||||||
*/
|
*/
|
||||||
timeout: function (callback, timeout) {
|
timeout: function (callback, timeout) {
|
||||||
const self = this;
|
const self = this;
|
||||||
let notify = { notify: function notify(timer) { try { callback.apply(self); } catch (e) { util.reportError(e); } } };
|
function notify(timer) {
|
||||||
let timer = services.Timer();
|
util.trapErrors(callback, self);
|
||||||
timer.initWithCallback(notify, timeout || 0, timer.TYPE_ONE_SHOT);
|
}
|
||||||
return timer;
|
return services.Timer(notify, timeout || 0, services.Timer.TYPE_ONE_SHOT);;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
memoize(Class.prototype, "closure", function () {
|
memoize(Class.prototype, "closure", function () {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ default xml namespace = XHTML;
|
|||||||
|
|
||||||
memoize(this, "Commands", function () {
|
memoize(this, "Commands", function () {
|
||||||
// FIXME
|
// FIXME
|
||||||
let obj = {};
|
let obj = { Module: Class };
|
||||||
services.subscriptLoader.loadSubScript("chrome://dactyl/content/commands.js", obj);
|
services.subscriptLoader.loadSubScript("chrome://dactyl/content/commands.js", obj);
|
||||||
return obj.Commands;
|
return obj.Commands;
|
||||||
});
|
});
|
||||||
@@ -94,20 +94,28 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
addObserver: function (obj) {
|
addObserver: function (obj) {
|
||||||
let observers = obj._observe || obj.observe;
|
let observers = obj._observe || obj.observe;
|
||||||
obj._observe = observers;
|
obj._observe = observers;
|
||||||
|
|
||||||
function register(meth) {
|
function register(meth) {
|
||||||
services.observer[meth](obj, "quit-application", true);
|
for (let target in set(["dactyl-cleanup", "quit-application"].concat(Object.keys(observers))))
|
||||||
services.observer[meth](obj, "dactyl-cleanup", true);
|
try {
|
||||||
for (let target in keys(observers))
|
services.observer[meth](obj, target, true);
|
||||||
services.observer[meth](obj, target, true);
|
}
|
||||||
|
catch (e) {}
|
||||||
}
|
}
|
||||||
Class.replaceProperty(obj, "observe",
|
Class.replaceProperty(obj, "observe",
|
||||||
function (subject, target, data) {
|
function (subject, target, data) {
|
||||||
if (target == "quit-application" || target == "dactyl-cleanup")
|
try {
|
||||||
register("removeObserver");
|
if (target == "quit-application" || target == "dactyl-cleanup")
|
||||||
if (observers[target])
|
register("removeObserver");
|
||||||
observers[target].call(obj, subject, data);
|
if (observers[target])
|
||||||
|
observers[target].call(obj, subject, data);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
util.reportError(e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
obj.observe.unRegister = function () register("removeObserver");
|
|
||||||
|
obj.observe.unregister = function () register("removeObserver");
|
||||||
register("addObserver");
|
register("addObserver");
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -457,6 +465,14 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
*/
|
*/
|
||||||
dump: defineModule.dump,
|
dump: defineModule.dump,
|
||||||
|
|
||||||
|
stackLines: function (stack) {
|
||||||
|
let lines = [];
|
||||||
|
let match, re = /([^]*?)(@.*?)(?:\n|$)/g;
|
||||||
|
while (match = re.exec(stack))
|
||||||
|
lines.push(match[1].replace(/\n/g, "\\n").substr(0, 80) + match[2]);
|
||||||
|
return lines;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dumps a stack trace to the console.
|
* Dumps a stack trace to the console.
|
||||||
*
|
*
|
||||||
@@ -464,9 +480,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {number} frames The number of frames to print.
|
* @param {number} frames The number of frames to print.
|
||||||
*/
|
*/
|
||||||
dumpStack: function dumpStack(msg, frames) {
|
dumpStack: function dumpStack(msg, frames) {
|
||||||
let stack = Error().stack.replace(/(?:.*\n){2}/, "");
|
let stack = util.stackLines(Error().stack);
|
||||||
if (frames != null)
|
stack = stack.slice(2, 2 + (frames || 0)).join("\n");
|
||||||
[stack] = stack.match(RegExp("(?:.*\n){0," + frames + "}"));
|
|
||||||
util.dump((arguments.length == 0 ? "Stack" : msg) + "\n" + stack + "\n");
|
util.dump((arguments.length == 0 ? "Stack" : msg) + "\n" + stack + "\n");
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1126,7 +1141,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
try {
|
try {
|
||||||
let obj = update({}, error, {
|
let obj = update({}, error, {
|
||||||
toString: function () String(error),
|
toString: function () String(error),
|
||||||
stack: <>{String.replace(error.stack || Error().stack, /^/mg, "\t")}</>
|
stack: <>{util.stackLines(String(error.stack || Error().stack)).join("\n").replace(/^/mg, "\t")}</>
|
||||||
});
|
});
|
||||||
|
|
||||||
this.errors.push([new Date, obj + "\n" + obj.stack]);
|
this.errors.push([new Date, obj + "\n" + obj.stack]);
|
||||||
@@ -1140,7 +1155,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
catch (e) {
|
catch (e) {
|
||||||
try {
|
try {
|
||||||
this.dump(String(error));
|
this.dump(String(error));
|
||||||
this.dump(error.stack)
|
this.dump(util.stackLines(error.stack).join("\n"))
|
||||||
}
|
}
|
||||||
catch (e) { dump(e + "\n"); }
|
catch (e) { dump(e + "\n"); }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user