mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 18:47:58 +01:00
Ditch the bloody chrome registry.
This commit is contained in:
28
common/bootstrap.js
vendored
28
common/bootstrap.js
vendored
@@ -123,16 +123,9 @@ function init() {
|
||||
for each (let line in manifest.split("\n")) {
|
||||
let fields = line.split(/\s+/);
|
||||
switch(fields[0]) {
|
||||
case "content":
|
||||
fields[2] = url(fields[2]);
|
||||
default:
|
||||
result.push(fields);
|
||||
break;
|
||||
|
||||
case "locale":
|
||||
case "skin":
|
||||
fields[3] = url(fields[3]);
|
||||
result.push(fields);
|
||||
case "#":
|
||||
if (fields[1] == "Suffix:")
|
||||
var suffix = fields[1];
|
||||
break;
|
||||
|
||||
case "category":
|
||||
@@ -146,10 +139,6 @@ function init() {
|
||||
break;
|
||||
|
||||
case "resource":
|
||||
let str = "dactyl-";
|
||||
if (fields[1].indexOf(str) == 0)
|
||||
var suffix = fields[1].substr(str.length - 1);
|
||||
|
||||
resourceProto.setSubstitution(fields[1], getURI(fields[2]));
|
||||
}
|
||||
}
|
||||
@@ -174,17 +163,6 @@ function init() {
|
||||
|
||||
let manifestText = result.map(function (line) line.join(" ")).join("\n");
|
||||
|
||||
if (manifestURI instanceof Ci.nsIFileURL)
|
||||
manager.autoRegister(manifestURI.QueryInterface(Ci.nsIFileURL).file);
|
||||
else {
|
||||
var file = basePath.parent;
|
||||
file.append(addon.id + ".manifest");
|
||||
|
||||
writeFile(file, manifestText);
|
||||
manager.autoRegister(file);
|
||||
file.remove(false);
|
||||
}
|
||||
|
||||
require(global, "overlay");
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ var global = this;
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var Cu = Components.utils;
|
||||
var DNE = "chrome://dactyl/content/does/not/exist";
|
||||
var DNE = "resource://dactyl/content/does/not/exist";
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
@@ -162,7 +162,7 @@ Dactyl.prototype = {
|
||||
let path = decodeURIComponent(uri.path.replace(/^\/|#.*/g, ""));
|
||||
switch(uri.host) {
|
||||
case "content":
|
||||
return makeChannel(this.pages[path] || "chrome://dactyl/content/" + path, uri);
|
||||
return makeChannel(this.pages[path] || "resource://dactyl-content/" + path, uri);
|
||||
case "help":
|
||||
return makeChannel(this.FILE_MAP[path], uri);
|
||||
case "help-overlay":
|
||||
@@ -174,9 +174,9 @@ Dactyl.prototype = {
|
||||
if (tag in this.HELP_TAGS)
|
||||
return redirect("dactyl://help/" + this.HELP_TAGS[tag] + "#" + tag, uri);
|
||||
case "locale":
|
||||
return makeChannel("chrome://dactyl/locale/" + path, uri);
|
||||
return makeChannel(["resource://dactyl-locale", config.locale, path].join("/"), uri);
|
||||
case "locale-local":
|
||||
return makeChannel("chrome://" + config.name + "/locale/" + path, uri);
|
||||
return makeChannel(["resource://dactyl-local-locale", config.locale, path].join("/"), uri);
|
||||
}
|
||||
}
|
||||
catch (e) {}
|
||||
@@ -303,7 +303,7 @@ AboutHandler.prototype = {
|
||||
|
||||
newChannel: function (uri) {
|
||||
let channel = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService)
|
||||
.newChannel("chrome://dactyl/content/about.xul", null, null);
|
||||
.newChannel("resource://dactyl-content/about.xul", null, null);
|
||||
channel.originalURI = uri;
|
||||
return channel;
|
||||
},
|
||||
|
||||
@@ -34,14 +34,14 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
<vbox id={config.commandContainer}>
|
||||
|
||||
<vbox class="dactyl-container" id="dactyl-multiline-output-container" hidden="false" collapsed="true">
|
||||
<iframe id="dactyl-multiline-output" src="chrome://dactyl/content/buffer.xhtml"
|
||||
<iframe id="dactyl-multiline-output" src="resource://dactyl-content/buffer.xhtml"
|
||||
flex="1" hidden="false" collapsed="false"
|
||||
contextmenu="dactyl-contextmenu"
|
||||
onclick="dactyl.modules.commandline.onMultilineOutputEvent(event)"/>
|
||||
</vbox>
|
||||
|
||||
<vbox class="dactyl-container" hidden="false" collapsed="true">
|
||||
<iframe class="dactyl-completions" id="dactyl-completions-dactyl-commandline" src="chrome://dactyl/content/buffer.xhtml"
|
||||
<iframe class="dactyl-completions" id="dactyl-completions-dactyl-commandline" src="resource://dactyl-content/buffer.xhtml"
|
||||
contextmenu="dactyl-contextmenu"
|
||||
flex="1" hidden="false" collapsed="false"
|
||||
onclick="dactyl.modules.commandline.onMultilineOutputEvent(event)"/>
|
||||
@@ -75,7 +75,7 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
before: <e4x xmlns={XUL} xmlns:dactyl={NS}>
|
||||
<toolbar id={statusline.statusBar.id}>
|
||||
<vbox id={"dactyl-completions-" + _status + "commandline-container"} class="dactyl-container" hidden="false" collapsed="true">
|
||||
<iframe class="dactyl-completions" id={"dactyl-completions-" + _status + "commandline"} src="chrome://dactyl/content/buffer.xhtml"
|
||||
<iframe class="dactyl-completions" id={"dactyl-completions-" + _status + "commandline"} src="resource://dactyl-content/buffer.xhtml"
|
||||
contextmenu="dactyl-contextmenu"
|
||||
flex="1" hidden="false" collapsed="false"
|
||||
onclick="dactyl.modules.commandline.onMultilineOutputEvent(event)"/>
|
||||
@@ -161,12 +161,12 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
});
|
||||
|
||||
let fontSize = util.computedStyle(document.documentElement).fontSize;
|
||||
styles.registerSheet("chrome://dactyl/skin/dactyl.css");
|
||||
styles.system.add("font-size", "chrome://dactyl/content/buffer.xhtml",
|
||||
styles.registerSheet("resource://dactyl-skin/dactyl.css");
|
||||
styles.system.add("font-size", "resource://dactyl-content/buffer.xhtml",
|
||||
"body { font-size: " + fontSize + "; }");
|
||||
},
|
||||
cleanup: function cleanup() {
|
||||
styles.unregisterSheet("chrome://dactyl/skin/dactyl.css");
|
||||
styles.unregisterSheet("resource://dactyl-skin/dactyl.css");
|
||||
},
|
||||
addElement: function (obj) {
|
||||
const self = this;
|
||||
|
||||
@@ -594,10 +594,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
if (context && context.INFO instanceof XML) {
|
||||
let info = context.INFO;
|
||||
if (info.*.@lang.length()) {
|
||||
let langs = set(String(a) for each (a in info.*.@lang));
|
||||
let lang = [config.language, config.language.replace(/-.*/, ""),
|
||||
"en", "en-US", info.*.@lang[0]
|
||||
].filter(function (l) set.has(langs, l))[0];
|
||||
let lang = config.bestLocale(String(a) for each (a in info.*.@lang));
|
||||
|
||||
info.* = info.*.(function::attribute("lang").length() == 0 || @lang == lang);
|
||||
|
||||
@@ -613,7 +610,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
let help =
|
||||
'<?xml version="1.0"?>\n' +
|
||||
'<?xml-stylesheet type="text/xsl" href="dactyl://content/help.xsl"?>\n' +
|
||||
'<!DOCTYPE document SYSTEM "chrome://dactyl/content/dactyl.dtd">\n' +
|
||||
'<!DOCTYPE document SYSTEM "resource://dactyl-content/dactyl.dtd">\n' +
|
||||
unescape(encodeURI( // UTF-8 handling hack.
|
||||
<document xmlns={NS}
|
||||
name="plugins" title={config.appName + " Plugins"}>
|
||||
|
||||
@@ -36,7 +36,7 @@ var Tabs = Module("tabs", {
|
||||
};
|
||||
|
||||
this.tabBinding = styles.system.add("tab-binding", "chrome://browser/content/browser.xul", String.replace(<><![CDATA[
|
||||
xul|tab { -moz-binding: url(chrome://dactyl/content/bindings.xml#tab) !important; }
|
||||
xul|tab { -moz-binding: url(resource://dactyl-content/bindings.xml#tab) !important; }
|
||||
]]></>, /tab-./g, function (m) util.OS.isMacOSX ? "tab-mac" : m),
|
||||
false, true);
|
||||
},
|
||||
|
||||
@@ -52,6 +52,7 @@ if (!JSMLoader || JSMLoader.bump != 1)
|
||||
.getService(Components.interfaces.mozIJSSubScriptLoader)
|
||||
.loadSubScript(url, global.global || global);
|
||||
}
|
||||
try {
|
||||
let global = Components.utils.import(url, target);
|
||||
|
||||
if (name == "base.jsm") {
|
||||
@@ -61,6 +62,11 @@ if (!JSMLoader || JSMLoader.bump != 1)
|
||||
}
|
||||
|
||||
return this.globals[url] = global;
|
||||
}
|
||||
catch (e) {
|
||||
dump("Importing " + url + ": " + e + "\n" + (e.stack || Error().stack));
|
||||
throw e;
|
||||
}
|
||||
},
|
||||
cleanup: function unregister() {
|
||||
for each (let factory in this.factories.splice(0))
|
||||
|
||||
@@ -55,7 +55,50 @@ var ConfigBase = Class("ConfigBase", {
|
||||
return addon;
|
||||
}),
|
||||
|
||||
language: Class.memoize(function () services.chromeRegistry.getSelectedLocale("dactyl")),
|
||||
/**
|
||||
* The current application locale.
|
||||
*/
|
||||
appLocale: Class.memoize(function () services.chromeRegistry.getSelectedLocale("global")),
|
||||
|
||||
/**
|
||||
* The current dactyl locale.
|
||||
*/
|
||||
locale: Class.memoize(function () this.bestLocale(this.locales)),
|
||||
|
||||
/**
|
||||
* The current application locale.
|
||||
*/
|
||||
locales: Class.memoize(function () {
|
||||
// TODO: Merge with completion.file code.
|
||||
function getDir(str) str.match(/^(?:.*[\/\\])?/)[0];
|
||||
|
||||
let uri = "resource://dactyl-locale/";
|
||||
let jar = io.isJarURL(uri);
|
||||
if (jar) {
|
||||
let prefix = getDir(jar.JAREntry);
|
||||
return iter(s.slice(prefix.length).replace(/\/.*/, "") for (s in io.listJar(jar.JARFile, prefix)))
|
||||
.uniq().toArray();
|
||||
}
|
||||
else {
|
||||
return array(f.leafName
|
||||
for (f in util.getFile(uri).iterDirectory())
|
||||
if (f.isDirectory())).array;
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
* Returns the best locale match to the current locale from a list
|
||||
* of available locales.
|
||||
*
|
||||
* @param {[string]} list A list of available locales
|
||||
* @returns {string}
|
||||
*/
|
||||
bestLocale: function (list) {
|
||||
let langs = set(list);
|
||||
return values([this.appLocale, this.appLocale.replace(/-.*/, ""),
|
||||
"en", "en-US", iter(langs).next()])
|
||||
.nth(function (l) set.has(langs, l), 0);
|
||||
},
|
||||
|
||||
/** @property {string} The Dactyl version string. */
|
||||
version: Class.memoize(function () {
|
||||
@@ -593,14 +636,14 @@ var ConfigBase = Class("ConfigBase", {
|
||||
]]></>)
|
||||
});
|
||||
|
||||
services.subscriptLoader.loadSubScript("chrome://dactyl/content/config.js", this);
|
||||
services.subscriptLoader.loadSubScript("resource://dactyl-local-content/config.js", this);
|
||||
|
||||
config.INIT = update(Object.create(config.INIT), config.INIT, {
|
||||
init: function init(dactyl, modules, window) {
|
||||
init.superapply(this, arguments);
|
||||
|
||||
let img = window.Image();
|
||||
img.src = this.logo || "chrome://" + this.name + "/content/logo.png";
|
||||
img.src = this.logo || "chrome://dactyl-local-content/logo.png";
|
||||
img.onload = function () {
|
||||
highlight.loadCSS(<>{"!Logo {"}
|
||||
display: inline-block;
|
||||
|
||||
@@ -43,7 +43,7 @@ Highlight.defaultValue("selector", function () highlight.selector(this.class));
|
||||
|
||||
Highlight.defaultValue("sites", function ()
|
||||
this.base ? this.base.sites
|
||||
: ["chrome://dactyl/*", "dactyl:*", "file://*"].concat(
|
||||
: ["resource://dactyl*", "dactyl:*", "file://*"].concat(
|
||||
highlight.styleableChrome));
|
||||
|
||||
Highlight.defaultValue("style", function ()
|
||||
|
||||
@@ -296,7 +296,7 @@ var IO = Module("io", {
|
||||
return File(file);
|
||||
},
|
||||
|
||||
isJarURL: function (url) {
|
||||
isJarURL: function isJarURL(url) {
|
||||
try {
|
||||
let uri = util.newURI(url);
|
||||
let channel = services.io.newChannelFromURI(uri);
|
||||
@@ -308,6 +308,22 @@ var IO = Module("io", {
|
||||
return false;
|
||||
},
|
||||
|
||||
listJar: function listJar(file, path) {
|
||||
file = util.getFile(file);
|
||||
if (file) {
|
||||
// let jar = services.zipReader.getZip(file); Crashes.
|
||||
let jar = services.ZipReader(file);
|
||||
try {
|
||||
for (let entry in jar.findEntries("*"))
|
||||
if (filter.test(s))
|
||||
yield entry;
|
||||
}
|
||||
finally {
|
||||
jar.close();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
readHeredoc: function (end) {
|
||||
return "";
|
||||
},
|
||||
@@ -869,25 +885,12 @@ unlet s:cpo_save
|
||||
let uri = io.isJarURL(dir);
|
||||
if (uri)
|
||||
context.generate = function generate_jar() {
|
||||
let file = util.getFile(uri.JARFile);
|
||||
if (file) {
|
||||
// let jar = services.zipReader.getZip(file); Crashes.
|
||||
let jar = services.ZipReader(file);
|
||||
try {
|
||||
let filter = RegExp("^" + util.regexp.escape(decodeURI(getDir(uri.JAREntry)))
|
||||
+ "[^/]*/?$");
|
||||
return [
|
||||
{
|
||||
isDirectory: function () s.substr(-1) == "/",
|
||||
leafName: /([^\/]*)\/?$/.exec(s)[1]
|
||||
}
|
||||
for (s in iter(jar.findEntries("*"))) if (filter.test(s))
|
||||
]
|
||||
}
|
||||
finally {
|
||||
jar.close();
|
||||
}
|
||||
}
|
||||
for (s in io.listJar(getDir(uri.JARFile, uri.JAREntry)))]
|
||||
};
|
||||
else
|
||||
context.generate = function generate_file() {
|
||||
|
||||
@@ -84,7 +84,7 @@ var Overlay = Module("Overlay", {
|
||||
Module.list = [];
|
||||
Module.constructors = {};
|
||||
|
||||
const BASE = "chrome://dactyl/content/";
|
||||
const BASE = "resource://dactyl-content/";
|
||||
|
||||
const create = window.Object.create || (function () {
|
||||
window.__dactyl_eval_string = "(function (proto) ({ __proto__: proto }))";
|
||||
@@ -143,7 +143,7 @@ var Overlay = Module("Overlay", {
|
||||
modules.modules = modules;
|
||||
window.dactyl = { modules: modules };
|
||||
|
||||
let prefix = [BASE];
|
||||
let prefix = [BASE, "resource://dactyl-local-content/"];
|
||||
|
||||
defineModule.time("load", null, function _load() {
|
||||
["base",
|
||||
@@ -156,7 +156,6 @@ var Overlay = Module("Overlay", {
|
||||
"storage",
|
||||
"util"
|
||||
].forEach(function (name) require(jsmodules, name));
|
||||
prefix.unshift("chrome://" + config.name + "/content/");
|
||||
|
||||
["dactyl",
|
||||
"modes",
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
BEGIN {
|
||||
chrome = "chrome"
|
||||
if (suffix)
|
||||
if (suffix) {
|
||||
chrome = suffix
|
||||
print "# Suffix: " suffix
|
||||
}
|
||||
}
|
||||
{ content = $1 ~ /^(content|skin|locale|resource)$/ }
|
||||
content && $NF ~ /^[a-z]/ { $NF = "/" name "/" $NF }
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
/* Applied to all content */
|
||||
[dactyl|activeframe] {
|
||||
-moz-binding: url(chrome://dactyl/content/bindings.xml#frame) !important;
|
||||
-moz-binding: url(resource://dactyl-content/bindings.xml#frame) !important;
|
||||
}
|
||||
|
||||
[dactyl|highlight~=hints] {
|
||||
-moz-binding: url(chrome://dactyl/content/bindings.xml#hints) !important;
|
||||
-moz-binding: url(resource://dactyl-content/bindings.xml#hints) !important;
|
||||
}
|
||||
|
||||
[dactyl|highlight~=HintImage],
|
||||
@@ -21,14 +21,14 @@
|
||||
url-prefix(dactyl:) {
|
||||
|
||||
[dactyl|highlight~=HelpDefault] {
|
||||
-moz-binding: url(chrome://dactyl/content/bindings.xml#compitem-td);
|
||||
-moz-binding: url(resource://dactyl-content/bindings.xml#compitem-td);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Applied only to completion buffer and MOW */
|
||||
@-moz-document
|
||||
url-prefix(chrome://dactyl/) {
|
||||
url-prefix(resource://dactyl) {
|
||||
|
||||
*:-moz-loading, *:-moz-broken { display: none !important; }
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
}
|
||||
[dactyl|highlight~=CompItem] > *,
|
||||
[dactyl|highlight~=CompTitle] > * {
|
||||
-moz-binding: url(chrome://dactyl/content/bindings.xml#compitem-td);
|
||||
-moz-binding: url(resource://dactyl-content/bindings.xml#compitem-td);
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
@@ -75,7 +75,7 @@
|
||||
}
|
||||
|
||||
@-moz-document
|
||||
url-prefix(chrome://dactyl/) {
|
||||
url-prefix(resource://dactyl) {
|
||||
|
||||
*:-moz-any-link:hover {
|
||||
text-decoration: underline;
|
||||
@@ -84,7 +84,8 @@
|
||||
|
||||
/* Applied to completion buffer, MOW, browser window */
|
||||
@-moz-document
|
||||
url-prefix(chrome://) {
|
||||
url-prefix(chrome://),
|
||||
url-prefix(resource://) {
|
||||
|
||||
#TabsToolbar .tab-icon-image, .tab-throbber { -moz-box-ordinal-group: 10; }
|
||||
[dactyl|highlight~=tab-number] { -moz-box-ordinal-group: 20; }
|
||||
|
||||
@@ -6,11 +6,6 @@ ARCHITECTURE:
|
||||
on the website - is there even a documentation tool that can parse our source
|
||||
sensibly?
|
||||
|
||||
There are a few that can, to some extent. We more or less follow the
|
||||
ScriptDoc standard, and we're very close to a few other standards.
|
||||
Unfortunately, nearly all of the parsers are lacking in some way, bloated to
|
||||
hell, and/or lack support for JS 1.8. --Kris
|
||||
|
||||
- unify the disgusting hodge podge of contract specification styles
|
||||
|
||||
REFACTORING:
|
||||
@@ -21,7 +16,6 @@ BUGS:
|
||||
- :sidebar improvements (:sidebar! Downloads while downloads is open should refocus the sidebar)
|
||||
- ;s saves the page rather than the image
|
||||
- RC file is sourced once per window
|
||||
- :undo seems to be affected by the tabstrip state
|
||||
- the :help version-information page is no longer generated
|
||||
|
||||
FEATURES:
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
# Firefox
|
||||
content pentadactyl content/
|
||||
skin pentadactyl classic/1.0 skin/
|
||||
locale pentadactyl en-US locale/en-US/
|
||||
locale dactyl en-US ../common/locale/en-US/
|
||||
resource dactyl-local-content content/
|
||||
resource dactyl-local-skin skin/
|
||||
resource dactyl-local-locale locale/
|
||||
|
||||
content dactyl ../common/content/
|
||||
resource dactyl ../common/modules/
|
||||
skin dactyl classic/1.0 ../common/skin/
|
||||
|
||||
override chrome://dactyl/content/dactyl.dtd chrome://pentadactyl/content/dactyl.dtd
|
||||
override chrome://dactyl/content/config.js chrome://pentadactyl/content/config.js
|
||||
resource dactyl-content ../common/content/
|
||||
resource dactyl-skin ../common/skin/
|
||||
resource dactyl-locale ../common/locale/
|
||||
|
||||
component {16dc34f7-6d22-4aa4-a67f-2921fb5dcb69} components/commandline-handler.js
|
||||
contract @mozilla.org/commandlinehandler/general-startup;1?type=dactyl {16dc34f7-6d22-4aa4-a67f-2921fb5dcb69}
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
em:version="1.0b5pre"
|
||||
em:description="Firefox for Vim and Links addicts"
|
||||
em:homepageURL="http://dactyl.sourceforge.net/pentadactyl"
|
||||
em:iconURL="chrome://pentadactyl/skin/icon.png"
|
||||
em:optionsURL="chrome://dactyl/content/preferences.xul"
|
||||
em:iconURL="resource://dactyl-local-skin/icon.png"
|
||||
em:bootstrap="true">
|
||||
|
||||
<em:creator>Kris Maglione, Doug Kearns</em:creator>
|
||||
<em:developer>Kris Maglione</em:developer>
|
||||
<em:developer>Doug Kearns</em:developer>
|
||||
<em:developer>Štěpán Němec</em:developer>
|
||||
|
||||
<em:contributor>anekos</em:contributor>
|
||||
@@ -30,7 +31,7 @@
|
||||
<Description
|
||||
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
|
||||
em:minVersion="3.5"
|
||||
em:maxVersion="4.0b9pre"/>
|
||||
em:maxVersion="4.0"/>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</RDF>
|
||||
|
||||
Reference in New Issue
Block a user