mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 09:17:59 +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: changed 'I' key to Ctrl-Q to also work in textboxes
|
||||||
* IMPORTANT: :bmarks! and :history! open the matching items now in a tab, instead
|
* IMPORTANT: :bmarks! and :history! open the matching items now in a tab, instead
|
||||||
of bringing up the bookmarks/history window
|
of bringing up the bookmarks/history window
|
||||||
|
* :macro for playing a recorded macro
|
||||||
* :[del]macros [regex] for listing/deleting recorded macros
|
* :[del]macros [regex] for listing/deleting recorded macros
|
||||||
* :set! now lets you change about:config prefs similar to :set
|
* :set! now lets you change about:config prefs similar to :set
|
||||||
* new :command to add user defined commands
|
* new :command to add user defined commands
|
||||||
|
|||||||
@@ -1439,7 +1439,7 @@ vimperator.Commands = function () //{{{
|
|||||||
completer: function (filter) { return vimperator.completion.autocommands(filter); }
|
completer: function (filter) { return vimperator.completion.autocommands(filter); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
commandManager.add(new vimperator.Command(["mac[ros]"],
|
commandManager.add(new vimperator.Command(["macros"],
|
||||||
function (arg)
|
function (arg)
|
||||||
{
|
{
|
||||||
var str = "<table>";
|
var str = "<table>";
|
||||||
@@ -1472,6 +1472,21 @@ vimperator.Commands = function () //{{{
|
|||||||
help: "Delete recorded macros matching a regular expression."
|
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
|
// 0 args -> list all maps
|
||||||
// 1 arg -> list the maps starting with args
|
// 1 arg -> list the maps starting with args
|
||||||
// 2 args -> map arg1 to arg*
|
// 2 args -> map arg1 to arg*
|
||||||
|
|||||||
@@ -186,7 +186,21 @@ vimperator.Completion = function () //{{{
|
|||||||
|
|
||||||
return [0, buildLongestCommonSubstring(mapped, filter)];
|
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
|
// filter a list of urls
|
||||||
//
|
//
|
||||||
// may consist of search engines, filenames, bookmarks and history,
|
// may consist of search engines, filenames, bookmarks and history,
|
||||||
|
|||||||
@@ -509,7 +509,7 @@ vimperator.Events = function () //{{{
|
|||||||
|
|
||||||
playMacro: function (macro)
|
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]");
|
vimperator.echoerr("Register must be [a-z0-9]");
|
||||||
return false;
|
return false;
|
||||||
@@ -524,7 +524,10 @@ vimperator.Events = function () //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (macro.length == 1)
|
||||||
lastMacro = macro.toLowerCase(); // XXX: sets last playerd macro, even if it does not yet exist
|
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])
|
if (macros[lastMacro])
|
||||||
|
|||||||
Reference in New Issue
Block a user