1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-04 17:34:12 +01:00

moved more commands. the end of all the moving is near!

This commit is contained in:
Martin Stubenschrott
2008-02-28 23:55:02 +00:00
parent 8c45097170
commit 8184b1109f
6 changed files with 351 additions and 363 deletions

View File

@@ -42,6 +42,56 @@ vimperator.AutoCommands = function() //{{{
throw StopIteration;
}
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// COMMANDS ////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
vimperator.commands.add(["au[tocmd]"],
"Execute commands automatically on events",
function (args, special)
{
if (!args)
{
if (special) // :au!
vimperator.autocommands.remove(null, null);
else // :au
vimperator.autocommands.list(null, null);
}
else
{
// (?: ) means don't store; (....)? <-> exclamation marks makes the group optional
var [all, asterix, auEvent, regex, cmds] = args.match(/^(\*)?(?:\s+)?(\S+)(?:\s+)?(\S+)?(?:\s+)?(.+)?$/);
if (cmds)
{
vimperator.autocommands.add(auEvent, regex, cmds);
}
else if (regex) // e.g. no cmds provided
{
if (special)
vimperator.autocommands.remove(auEvent, regex);
else
vimperator.autocommands.list(auEvent, regex);
}
else if (auEvent)
{
if (asterix)
if (special)
vimperator.autocommands.remove(null, auEvent); // ':au! * auEvent'
else
vimperator.autocommands.list(null, auEvent);
else
if (special)
vimperator.autocommands.remove(auEvent, null);
else
vimperator.autocommands.list(auEvent, null);
}
}
},
{
completer: function (filter) { return vimperator.completion.autocommands(filter); }
});
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -514,6 +564,48 @@ vimperator.Events = function () //{{{
},
{ flags: vimperator.Mappings.flags.ARGUMENT | vimperator.Mappings.flags.COUNT });
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// COMMANDS ////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
vimperator.commands.add(["delmac[ros]"],
"Delete macros",
function (arg)
{
if (!arg)
vimperator.echoerr("E474: Invalid argument");
else
vimperator.events.deleteMacros(arg);
});
vimperator.commands.add(["macros"],
"List all macros",
function (arg)
{
var str = "<table>";
var macroRef = vimperator.events.getMacros(arg);
for (var item in macroRef)
str += "<tr><td> " + item + " &nbsp; </td><td>" +
vimperator.util.escapeHTML(macroRef[item]) + "</td></tr>";
str += "</table>";
vimperator.echo(str, vimperator.commandline.FORCE_MULTILINE);
});
vimperator.commands.add(["pl[ay]"],
"Replay a recorded macro",
function (arg)
{
if (!arg)
vimperator.echoerr("E474: Invalid argument");
else
vimperator.events.playMacro(arg);
},
{
completer: function (filter) { return vimperator.completion.macros(filter); }
});
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{