mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 18:17:58 +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:
@@ -982,7 +982,7 @@ var Commands = Module("commands", {
|
||||
<forbid>
|
||||
]
|
||||
[^ <forbid> ]*
|
||||
]]>, "", {
|
||||
]]>, "g", {
|
||||
forbid: util.regexp(String.replace(<![CDATA[
|
||||
U0000-U002c // U002d -
|
||||
U002e-U002f
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -993,7 +993,7 @@ unlet s:cpo_save
|
||||
modules.JavaScript.setCompleter([File, File.expandPath],
|
||||
[function (context, obj, args) {
|
||||
context.quote[2] = "";
|
||||
completion.file(context, true);
|
||||
modules.completion.file(context, true);
|
||||
}]);
|
||||
|
||||
},
|
||||
|
||||
@@ -1353,7 +1353,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
* @param {string} string The string to search.
|
||||
* @param {number} lastIndex The index at which to begin searching. @optional
|
||||
*/
|
||||
iterate: function iterate(regexp, string, lastIndex) {
|
||||
iterate: function iterate(regexp, string, lastIndex) iter(function () {
|
||||
regexp.lastIndex = lastIndex = lastIndex || 0;
|
||||
let match;
|
||||
while (match = regexp.exec(string)) {
|
||||
@@ -1363,7 +1363,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
if (match[0].length == 0 || !regexp.global)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}())
|
||||
}),
|
||||
|
||||
rehash: function (args) {
|
||||
|
||||
Reference in New Issue
Block a user