mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 12:47:58 +01:00
Fix bugs. Add optional bang to :loadplugins.
--HG-- branch : groups
This commit is contained in:
@@ -103,6 +103,7 @@ var Group = Class("Group", {
|
||||
memoize(Group.prototype, name, function () {
|
||||
let group = constructor(this);
|
||||
this.hives.push(group);
|
||||
delete contexts.groups;
|
||||
return group;
|
||||
});
|
||||
|
||||
@@ -126,7 +127,7 @@ var Contexts = Module("contexts", {
|
||||
|
||||
this.builtin = this.addGroup("builtin", "Builtin items");
|
||||
this.user = this.addGroup("user", "User-defined items", null, true);
|
||||
this.builtinGroups = [this.system, this.user];
|
||||
this.builtinGroups = [this.builtin, this.user];
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
@@ -157,11 +158,16 @@ var Contexts = Module("contexts", {
|
||||
get hives() Group.hiveMap,
|
||||
|
||||
addGroup: function addGroup(name, description, filter, persist, replace) {
|
||||
let group = this.getGroup(name);
|
||||
if (group)
|
||||
name = group.name;
|
||||
|
||||
if (replace)
|
||||
this.removeGroup(name);
|
||||
|
||||
let group = this.groupMap[name];
|
||||
if (!group) {
|
||||
if (!group || replace) {
|
||||
dactyl.assert(name !== "default", "Illegal group name");
|
||||
|
||||
group = Group(name, description, filter, persist);
|
||||
this.groupList.unshift(group);
|
||||
this.groupMap[name] = group;
|
||||
@@ -183,6 +189,7 @@ var Contexts = Module("contexts", {
|
||||
dactyl.assert(!group || !group.builtin, "Cannot remove builtin group");
|
||||
|
||||
if (group) {
|
||||
name = group.name;
|
||||
this.groupList.splice(this.groupList.indexOf(group), 1);
|
||||
group.cleanup();
|
||||
group.destroy();
|
||||
@@ -201,7 +208,7 @@ var Contexts = Module("contexts", {
|
||||
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;
|
||||
group = set.has(this.groupMap, name) && this.groupMap[name];
|
||||
|
||||
if (group && hive)
|
||||
return group[hive];
|
||||
|
||||
@@ -1031,7 +1031,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
get: function globalVariables() this._globalVariables
|
||||
}),
|
||||
|
||||
loadPlugins: function (args) {
|
||||
loadPlugins: function (args, force) {
|
||||
function sourceDirectory(dir) {
|
||||
dactyl.assert(dir.isReadable(), "E484: Can't open file " + dir.path);
|
||||
|
||||
@@ -1042,7 +1042,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
loadplugins = { __proto__: loadplugins, value: args.map(Option.parseRegexp) }
|
||||
|
||||
dir.readDirectory(true).forEach(function (file) {
|
||||
if (file.isFile() && loadplugins.getKey(file.path) && !(file.path in dactyl.pluginFiles)) {
|
||||
if (file.isFile() && loadplugins.getKey(file.path) && !(!force && file.path in dactyl.pluginFiles)) {
|
||||
try {
|
||||
io.source(file.path);
|
||||
dactyl.pluginFiles[file.path] = true;
|
||||
@@ -1756,10 +1756,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
commands.add(["loadplugins", "lpl"],
|
||||
"Load all plugins immediately",
|
||||
function (args) {
|
||||
dactyl.loadPlugins(args.length ? args : null);
|
||||
dactyl.loadPlugins(args.length ? args : null, args.bang);
|
||||
},
|
||||
{
|
||||
argCount: "*",
|
||||
bang: true,
|
||||
keepQuotes: true,
|
||||
serialGroup: 10,
|
||||
serialize: function () [
|
||||
|
||||
@@ -38,8 +38,6 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
},
|
||||
|
||||
execute: function execute(result, force) {
|
||||
function dbg() {}
|
||||
|
||||
if (force && this.actions.length)
|
||||
this.processors.length = 0;
|
||||
|
||||
@@ -71,7 +69,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
else if (result === undefined)
|
||||
result = Events.PASS;
|
||||
|
||||
dbg("RESULT: " + (result === Events.KILL ? "KILL" :
|
||||
events.dbg("RESULT: " + (result === Events.KILL ? "KILL" :
|
||||
result === Events.PASS ? "PASS" :
|
||||
result === Events.ABORT ? "ABORT" : result));
|
||||
|
||||
@@ -79,7 +77,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
Events.kill(this.events[this.events.length - 1]);
|
||||
|
||||
if (result === Events.PASS || result === Events.ABORT) {
|
||||
let list = this.events.filter(function (e) e.getPreventDefault());
|
||||
let list = this.events.filter(function (e) e.getPreventDefault() && !e.dactylDefaultPrevented);
|
||||
if (list.length)
|
||||
events.dbg("REFEED: " + list.map(events.closure.toString).join(""));
|
||||
|
||||
@@ -102,8 +100,6 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
},
|
||||
|
||||
process: function process(event) {
|
||||
function dbg() {}
|
||||
|
||||
if (this.timer)
|
||||
this.timer.cancel();
|
||||
|
||||
@@ -115,15 +111,15 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
let actions = [];
|
||||
let processors = [];
|
||||
|
||||
dbg("\n\n");
|
||||
dbg("KEY: " + key + " skipmap: " + event.skipmap + " macro: " + event.isMacro);
|
||||
events.dbg("\n\n");
|
||||
events.dbg("KEY: " + key + " skipmap: " + event.skipmap + " macro: " + event.isMacro);
|
||||
|
||||
for (let [i, input] in Iterator(this.processors)) {
|
||||
let res = input.process(event);
|
||||
if (res !== Events.ABORT)
|
||||
var result = res;
|
||||
|
||||
dbg("RES: " + input + " " + (callable(res) ? {}.toString.call(res) : res));
|
||||
events.dbg("RES: " + input + " " + (callable(res) ? {}.toString.call(res) : res));
|
||||
|
||||
if (res === Events.KILL)
|
||||
break;
|
||||
@@ -139,9 +135,9 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
processors.push(input);
|
||||
}
|
||||
|
||||
dbg("RESULT: " + (callable(result) ? {}.toString.call(result) : result) + " " + event.getPreventDefault());
|
||||
dbg("ACTIONS: " + actions.length + " " + this.actions.length);
|
||||
dbg("PROCESSORS:", processors);
|
||||
events.dbg("RESULT: " + (callable(result) ? {}.toString.call(result) : result) + " " + event.getPreventDefault());
|
||||
events.dbg("ACTIONS: " + actions.length + " " + this.actions.length);
|
||||
events.dbg("PROCESSORS:", processors);
|
||||
|
||||
this._actions = actions;
|
||||
this.actions = actions.concat(this.actions);
|
||||
|
||||
Reference in New Issue
Block a user