From 2b3ef469c4c3f7d3f50f42af6e4defa21a9648ea Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Sat, 1 Nov 2008 11:18:37 +0000 Subject: [PATCH] add rough initial implementation of :colorscheme --- content/io.js | 71 ++++++++++++++++++++++++------------------------ content/style.js | 27 ++++++++++++++++++ 2 files changed, 63 insertions(+), 35 deletions(-) diff --git a/content/io.js b/content/io.js index d1a8630a..a5d7a0df 100644 --- a/content/io.js +++ b/content/io.js @@ -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 <