1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-07 12:05:47 +01:00

add rough initial implementation of :colorscheme

This commit is contained in:
Doug Kearns
2008-11-01 11:18:37 +00:00
parent fdd2339274
commit 2b3ef469c4
2 changed files with 63 additions and 35 deletions

View File

@@ -268,41 +268,7 @@ function IO() //{{{
commands.add(["runt[ime]"],
"Source the specified file from each directory in 'runtimepath'",
function (args, special)
{
// TODO: support backslash escaped whitespace in filenames
// : wildcards/regexp
// : unify with startup sourcing loop
let paths = args.arguments;
let runtimeDirs = options["runtimepath"].split(",");
let found = false;
// FIXME: should use original arg string
liberator.echomsg("Searching for \"" + paths.join(" ") + "\" in \"" + options["runtimepath"] + "\"", 2);
outer:
for (let [,runtimeDir] in Iterator(runtimeDirs))
{
for (let [,path] in Iterator(paths))
{
let file = io.getFile(joinPaths(runtimeDir, path));
liberator.echomsg("Searching for \"" + file.path + "\" in \"", 3);
if (file.exists() && file.isReadable() && !file.isDirectory()) // XXX
{
found = true;
io.source(file.path, false);
if (!special)
break outer;
}
}
}
if (!found)
liberator.echomsg("not found in 'runtimepath': \"" + paths.join(" ") + "\"", 1); // FIXME: should use original arg string
},
function (args, special) { io.sourceFromRuntimePath(args.arguments, special); },
{
argCount: "+",
bang: true
@@ -746,6 +712,41 @@ lookup:
return output;
},
// FIXME: multiple paths?
sourceFromRuntimePath: function (paths, all)
{
let runtimeDirs = options["runtimepath"].split(",");
let found = false;
// FIXME: should use original arg string
liberator.echomsg("Searching for \"" + paths.join(" ") + "\" in \"" + options["runtimepath"] + "\"", 2);
outer:
for (let [,runtimeDir] in Iterator(runtimeDirs))
{
for (let [,path] in Iterator(paths))
{
let file = io.getFile(joinPaths(runtimeDir, path));
liberator.echomsg("Searching for \"" + file.path, 3);
if (file.exists() && file.isReadable() && !file.isDirectory()) // XXX
{
found = true;
io.source(file.path, false);
if (!all)
break outer;
}
}
}
if (!found)
liberator.echomsg("not found in 'runtimepath': \"" + paths.join(" ") + "\"", 1); // FIXME: should use original arg string
return found;
},
// files which end in .js are sourced as pure javascript files,
// no need (actually forbidden) to add: js <<EOF ... EOF around those files
source: function (filename, silent)

View File

@@ -362,6 +362,32 @@ const highlight = storage.newObject("highlight", Highlights, false);
liberator.registerObserver("load_commands", function ()
{
commands.add(["colo[rscheme]"],
"Load a color scheme",
function (args)
{
let scheme = args.arguments[0];
if (!io.sourceFromRuntimePath(["colors/" + scheme + ".vimp"]))
liberator.echoerr("E185: Cannot find color scheme " + scheme);
},
{
argCount: 1,
completer: function (filter)
{
let rtp = options["runtimepath"].split(",");
let schemes = [];
rtp.forEach(function (path) {
schemes = schemes.concat(
[[c[0].replace(/\.vimp$/, ""), ""] for each (c in completion.file(path + "/colors/", true)[1])]
)
});
return [0, completion.filter(schemes, filter)];
}
});
commands.add(["sty[le]"],
"Add or list user styles",
function (args, special)
@@ -498,3 +524,4 @@ liberator.registerObserver("load_commands", function ()
});
});
// vim: set fdm=marker sw=4 ts=4 et: