1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-30 09:12:26 +01:00

More group tweaks: colors- prefix for color scheme groups. :group default to return to the default group for your script.

--HG--
branch : groups
This commit is contained in:
Kris Maglione
2011-02-06 11:21:58 -05:00
parent f1db6ae5c1
commit 4a43477980
4 changed files with 22 additions and 10 deletions

View File

@@ -147,7 +147,11 @@ var Contexts = Module("contexts", {
},
getGroup: function getGroup(name, subGroup) {
let group = array.nth(this.groupList, function (h) h.name == name, 0) || null;
if (name === "default")
var group = this.context && this.context.context && this.context.context.GROUP;
else
group = array.nth(this.groupList, function (h) h.name == name, 0) || null;
if (group && subGroup)
return group[subGroup];
return group;
@@ -213,8 +217,12 @@ var Contexts = Module("contexts", {
Context: modules.Script = function Context(file, group, args) {
function Const(val) Class.Property({ enumerable: true, value: val });
let isPlugin = io.getRuntimeDirectories("plugins")
.some(function (dir) dir.contains(file, false))
let isPlugin = array.nth(io.getRuntimeDirectories("plugins"),
function (dir) dir.contains(file, true),
0);
let isRuntime = array.nth(io.getRuntimeDirectories(""),
function (dir) dir.contains(file, true),
0);
let self = set.has(plugins, file.path) && plugins[file.path];
if (self) {
@@ -222,8 +230,9 @@ var Contexts = Module("contexts", {
self.onUnload();
}
else {
let name = isPlugin ? file.getRelativeDescriptor(isPlugin).replace(File.PATH_SEP, "-") : file.leafName;
self = update(modules.newContext.apply(null, args || [userContext]), {
NAME: Const(file.leafName.replace(/\..*/, "").replace(/-([a-z])/g, function (m, n1) n1.toUpperCase())),
NAME: Const(name.replace(/\..*/, "").replace(/-([a-z])/g, function (m, n1) n1.toUpperCase())),
PATH: Const(file.path),
CONTEXT: Const(self),
unload: Const(function unload() {
@@ -248,9 +257,12 @@ var Contexts = Module("contexts", {
});
}
let path = isRuntime ? file.getRelativeDescriptor(isRuntime) : file.path;
self.GROUP = group ||
contexts.addGroup(isPlugin ? "plugin-" + self.NAME
: "script-" + array(commands.nameRegexp.iterate(file.path)).join("-"),
contexts.addGroup((isRuntime ? "" : "script-") +
commands.nameRegexp.iterate(path.replace(/\..*/, ""))
.join("-"),
"Script group for " + file.path,
null, false);