mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-30 10:55:45 +01:00
Refactor modules.config.
This commit is contained in:
@@ -12,6 +12,8 @@ const AutoCommand = new Struct("event", "pattern", "command");
|
||||
* @instance autocommands
|
||||
*/
|
||||
const AutoCommands = Module("autocommands", {
|
||||
requires: ["config"],
|
||||
|
||||
init: function () {
|
||||
this._store = [];
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ const DEFAULT_FAVICON = "chrome://mozapps/skin/places/defaultFavicon.png";
|
||||
|
||||
// also includes methods for dealing with keywords and search engines
|
||||
const Bookmarks = Module("bookmarks", {
|
||||
requires: ["autocommands", "liberator", "storage", "services"],
|
||||
requires: ["autocommands", "config", "liberator", "storage", "services"],
|
||||
|
||||
init: function () {
|
||||
const faviconService = services.get("favicon");
|
||||
|
||||
@@ -15,6 +15,8 @@ const Point = new Struct("x", "y");
|
||||
* @instance buffer
|
||||
*/
|
||||
const Buffer = Module("buffer", {
|
||||
requires: ["config"],
|
||||
|
||||
init: function () {
|
||||
|
||||
this.pageInfo = {};
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* this class when the chrome is ready.
|
||||
*/
|
||||
const CommandLine = Module("commandline", {
|
||||
requires: ["liberator", "modes", "services", "storage", "template", "util"],
|
||||
requires: ["config", "liberator", "modes", "services", "storage", "template", "util"],
|
||||
|
||||
init: function () {
|
||||
const self = this;
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
* @private
|
||||
*/
|
||||
const Command = Class("Command", {
|
||||
requires: ["config"],
|
||||
|
||||
init: function (specs, description, action, extraInfo) {
|
||||
specs = Array.concat(specs);
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
// This work is licensed for reuse under an MIT license. Details are
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
|
||||
|
||||
const configbase = { //{{{
|
||||
const ConfigBase = Class(ModuleBase, {
|
||||
/**
|
||||
* @property {[["string", "string"]]} A sequence of names and descriptions
|
||||
* of the autocommands available in this application. Primarily used
|
||||
@@ -99,6 +98,6 @@ const configbase = { //{{{
|
||||
*/
|
||||
get tempFile() this.name.toLowerCase() + ".tmp"
|
||||
|
||||
}; //}}}
|
||||
});
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
/** @instance editor */
|
||||
const Editor = Module("editor", {
|
||||
requires: ["config"],
|
||||
|
||||
init: function () {
|
||||
// store our last search with f, F, t or T
|
||||
//
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* @instance events
|
||||
*/
|
||||
const Events = Module("events", {
|
||||
requires: ["autocommands"],
|
||||
requires: ["autocommands", "config"],
|
||||
|
||||
init: function () {
|
||||
const self = this;
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
* @instance finder
|
||||
*/
|
||||
const Finder = Module("finder", {
|
||||
requires: ["config"],
|
||||
|
||||
init: function () {
|
||||
const self = this;
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
/** @instance hints */
|
||||
const ELEM = 0, TEXT = 1, SPAN = 2, IMG_SPAN = 3;
|
||||
const Hints = Module("hints", {
|
||||
requires: ["config"],
|
||||
|
||||
init: function () {
|
||||
|
||||
this._hintMode;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
|
||||
const History = Module("history", {
|
||||
requires: ["config"],
|
||||
|
||||
get format() bookmarks.format,
|
||||
|
||||
get service() services.get("history"),
|
||||
|
||||
@@ -267,7 +267,7 @@ const File = Class("File", {
|
||||
* @instance io
|
||||
*/
|
||||
const IO = Module("io", {
|
||||
requires: ["services"],
|
||||
requires: ["config", "services"],
|
||||
|
||||
init: function () {
|
||||
this._processDir = services.get("directory").get("CurWorkD", Ci.nsIFile);
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
"commandline.js",
|
||||
"commands.js",
|
||||
"completion.js",
|
||||
"config.js",
|
||||
"configbase.js",
|
||||
"config.js",
|
||||
"liberator.js",
|
||||
"editor.js",
|
||||
"events.js",
|
||||
@@ -55,10 +55,9 @@
|
||||
"template.js",
|
||||
"util.js",
|
||||
].forEach(load);
|
||||
modules.config.__proto__ = modules.configbase;
|
||||
|
||||
prefix.unshift("chrome://" + modules.config.name.toLowerCase() + "/content/");
|
||||
modules.config.scripts.forEach(load);
|
||||
prefix.unshift("chrome://" + modules.Config.prototype.name.toLowerCase() + "/content/");
|
||||
modules.Config.prototype.scripts.forEach(load);
|
||||
|
||||
})();
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ const FailedAssertion = Class("FailedAssertion", Error, {
|
||||
});
|
||||
|
||||
const Liberator = Module("liberator", {
|
||||
requires: ["services"],
|
||||
requires: ["config", "services"],
|
||||
|
||||
init: function () {
|
||||
window.liberator = this;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* @instance marks
|
||||
*/
|
||||
const Marks = Module("marks", {
|
||||
requires: ["storage"],
|
||||
requires: ["config", "storage"],
|
||||
|
||||
init: function init() {
|
||||
this._localMarks = storage.newMap("local-marks", { store: true, privateData: true });
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/** @scope modules */
|
||||
|
||||
const Modes = Module("modes", {
|
||||
requires: ["util"],
|
||||
requires: ["config", "util"],
|
||||
|
||||
init: function () {
|
||||
this._main = 1; // NORMAL
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
|
||||
const ModuleBase = Class("ModuleBase", { requires: [] });
|
||||
function Module(name, inst, clas, moduleInit) {
|
||||
const module = Class(name, ModuleBase, inst, clas);
|
||||
var base = ModuleBase;
|
||||
if (callable(inst))
|
||||
base = Array.splice(arguments, 1, 1)[0]
|
||||
const module = Class(name, base, inst, clas);
|
||||
module.INIT = moduleInit || {};
|
||||
module.requires = inst.requires || [];
|
||||
Module.list.push(module);
|
||||
@@ -12,7 +15,7 @@ Module.list = [];
|
||||
Module.constructors = {};
|
||||
|
||||
window.addEventListener("load", function () {
|
||||
function dump(str) window.dump(String.replace(str, /\n?$/, "\n").replace(/^/m, config.name.toLowerCase() + ": "));
|
||||
function dump(str) window.dump(String.replace(str, /\n?$/, "\n").replace(/^/m, Config.prototype.name.toLowerCase() + ": "));
|
||||
const start = Date.now();
|
||||
const deferredInit = { load: [] };
|
||||
const seen = set();
|
||||
|
||||
@@ -401,7 +401,7 @@ const Option = Class("Option", {
|
||||
* @instance options
|
||||
*/
|
||||
const Options = Module("options", {
|
||||
requires: ["highlight", "storage"],
|
||||
requires: ["config", "highlight", "storage"],
|
||||
|
||||
init: function () {
|
||||
for (let [, pref] in Iterator(this.allPrefs(Options.OLD_SAVED))) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* @instance quickmarks
|
||||
*/
|
||||
const QuickMarks = Module("quickmarks", {
|
||||
requires: ["storage"],
|
||||
requires: ["config", "storage"],
|
||||
|
||||
init: function () {
|
||||
this._qmarks = storage.newMap("quickmarks", { store: true });
|
||||
|
||||
@@ -557,7 +557,7 @@ function Styles(name, store) {
|
||||
}
|
||||
|
||||
Module("styles", {
|
||||
requires: ["liberator", "storage", "util"],
|
||||
requires: ["config", "liberator", "storage", "util"],
|
||||
|
||||
init: function () {
|
||||
let (array = util.Array) {
|
||||
@@ -707,7 +707,7 @@ Module("styles", {
|
||||
});
|
||||
|
||||
Module("highlight", {
|
||||
requires: ["styles"],
|
||||
requires: ["config", "styles"],
|
||||
|
||||
init: function () {
|
||||
const self = storage.newObject("highlight", Highlights, { store: false });
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
* @instance tabs
|
||||
*/
|
||||
const Tabs = Module("tabs", {
|
||||
requires: ["config"],
|
||||
|
||||
init: function () {
|
||||
this._alternates = [getBrowser().mCurrentTab, null];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user