1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 05:08:00 +01:00

Fix broken :colorscheme completion.

This commit is contained in:
Kris Maglione
2009-10-31 18:42:48 -04:00
parent 785c416b3d
commit cf03f99246
3 changed files with 38 additions and 12 deletions

View File

@@ -29,8 +29,12 @@ const systemPrincipal = channel.owner;
channel.cancel(NS_BINDING_ABORTED); channel.cancel(NS_BINDING_ABORTED);
delete channel; delete channel;
function dataURL(type, data)
"data:" + (type || "application/xml;encoding=UTF-8") + "," + escape(data);
function makeChannel(url, orig) function makeChannel(url, orig)
{ {
if (typeof url == "function")
url = dataURL.apply(null, url());
let uri = ioService.newURI(url, null, null); let uri = ioService.newURI(url, null, null);
let channel = ioService.newChannelFromURI(uri); let channel = ioService.newChannelFromURI(uri);
channel.owner = systemPrincipal; channel.owner = systemPrincipal;
@@ -42,7 +46,7 @@ function fakeChannel(orig)
function redirect(to, orig) function redirect(to, orig)
{ {
let html = <html><head><meta http-equiv="Refresh" content={"0;" + to}/></head></html>.toXMLString(); let html = <html><head><meta http-equiv="Refresh" content={"0;" + to}/></head></html>.toXMLString();
return makeChannel('data:text/html,' + escape(html), orig); return makeChannel(dataURL('text/html', html), orig);
} }
function ChromeData() {} function ChromeData() {}

View File

@@ -1167,6 +1167,8 @@ const liberator = (function () //{{{
*/ */
loadScript: function (uri, context) loadScript: function (uri, context)
{ {
XML.ignoreWhiteSpace = false;
XML.prettyPrinting = false;
services.get("subscriptLoader").loadSubScript(uri, context); services.get("subscriptLoader").loadSubScript(uri, context);
}, },
@@ -1383,9 +1385,6 @@ const liberator = (function () //{{{
*/ */
initHelp: function () initHelp: function ()
{ {
if (services.get("liberator:").NAMESPACES.length)
return;
let namespaces = [config.name.toLowerCase(), "liberator"]; let namespaces = [config.name.toLowerCase(), "liberator"];
let tagMap = {}; let tagMap = {};
let fileMap = {}; let fileMap = {};
@@ -1415,6 +1414,13 @@ const liberator = (function () //{{{
} }
return result; return result;
} }
function addTags(file, doc)
{
doc = XSLT.transformToDocument(doc);
for (let elem in util.evaluateXPath("//liberator:tag/text()", doc))
tagMap[elem.textContent] = file;
}
const XSLT = XSLTProcessor("chrome://liberator/content/help.xsl"); const XSLT = XSLTProcessor("chrome://liberator/content/help.xsl");
tagMap.all = "all"; tagMap.all = "all";
@@ -1423,14 +1429,30 @@ const liberator = (function () //{{{
"//liberator:include/@href", doc))]); "//liberator:include/@href", doc))]);
util.Array.flatten(files).map(function (file) { util.Array.flatten(files).map(function (file) {
liberator.dump("file:", file);
findHelpFile(file).forEach(function (doc) { findHelpFile(file).forEach(function (doc) {
doc = XSLT.transformToDocument(doc); addTags(file, doc);
for (let elem in util.evaluateXPath("//liberator:tag/text()", doc))
tagMap[elem.textContent] = file;
}); });
}); });
XML.ignoreWhiteSpace = false;
XML.prettyPrinting = false;
let body = XML();
for (let [, context] in Iterator(plugins.contexts))
if (context.INFO instanceof XML)
body += context.INFO;
let help = '<?xml version="1.0"?>\n' +
'<?xml-stylesheet type="text/xsl" href="chrome://liberator/content/overlay.xsl"?>\n' +
'<!DOCTYPE document SYSTEM "chrome://liberator/content/liberator.dtd">' +
<document
name="plugins"
title={config.name + " Plugins"}
xmlns="http://vimperator.org/namespaces/liberator">
<h2 tag="using-plugins">Using Plugins</h2>
{body}
</document>.toXMLString();
fileMap['plugins'] = function () ['application/xml;charset=UTF-8', help];
services.get("liberator:").init({ services.get("liberator:").init({
HELP_TAGS: tagMap, FILE_MAP: fileMap, HELP_TAGS: tagMap, FILE_MAP: fileMap,
OVERLAY_MAP: overlayMap, NAMESPACES: namespaces OVERLAY_MAP: overlayMap, NAMESPACES: namespaces
@@ -1796,8 +1818,6 @@ const liberator = (function () //{{{
let start = Date.now(); let start = Date.now();
liberator.log("Initializing liberator object...", 0); liberator.log("Initializing liberator object...", 0);
liberator.initHelp();
config.features.push(getPlatformFeature()); config.features.push(getPlatformFeature());
try try
@@ -1911,6 +1931,8 @@ const liberator = (function () //{{{
if (options["loadplugins"]) if (options["loadplugins"])
liberator.loadPlugins(); liberator.loadPlugins();
liberator.initHelp();
// after sourcing the initialization files, this function will set // after sourcing the initialization files, this function will set
// all gui options to their default values, if they have not been // all gui options to their default values, if they have not been
// set before by any RC file // set before by any RC file

View File

@@ -826,11 +826,11 @@ liberator.registerObserver("load_completion", function () {
completion.colorScheme = function colorScheme(context) { completion.colorScheme = function colorScheme(context) {
context.title = ["Color Scheme", "Runtime Path"]; context.title = ["Color Scheme", "Runtime Path"];
context.keys = { text: function (f) f.leafName.replace(/\.vimp$/, ""), description: "parent.path" }; context.keys = { text: function (f) f.leafName.replace(/\.vimp$/, ""), description: ".parent.path" };
context.completions = util.Array.flatten( context.completions = util.Array.flatten(
io.getRuntimeDirectories("colors").map( io.getRuntimeDirectories("colors").map(
function (dir) dir.readDirectory().filter( function (dir) dir.readDirectory().filter(
function (file) /\.vimp$/.test(file.leafName) && !colors.some(function (c) c.leafName == file.leafName)))) function (file) /\.vimp$/.test(file.leafName))))
}; };