1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 18:42:27 +01:00

Fix color scheme completion

This commit is contained in:
Kris Maglione
2008-11-25 09:59:11 +00:00
parent b5141bb85f
commit e044d5fddd
2 changed files with 22 additions and 17 deletions

View File

@@ -54,7 +54,7 @@ function CompletionContext(editor, name, offset)
this.parent = parent; this.parent = parent;
this.offset = parent.offset + (offset || 0); this.offset = parent.offset + (offset || 0);
this.keys = util.cloneObject(this.parent.keys); this.keys = util.cloneObject(this.parent.keys);
["compare", "editor", "filterFunc", "keys", "title", "top"].forEach(function (key) ["compare", "editor", "filterFunc", "keys", "quote", "title", "top"].forEach(function (key)
self[key] = parent[key]); self[key] = parent[key]);
["contextList", "onUpdate", "selectionTypes", "tabPressed", "updateAsync", "value"].forEach(function (key) { ["contextList", "onUpdate", "selectionTypes", "tabPressed", "updateAsync", "value"].forEach(function (key) {
self.__defineGetter__(key, function () this.top[key]); self.__defineGetter__(key, function () this.top[key]);
@@ -187,18 +187,17 @@ CompletionContext.prototype = {
return items; return items;
let self = this; let self = this;
let text = function (item) item[self.keys["text"]];
if (self.quote)
text = function (item) self.quote(item[self.keys["text"]]);
completion.getKey = this.getKey; // XXX completion.getKey = this.getKey; // XXX
this.cache.filtered = this.filterFunc(items.map(function (item) ({ text: text(item), item: item })), let filtered = this.filterFunc(items.map(function (item) ({ text: item[self.keys["text"]], item: item })),
this.filter, this.anchored); this.filter, this.anchored);
if (options.get("wildoptions").has("sort"))
this.cache.filtered.sort(this.compare);
completion.getKey = null; completion.getKey = null;
return this.cache.filtered; if (self.quote)
filtered.forEach(function (item) item.text = self.quote(item.text));
if (options.get("wildoptions").has("sort"))
filtered.sort(this.compare);
return this.cache.filtered = filtered;
}, },
get process() // FIXME get process() // FIXME
@@ -220,6 +219,9 @@ CompletionContext.prototype = {
advance: function advance(count) advance: function advance(count)
{ {
this.offset += count; this.offset += count;
// XXX
if (this._filter)
this._filter = this._filter.substr(count);
}, },
getItems: function (start, end) getItems: function (start, end)
@@ -1112,14 +1114,16 @@ function Completion() //{{{
}); });
}, },
colorScheme: function colorScheme(filter) colorScheme: function colorScheme(context)
{ {
let rtp = options["runtimepath"].split(","); options["runtimepath"].split(",").forEach(function (path) {
let schemes = rtp.map(function (path) // FIXME: Now! Very, very broken. context.fork(path, 0, null, function (context) {
[[c[0].replace(/\.vimp$/, ""), ""] context.filter = path + "/colors/" + context.filter;
for each (c in completion.file(path + "/colors/", true)[1])]); completion.file(context, true);
context.title = [path + "/colors/"];
return [0, completion.filter(util.Array.flatten(schemes), filter)]; context.quote = function (text) text.replace(/\.vimp$/, "");
});
});
}, },
command: function command(context) command: function command(context)
@@ -1215,6 +1219,7 @@ function Completion() //{{{
context.keys = { text: 0, description: 1, icon: 2 }; context.keys = { text: 0, description: 1, icon: 2 };
context.anchored = true; context.anchored = true;
context.key = dir; context.key = dir;
context.quote = function (text) text.replace(" ", "\\ ", "g");
context.generate = function generate() context.generate = function generate()
{ {
context.cache.dir = dir; context.cache.dir = dir;
@@ -1230,7 +1235,7 @@ function Completion() //{{{
} }
return files.map( return files.map(
function (file) [(tail ? file.leafName : dir + file.leafName).replace(" ", "\\ ", "g"), function (file) [tail ? file.leafName : dir + file.leafName,
file.isDirectory() ? "Directory" : "File", file.isDirectory() ? "Directory" : "File",
file.isDirectory() ? "resource://gre/res/html/folder.png" file.isDirectory() ? "resource://gre/res/html/folder.png"
: "moz-icon://" + file.leafName] : "moz-icon://" + file.leafName]

View File

@@ -388,7 +388,7 @@ liberator.registerObserver("load_commands", function ()
}, },
{ {
argCount: 1, argCount: 1,
completer: function (context) completion.colorScheme(context.filter) completer: function (context) completion.colorScheme(context)
}); });
commands.add(["sty[le]"], commands.add(["sty[le]"],