1
0
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:
Kris Maglione
2009-11-09 03:12:27 -05:00
parent 4d88ccb036
commit a72068c9f7
26 changed files with 160 additions and 175 deletions

View File

@@ -12,6 +12,8 @@ const AutoCommand = new Struct("event", "pattern", "command");
* @instance autocommands
*/
const AutoCommands = Module("autocommands", {
requires: ["config"],
init: function () {
this._store = [];
},

View File

@@ -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");

View File

@@ -15,6 +15,8 @@ const Point = new Struct("x", "y");
* @instance buffer
*/
const Buffer = Module("buffer", {
requires: ["config"],
init: function () {
this.pageInfo = {};

View File

@@ -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;

View File

@@ -33,6 +33,8 @@
* @private
*/
const Command = Class("Command", {
requires: ["config"],
init: function (specs, description, action, extraInfo) {
specs = Array.concat(specs);

View File

@@ -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:

View File

@@ -11,6 +11,8 @@
/** @instance editor */
const Editor = Module("editor", {
requires: ["config"],
init: function () {
// store our last search with f, F, t or T
//

View File

@@ -10,7 +10,7 @@
* @instance events
*/
const Events = Module("events", {
requires: ["autocommands"],
requires: ["autocommands", "config"],
init: function () {
const self = this;

View File

@@ -20,6 +20,8 @@
* @instance finder
*/
const Finder = Module("finder", {
requires: ["config"],
init: function () {
const self = this;

View File

@@ -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;

View File

@@ -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"),

View File

@@ -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);

View File

@@ -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);
})();

View File

@@ -38,7 +38,7 @@ const FailedAssertion = Class("FailedAssertion", Error, {
});
const Liberator = Module("liberator", {
requires: ["services"],
requires: ["config", "services"],
init: function () {
window.liberator = this;

View File

@@ -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 });

View File

@@ -6,7 +6,7 @@
/** @scope modules */
const Modes = Module("modes", {
requires: ["util"],
requires: ["config", "util"],
init: function () {
this._main = 1; // NORMAL

View File

@@ -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();

View File

@@ -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))) {

View File

@@ -9,7 +9,7 @@
* @instance quickmarks
*/
const QuickMarks = Module("quickmarks", {
requires: ["storage"],
requires: ["config", "storage"],
init: function () {
this._qmarks = storage.newMap("quickmarks", { store: true });

View File

@@ -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 });

View File

@@ -12,6 +12,8 @@
* @instance tabs
*/
const Tabs = Module("tabs", {
requires: ["config"],
init: function () {
this._alternates = [getBrowser().mCurrentTab, null];