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

Dont display "replaying" unless playing back a macro

This commit is contained in:
Kris Maglione
2008-10-12 15:57:54 +00:00
parent 7a61111e35
commit afcd5cbaeb
2 changed files with 18 additions and 15 deletions

View File

@@ -276,7 +276,6 @@ liberator.Events = function () //{{{
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
var replayingMacro;
var inputBufferLength = 0; // count the number of keys in v.input.buffer (can be different from v.input.buffer.length) var inputBufferLength = 0; // count the number of keys in v.input.buffer (can be different from v.input.buffer.length)
var skipMap = false; // while feeding the keys (stored in v.input.buffer | no map found) - ignore mappings var skipMap = false; // while feeding the keys (stored in v.input.buffer | no map found) - ignore mappings
@@ -553,7 +552,7 @@ liberator.Events = function () //{{{
if ((now - then) % 1000 < 10) if ((now - then) % 1000 < 10)
liberator.dump("waited: " + (now - then) + " ms"); liberator.dump("waited: " + (now - then) + " ms");
if (!liberator.modes.isReplaying) if (!liberator.events.feedingKeys)
return false; return false;
if (liberator.buffer.loaded > 0) if (liberator.buffer.loaded > 0)
@@ -713,6 +712,8 @@ liberator.Events = function () //{{{
var eventManager = { var eventManager = {
feedingKeys: false,
wantsModeReset: true, // used in onFocusChange since Firefox is so buggy here wantsModeReset: true, // used in onFocusChange since Firefox is so buggy here
destroy: function () destroy: function ()
@@ -791,9 +792,9 @@ liberator.Events = function () //{{{
catch (e) {} catch (e) {}
liberator.buffer.loaded = 1; // even if not a full page load, assume it did load correctly before starting the macro liberator.buffer.loaded = 1; // even if not a full page load, assume it did load correctly before starting the macro
replayingMacro = true; liberator.modes.isReplaying = true;
res = liberator.events.feedkeys(macros.get(lastMacro), true); // true -> noremap res = liberator.events.feedkeys(macros.get(lastMacro), true); // true -> noremap
replayingMacro = false; liberator.modes.isReplaying = false;
} }
else else
{ {
@@ -837,8 +838,9 @@ liberator.Events = function () //{{{
var doc = window.document; var doc = window.document;
var view = window.document.defaultView; var view = window.document.defaultView;
var escapeKey = false; // \ to escape some special keys var escapeKey = false; // \ to escape some special keys
var wasReplaying = liberator.modes.isReplaying;
liberator.modes.isReplaying = true; var wasFeeding = this.feedingKeys;
this.feedingKeys = true;
noremap = !!noremap; noremap = !!noremap;
@@ -898,15 +900,15 @@ liberator.Events = function () //{{{
evt.noremap = noremap; evt.noremap = noremap;
evt.isMacro = true; evt.isMacro = true;
elem.dispatchEvent(evt); elem.dispatchEvent(evt);
if (!liberator.modes.isReplaying) if (!this.feedingKeys)
break; break;
// stop feeding keys if page loading failed // stop feeding keys if page loading failed
if (replayingMacro && !waitForPageLoaded()) if (liberator.modes.isReplaying && !waitForPageLoaded())
break; break;
// else // a short break between keys often helps // else // a short break between keys often helps
// liberator.sleep(50); // liberator.sleep(50);
} }
liberator.modes.isReplaying = wasReplaying; this.feedingKeys = wasFeeding;
return i == keys.length; return i == keys.length;
}, },
@@ -1193,12 +1195,12 @@ liberator.Events = function () //{{{
} }
} }
if (liberator.modes.isReplaying) if (liberator.events.feedingKeys)
{ {
if (key == "<C-c>" && !event.isMacro) if (key == "<C-c>" && !event.isMacro)
{ {
liberator.modes.isReplaying = false; liberator.events.feedingKeys = false;
liberator.echo("Canceled playback of macro '" + lastMacro + "'"); setTimeout(function () { liberator.echo("Canceled playback of macro '" + lastMacro + "'") }, 100);
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
return true; return true;
@@ -1335,7 +1337,7 @@ liberator.Events = function () //{{{
liberator.input.pendingArgMap = null; // v.input.pendingArgMap is still 'true' also for new feeded keys liberator.input.pendingArgMap = null; // v.input.pendingArgMap is still 'true' also for new feeded keys
if (key != "<Esc>" && key != "<C-[>") if (key != "<Esc>" && key != "<C-[>")
{ {
if (replayingMacro && !waitForPageLoaded()) if (liberator.modes.isReplaying && !waitForPageLoaded())
return true; return true;
tmp.execute(null, liberator.input.count, key); tmp.execute(null, liberator.input.count, key);
@@ -1378,7 +1380,7 @@ liberator.Events = function () //{{{
liberator.input.buffer = ""; liberator.input.buffer = "";
inputBufferLength = 0; inputBufferLength = 0;
if (replayingMacro && !waitForPageLoaded()) if (liberator.modes.isReplaying && !waitForPageLoaded())
return true; return true;
var ret = map.execute(null, liberator.input.count); var ret = map.execute(null, liberator.input.count);

View File

@@ -400,9 +400,10 @@ const liberator = (function () //{{{
var i = count; var i = count;
var beforeTime = Date.now(); var beforeTime = Date.now();
liberator.interrupted = false;
if (args && args[0] == ":") if (args && args[0] == ":")
{ {
while (i--) while (i-- && !liberator.interrupted)
liberator.execute(args); liberator.execute(args);
} }
else else