mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-16 08:23:38 +01:00
add rough initial implementation of :colorscheme
This commit is contained in:
@@ -268,41 +268,7 @@ function IO() //{{{
|
|||||||
|
|
||||||
commands.add(["runt[ime]"],
|
commands.add(["runt[ime]"],
|
||||||
"Source the specified file from each directory in 'runtimepath'",
|
"Source the specified file from each directory in 'runtimepath'",
|
||||||
function (args, special)
|
function (args, special) { io.sourceFromRuntimePath(args.arguments, 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
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
argCount: "+",
|
argCount: "+",
|
||||||
bang: true
|
bang: true
|
||||||
@@ -746,6 +712,41 @@ lookup:
|
|||||||
return output;
|
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,
|
// files which end in .js are sourced as pure javascript files,
|
||||||
// no need (actually forbidden) to add: js <<EOF ... EOF around those files
|
// no need (actually forbidden) to add: js <<EOF ... EOF around those files
|
||||||
source: function (filename, silent)
|
source: function (filename, silent)
|
||||||
|
|||||||
@@ -362,6 +362,32 @@ const highlight = storage.newObject("highlight", Highlights, false);
|
|||||||
|
|
||||||
liberator.registerObserver("load_commands", function ()
|
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]"],
|
commands.add(["sty[le]"],
|
||||||
"Add or list user styles",
|
"Add or list user styles",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
@@ -498,3 +524,4 @@ liberator.registerObserver("load_commands", function ()
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
Reference in New Issue
Block a user