1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 10:07:59 +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

@@ -982,7 +982,7 @@ var Commands = Module("commands", {
<forbid> <forbid>
] ]
[^ <forbid> ]* [^ <forbid> ]*
]]>, "", { ]]>, "g", {
forbid: util.regexp(String.replace(<![CDATA[ forbid: util.regexp(String.replace(<![CDATA[
U0000-U002c // U002d - U0000-U002c // U002d -
U002e-U002f U002e-U002f

View File

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

View File

@@ -993,7 +993,7 @@ unlet s:cpo_save
modules.JavaScript.setCompleter([File, File.expandPath], modules.JavaScript.setCompleter([File, File.expandPath],
[function (context, obj, args) { [function (context, obj, args) {
context.quote[2] = ""; context.quote[2] = "";
completion.file(context, true); modules.completion.file(context, true);
}]); }]);
}, },

View File

@@ -1353,7 +1353,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* @param {string} string The string to search. * @param {string} string The string to search.
* @param {number} lastIndex The index at which to begin searching. @optional * @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; regexp.lastIndex = lastIndex = lastIndex || 0;
let match; let match;
while (match = regexp.exec(string)) { 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) if (match[0].length == 0 || !regexp.global)
break; break;
} }
} }())
}), }),
rehash: function (args) { rehash: function (args) {