mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-10 21:24:11 +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:
File diff suppressed because it is too large
Load Diff
@@ -148,6 +148,23 @@ var Contexts = Module("contexts", {
|
||||
|
||||
context: null,
|
||||
|
||||
/**
|
||||
* Returns a frame object describing the currently executing
|
||||
* command, if applicable, otherwise returns the passed frame.
|
||||
*
|
||||
* @param {nsIStackFrame} frame
|
||||
*/
|
||||
getCaller: function getCaller(frame) {
|
||||
if (this.context && this.context.file)
|
||||
return {
|
||||
__proto__: frame,
|
||||
filename: this.context.file[0] == "[" ? this.context.file
|
||||
: services.io.newFileURI(File(this.context.file)).spec,
|
||||
lineNumber: this.context.line
|
||||
};
|
||||
return frame;
|
||||
},
|
||||
|
||||
groups: Class.memoize(function () Object.create(Group.groupsProto, {
|
||||
groups: { value: this.activeGroups().filter(function (g) g.filter(buffer.uri)) }
|
||||
})),
|
||||
@@ -216,8 +233,8 @@ var Contexts = Module("contexts", {
|
||||
getGroup: function getGroup(name, hive) {
|
||||
if (name === "default")
|
||||
var group = this.context && this.context.context && this.context.context.GROUP;
|
||||
else
|
||||
group = set.has(this.groupMap, name) && this.groupMap[name];
|
||||
else if (set.has(this.groupMap, name))
|
||||
group = this.groupMap[name];
|
||||
|
||||
if (group && hive)
|
||||
return group[hive];
|
||||
|
||||
@@ -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;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user