1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-03 20:44:16 +01:00

Experimentally move commands.js and options.js to modules. Fix some bugs.

--HG--
branch : groups
rename : common/content/commands.js => common/modules/commands.jsm
rename : common/content/options.js => common/modules/options.jsm
This commit is contained in:
Kris Maglione
2011-02-10 15:40:09 -05:00
parent 1299fddfd3
commit 60063a8f91
12 changed files with 595 additions and 463 deletions

View File

@@ -170,7 +170,7 @@ var MapHive = Class("MapHive", Group.Hive, {
extra = extra || {};
let map = Map(modes, keys, description, action, extra);
map.definedAt = Commands.getCaller(Components.stack.caller);
map.definedAt = contexts.getCaller(Components.stack.caller);
map.hive = this;
if (this.name !== "builtin")
@@ -341,7 +341,7 @@ var Mappings = Module("mappings", {
*/
add: function () {
let map = this.builtin.add.apply(this.builtin, arguments);
map.definedAt = Commands.getCaller(Components.stack.caller);
map.definedAt = contexts.getCaller(Components.stack.caller);
return map;
},
@@ -358,7 +358,7 @@ var Mappings = Module("mappings", {
*/
addUserMap: function () {
let map = this.user.add.apply(this.user, arguments);
map.definedAt = Commands.getCaller(Components.stack.caller);
map.definedAt = contexts.getCaller(Components.stack.caller);
return map;
},
@@ -454,6 +454,9 @@ var Mappings = Module("mappings", {
if (!rhs) // list the mapping
mappings.list(mapmodes, mappings.expandLeader(lhs), hives);
else {
util.assert(args["-group"] !== mappings.builtin,
"Cannot change mappings in the builtin group");
args["-group"].add(mapmodes, [lhs],
args["-description"],
contexts.bindMacro(args, "-keys", function (params) params),
@@ -572,6 +575,9 @@ var Mappings = Module("mappings", {
commands.add([ch + "mapc[lear]"],
"Remove all mappings" + modeDescription,
function (args) {
util.assert(args["-group"] !== mappings.builtin,
"Cannot change mappings in the builtin group");
let mapmodes = array.uniq(args["-modes"].map(findMode));
mapmodes.forEach(function (mode) {
args["-group"].clear(mode);
@@ -593,6 +599,9 @@ var Mappings = Module("mappings", {
commands.add([ch + "unm[ap]"],
"Remove a mapping" + modeDescription,
function (args) {
util.assert(args["-group"] !== mappings.builtin,
"Cannot change mappings in the builtin group");
let mapmodes = array.uniq(args["-modes"].map(findMode));
let found = false;