1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 22:08:00 +01:00

marco code, not fully functional yet

This commit is contained in:
Marco Candrian
2007-12-16 00:45:34 +00:00
parent 1de6096906
commit 8b1b17a84f
3 changed files with 59 additions and 4 deletions

View File

@@ -245,6 +245,10 @@ vimperator.Events = function () //{{{
}
}
var macros = {};
var isRecording = false;
var currentMacro;
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -253,6 +257,23 @@ vimperator.Events = function () //{{{
wantsModeReset: true, // used in onFocusChange since Firefox is so buggy here
startRecording: function (reg)
{
isRecording = true;
vimperator.modes.add(vimperator.modes.RECORDING);
currentMacro = reg;
macros[currentMacro] = "";
vimperator.echo("recording into register " + currentMacro + "...");
},
playMacro: function (reg)
{
if (macros[reg])
vimperator.events.feedkeys(macros[reg], true); // true -> noremap
else
vimperator.echoerr("Register '" + reg + " not set");
},
destroy: function ()
{
// removeEventListeners() to avoid mem leaks
@@ -570,6 +591,23 @@ vimperator.Events = function () //{{{
if (!key)
return true;
if (isRecording)
{
if (key == "q") // TODO: should not be hardcoded
{
isRecording = false;
vimperator.modes.remove(vimperator.modes.RECORDING);
vimperator.echo("recorded " + currentMacro + " : " + macros[currentMacro]); // DEBUG:
event.preventDefault(); // XXX: or howto stop that key beeing processed?
event.stopPropagation();
return true;
}
else if (!vimperator.mappings.hasMap(vimperator.mode, vimperator.input.buffer + key))
{
macros[currentMacro] += key;
}
}
var stop = true; // set to false if we should NOT consume this event but let also firefox handle it
var win = document.commandDispatcher.focusedWindow;
@@ -673,11 +711,11 @@ vimperator.Events = function () //{{{
else if (vimperator.input.pendingArgMap)
{
vimperator.input.buffer = "";
var tmp = vimperator.input.pendingArgMap; // must be set to null before .execute; if not
vimperator.input.pendingArgMap = null; // v.inputpendingArgMap is still 'true' also for new feeded keys
if (key != "<Esc>" && key != "<C-[>")
vimperator.input.pendingArgMap.execute(null, vimperator.input.count, key);
tmp.execute(null, vimperator.input.count, key);
vimperator.input.pendingArgMap = null;
}
else if (map)
{