1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-30 02:23:33 +02:00

fix extra_info processing in Map() and other minor typos

This commit is contained in:
Doug Kearns
2007-05-30 07:22:05 +00:00
parent 2d1c1e3b92
commit 2e116c374e

View File

@@ -1,40 +1,59 @@
// TODO: document // TODO: document
function Map(mode, cmds, act, extra_info) function Map(mode, cmds, act, extra_info)
{ {
if (!mode || (!cmds || !cmds.length) || !action) if (!mode || (!cmds || !cmds.length) || !act)
return null; return null;
if (!extra_info)
extra_info = {};
var action = act; var action = act;
var flags = extra_info.flags || 0;
this.mode = mode; this.mode = mode;
this.commands = cmds; this.commands = cmds;
if (extra_info)
{
var flags = extra_info.flags || 0;
if (extra_info.usage) if (extra_info.usage)
this.usage = extra_info.usage; this.usage = extra_info.usage;
else else
{ {
var usage = ""; this.usage = "";
if (flags & vimperator.mappings.flags.COUNT) if (flags & vimperator.mappings.flags.COUNT)
usage = "{count}"; this.usage = "{count}";
this.usage += this.commands;
usage += cmd;
if (flags & vimperator.mappings.flags.ARGUMENT) if (flags & vimperator.mappings.flags.ARGUMENT)
usage += " {arg}"; this.usage += " {arg}";
} }
if (extra_info.help) if (extra_info.help)
this.help = extra_info.help; this.help = extra_info.help;
else
this.help = null;
if (extra_info.short_help) if (extra_info.short_help)
this.short_help = extra_info.short_help; this.short_help = extra_info.short_help;
else
this.short_help = null;
}
// XXX: can we move this to Map.prototype.execute, or don't we have access to this in a prototype? // XXX: can we move this to Map.prototype.execute, or don't we have access to this in a prototype?
this.execute = function() { this.execute = function()
{
action.call(this); action.call(this);
} }
this.toString = function()
{
// FIXME: -- djk
return "Map {" +
"\nmode: " + this.mode +
"\ncommands: " + this.commands +
"\naction: " + action +
"\nusage: " + this.usage +
"\nshort_help: " + this.short_help +
"\nhelp: " + this.help +
"\n}"
}
} }
function Mappings() function Mappings()
@@ -82,7 +101,6 @@ function Mappings()
ARGUMENT: 1 << 2 ARGUMENT: 1 << 2
}; };
// add a user mapping
this.add = function(map) this.add = function(map)
{ {
if (!map) if (!map)