mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 07:27:58 +01:00
:macro for playing a macro added
This commit is contained in:
1
NEWS
1
NEWS
@@ -9,6 +9,7 @@
|
||||
* IMPORTANT: changed 'I' key to Ctrl-Q to also work in textboxes
|
||||
* IMPORTANT: :bmarks! and :history! open the matching items now in a tab, instead
|
||||
of bringing up the bookmarks/history window
|
||||
* :macro for playing a recorded macro
|
||||
* :[del]macros [regex] for listing/deleting recorded macros
|
||||
* :set! now lets you change about:config prefs similar to :set
|
||||
* new :command to add user defined commands
|
||||
|
||||
@@ -1439,7 +1439,7 @@ vimperator.Commands = function () //{{{
|
||||
completer: function (filter) { return vimperator.completion.autocommands(filter); }
|
||||
}
|
||||
));
|
||||
commandManager.add(new vimperator.Command(["mac[ros]"],
|
||||
commandManager.add(new vimperator.Command(["macros"],
|
||||
function (arg)
|
||||
{
|
||||
var str = "<table>";
|
||||
@@ -1472,6 +1472,21 @@ vimperator.Commands = function () //{{{
|
||||
help: "Delete recorded macros matching a regular expression."
|
||||
}
|
||||
));
|
||||
commandManager.add(new vimperator.Command(["mac[ro]"],
|
||||
function (arg)
|
||||
{
|
||||
if (!arg)
|
||||
vimperator.echoerr("E474: Invalid argument");
|
||||
else
|
||||
vimperator.events.playMacro(arg);
|
||||
},
|
||||
{
|
||||
usage: ["delmac[ros] [regex]"],
|
||||
shortHelp: "Delete macros matching a regex",
|
||||
help: "Delete recorded macros matching a regular expression.",
|
||||
completer: function (filter) { return vimperator.completion.macros(filter); }
|
||||
}
|
||||
));
|
||||
// 0 args -> list all maps
|
||||
// 1 arg -> list the maps starting with args
|
||||
// 2 args -> map arg1 to arg*
|
||||
|
||||
@@ -186,7 +186,21 @@ vimperator.Completion = function () //{{{
|
||||
|
||||
return [0, buildLongestCommonSubstring(mapped, filter)];
|
||||
},
|
||||
macros: function (filter)
|
||||
{
|
||||
var macros = [];
|
||||
var tmp = vimperator.events.getMacros();
|
||||
for (var item in tmp)
|
||||
macros.push([item, tmp[item]]);
|
||||
|
||||
if (!filter)
|
||||
return [0, macros];
|
||||
|
||||
var mapped = macros.map(function (macro) {
|
||||
return [[macro[0]], macro[1]];
|
||||
});
|
||||
return [0, buildLongestCommonSubstring(mapped, filter)];
|
||||
},
|
||||
// filter a list of urls
|
||||
//
|
||||
// may consist of search engines, filenames, bookmarks and history,
|
||||
|
||||
@@ -509,7 +509,7 @@ vimperator.Events = function () //{{{
|
||||
|
||||
playMacro: function (macro)
|
||||
{
|
||||
if (!/[a-zA-Z0-9@]/.test(macro))
|
||||
if (!/[a-zA-Z0-9@]/.test(macro) && macro.length == 1)
|
||||
{
|
||||
vimperator.echoerr("Register must be [a-z0-9]");
|
||||
return false;
|
||||
@@ -524,7 +524,10 @@ vimperator.Events = function () //{{{
|
||||
}
|
||||
else
|
||||
{
|
||||
lastMacro = macro.toLowerCase(); // XXX: sets last playerd macro, even if it does not yet exist
|
||||
if (macro.length == 1)
|
||||
lastMacro = macro.toLowerCase(); // XXX: sets last playerd macro, even if it does not yet exist
|
||||
else
|
||||
lastMacro = macro; // e.g. long names are case sensitive
|
||||
}
|
||||
|
||||
if (macros[lastMacro])
|
||||
@@ -532,7 +535,7 @@ vimperator.Events = function () //{{{
|
||||
vimperator.modes.isReplaying = true;
|
||||
BrowserStop(); // make sure the page is stopped before starting to play the macro
|
||||
vimperator.buffer.loaded = 1; // even if not a full page load, assume it did load correctly before starting the macro
|
||||
vimperator.events.feedkeys(macros[lastMacro], true); // true -> noremap
|
||||
vimperator.events.feedkeys(macros[lastMacro], true); // true -> noremap
|
||||
vimperator.modes.isReplaying = false;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user