1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-05 23:35:46 +01:00

Rename {Command,Map)#isUser{Command,Map} => #user.

This commit is contained in:
Doug Kearns
2009-07-07 22:08:51 +10:00
parent 4df207e6e5
commit 5e2b5b014b
2 changed files with 11 additions and 11 deletions

View File

@@ -165,7 +165,7 @@ function Command(specs, description, action, extraInfo) //{{{
* unlike basic commands, may be overwritten. Users and plugin authors * unlike basic commands, may be overwritten. Users and plugin authors
* should create only user commands. * should create only user commands.
*/ */
this.isUserCommand = extraInfo.isUserCommand || false; this.user = extraInfo.user || false;
/** /**
* @property {string} For commands defined via :command, contains the Ex * @property {string} For commands defined via :command, contains the Ex
* command line to be executed upon invocation. * command line to be executed upon invocation.
@@ -374,7 +374,7 @@ function Commands() //{{{
{ {
if (exCommands.some(function (c) c.hasName(command.name))) if (exCommands.some(function (c) c.hasName(command.name)))
{ {
if (command.isUserCommand && replace) if (command.user && replace)
commands.removeUserCommand(command.name); commands.removeUserCommand(command.name);
else else
{ {
@@ -490,7 +490,7 @@ function Commands() //{{{
addUserCommand: function (names, description, action, extra, replace) addUserCommand: function (names, description, action, extra, replace)
{ {
extra = extra || {}; extra = extra || {};
extra.isUserCommand = true; extra.user = true;
description = description || "User defined command"; description = description || "User defined command";
return addCommand(new Command(names, description, action, extra), replace); return addCommand(new Command(names, description, action, extra), replace);
@@ -544,7 +544,7 @@ function Commands() //{{{
*/ */
getUserCommand: function (name) getUserCommand: function (name)
{ {
return exCommands.filter(function (cmd) cmd.isUserCommand && cmd.hasName(name))[0] || null; return exCommands.filter(function (cmd) cmd.user && cmd.hasName(name))[0] || null;
}, },
/** /**
@@ -554,7 +554,7 @@ function Commands() //{{{
*/ */
getUserCommands: function () getUserCommands: function ()
{ {
return exCommands.filter(function (cmd) cmd.isUserCommand); return exCommands.filter(function (cmd) cmd.user);
}, },
// TODO: should it handle comments? // TODO: should it handle comments?
@@ -921,7 +921,7 @@ function Commands() //{{{
*/ */
removeUserCommand: function (name) removeUserCommand: function (name)
{ {
exCommands = exCommands.filter(function (cmd) !(cmd.isUserCommand && cmd.hasName(name))); exCommands = exCommands.filter(function (cmd) !(cmd.user && cmd.hasName(name)));
}, },
// FIXME: still belong here? Also used for autocommand parameters. // FIXME: still belong here? Also used for autocommand parameters.
@@ -1076,7 +1076,7 @@ function Commands() //{{{
// TODO: using an array comprehension here generates flakey results across repeated calls // TODO: using an array comprehension here generates flakey results across repeated calls
// : perhaps we shouldn't allow options in a list call but just ignore them for now // : perhaps we shouldn't allow options in a list call but just ignore them for now
let cmds = exCommands.filter(function (c) c.isUserCommand && (!cmd || c.name.match("^" + cmd))); let cmds = exCommands.filter(function (c) c.user && (!cmd || c.name.match("^" + cmd)));
if (cmds.length > 0) if (cmds.length > 0)
{ {
@@ -1124,7 +1124,7 @@ function Commands() //{{{
literalArg: cmd.replacementText literalArg: cmd.replacementText
} }
for ([k, cmd] in Iterator(exCommands)) for ([k, cmd] in Iterator(exCommands))
if (cmd.isUserCommand && cmd.replacementText) if (cmd.user && cmd.replacementText)
] ]
}); });

View File

@@ -91,7 +91,7 @@ function Map(modes, keys, description, action, extraInfo) //{{{
* mappings may be created by plugins, or directly by users. Users and * mappings may be created by plugins, or directly by users. Users and
* plugin authors should create only user mappings. * plugin authors should create only user mappings.
*/ */
this.isUserMap = extraInfo.isUserMap || false; this.user = extraInfo.user || false;
} }
Map.prototype = { Map.prototype = {
@@ -156,7 +156,7 @@ function Mappings() //{{{
function addMap(map) function addMap(map)
{ {
let where = map.isUserMap ? user : main; let where = map.user ? user : main;
map.modes.forEach(function (mode) { map.modes.forEach(function (mode) {
if (!(mode in where)) if (!(mode in where))
where[mode] = []; where[mode] = [];
@@ -401,7 +401,7 @@ function Mappings() //{{{
{ {
keys = keys.map(expandLeader); keys = keys.map(expandLeader);
extra = extra || {}; extra = extra || {};
extra.isUserMap = true; extra.user = true;
let map = new Map(modes, keys, description || "User defined mapping", action, extra); let map = new Map(modes, keys, description || "User defined mapping", action, extra);
// remove all old mappings to this key sequence // remove all old mappings to this key sequence