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

Dont use autocomplete during macro/:cmd playback; dont show the completion list on setCompletions if wim-=auto

This commit is contained in:
Kris Maglione
2008-10-08 18:19:11 +00:00
parent e22bd873ff
commit 605cf4bbc3
3 changed files with 26 additions and 20 deletions

View File

@@ -286,6 +286,7 @@ 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
@@ -780,7 +781,6 @@ liberator.Events = function () //{{{
if (macros.get(lastMacro)) if (macros.get(lastMacro))
{ {
liberator.modes.isReplaying = true;
// make sure the page is stopped before starting to play the macro // make sure the page is stopped before starting to play the macro
try try
{ {
@@ -789,8 +789,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;
res = liberator.events.feedkeys(macros.get(lastMacro), true); // true -> noremap res = liberator.events.feedkeys(macros.get(lastMacro), true); // true -> noremap
liberator.modes.isReplaying = false; replayingMacro = false;
} }
else else
{ {
@@ -835,6 +836,7 @@ liberator.Events = function () //{{{
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; var wasReplaying = liberator.modes.isReplaying;
liberator.modes.isReplaying = true;
noremap = !!noremap; noremap = !!noremap;
@@ -894,17 +896,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)
break;
// stop feeding keys if page loading failed // stop feeding keys if page loading failed
if (wasReplaying) if (replayingMacro && !waitForPageLoaded())
{ break;
if (!liberator.modes.isReplaying)
break;
if (!waitForPageLoaded())
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;
return i == keys.length; return i == keys.length;
}, },
@@ -1333,7 +1333,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 (liberator.modes.isReplaying && !waitForPageLoaded()) if (replayingMacro && !waitForPageLoaded())
return true; return true;
tmp.execute(null, liberator.input.count, key); tmp.execute(null, liberator.input.count, key);
@@ -1376,7 +1376,7 @@ liberator.Events = function () //{{{
liberator.input.buffer = ""; liberator.input.buffer = "";
inputBufferLength = 0; inputBufferLength = 0;
if (liberator.modes.isReplaying && !waitForPageLoaded()) if (replayingMacro && !waitForPageLoaded())
return true; return true;
var ret = map.execute(null, liberator.input.count); var ret = map.execute(null, liberator.input.count);

View File

@@ -108,8 +108,10 @@ liberator.CommandLine = function () //{{{
var statusTimer = new liberator.util.Timer(5, 100, function () var statusTimer = new liberator.util.Timer(5, 100, function ()
liberator.statusline.updateProgress("match " + (completionIndex + 1) + " of " + completions.length)); liberator.statusline.updateProgress("match " + (completionIndex + 1) + " of " + completions.length));
var autocompleteTimer = new liberator.util.Timer(201, 300, function (command) { var autocompleteTimer = new liberator.util.Timer(201, 300, function (command) {
let res = liberator.completion.ex(command); if (liberator.modes.isReplaying)
liberator.commandline.setCompletions(res[1], res[0]); return;
let [start, compl] = liberator.completion.ex(command);
liberator.commandline.setCompletions(compl, start);
}); });
// the containing box for the promptWidget and commandWidget // the containing box for the promptWidget and commandWidget
@@ -574,10 +576,7 @@ liberator.CommandLine = function () //{{{
if (/\s/.test(cmd) && if (/\s/.test(cmd) &&
liberator.options.get("wildoptions").has("auto") >= 0 && liberator.options.get("wildoptions").has("auto") >= 0 &&
extendedMode == liberator.modes.EX) extendedMode == liberator.modes.EX)
{ autocompleteTimer.tell(cmd);
var [start, compl] = liberator.completion.ex(cmd);
this.setCompletions(compl, start);
}
}, },
// normally used when pressing esc, does not execute a command // normally used when pressing esc, does not execute a command
@@ -1175,7 +1174,8 @@ liberator.CommandLine = function () //{{{
completions = compl; completions = compl;
completionList.selectItem(completionIndex); completionList.selectItem(completionIndex);
completionList.show(); if (liberator.options.get("wildoptions").has("auto"))
completionList.show();
var command = this.getCommand(); var command = this.getCommand();
completionPrefix = command.substring(0, commandWidget.selectionStart); completionPrefix = command.substring(0, commandWidget.selectionStart);

View File

@@ -40,8 +40,14 @@ liberator.util = { //{{{
this.latest = 0; this.latest = 0;
/* minInterval is the time between the completion of the command and the next firing. */ /* minInterval is the time between the completion of the command and the next firing. */
this.doneAt = Date.now() + minInterval; this.doneAt = Date.now() + minInterval;
callback(this.arg); try
this.doneAt = Date.now() + minInterval; {
callback(this.arg);
}
finally
{
this.doneAt = Date.now() + minInterval;
}
} }
this.tell = function (arg) this.tell = function (arg)
{ {