mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 22:22:27 +01:00
Allow C-c to interrupt search highlighting
This commit is contained in:
@@ -537,10 +537,7 @@ liberator.Events = function () //{{{
|
||||
function waitForPageLoaded()
|
||||
{
|
||||
liberator.dump("start waiting in loaded state: " + liberator.buffer.loaded + "\n");
|
||||
var mainThread = Components.classes["@mozilla.org/thread-manager;1"]
|
||||
.getService(Components.interfaces.nsIThreadManager).mainThread;
|
||||
while (mainThread.hasPendingEvents()) // clear queue
|
||||
mainThread.processNextEvent(true);
|
||||
liberator.threadyield(true); // clear queue
|
||||
|
||||
if (liberator.buffer.loaded == 1)
|
||||
return true;
|
||||
@@ -549,7 +546,7 @@ liberator.Events = function () //{{{
|
||||
var then = new Date().getTime();
|
||||
for (let now = then; now - then < ms; now = new Date().getTime())
|
||||
{
|
||||
mainThread.processNextEvent(true);
|
||||
liberator.threadyield();
|
||||
if ((now - then) % 1000 < 10)
|
||||
liberator.dump("waited: " + (now - then) + " ms\n");
|
||||
|
||||
@@ -1196,7 +1193,6 @@ liberator.Events = function () //{{{
|
||||
|
||||
if (liberator.modes.isReplaying)
|
||||
{
|
||||
// XXX: Prevents using <C-c> in a macro.
|
||||
if (key == "<C-c>" && !event.isMacro)
|
||||
{
|
||||
liberator.modes.isReplaying = false;
|
||||
@@ -1207,6 +1203,9 @@ liberator.Events = function () //{{{
|
||||
}
|
||||
}
|
||||
|
||||
if (key == "<C-c>")
|
||||
liberator.interrupted = true;
|
||||
|
||||
var stop = true; // set to false if we should NOT consume this event but let Firefox handle it
|
||||
|
||||
var win = document.commandDispatcher.focusedWindow;
|
||||
|
||||
@@ -195,6 +195,8 @@ liberator.Search = function () //{{{
|
||||
this.endPt.setStart(body, count);
|
||||
this.endPt.setEnd(body, count);
|
||||
|
||||
liberator.interrupted = false;
|
||||
let n = 0;
|
||||
for (let retRange in this.search(aWord, caseSensitive))
|
||||
{
|
||||
// Highlight
|
||||
@@ -203,6 +205,10 @@ liberator.Search = function () //{{{
|
||||
this.startPt = node.ownerDocument.createRange();
|
||||
this.startPt.setStart(node, node.childNodes.length);
|
||||
this.startPt.setEnd(node, node.childNodes.length);
|
||||
if (n++ % 20 == 0)
|
||||
liberator.threadyield();
|
||||
if (liberator.interrupted)
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -647,10 +647,7 @@ liberator.Hints = function () //{{{
|
||||
generate(win);
|
||||
|
||||
// get all keys from the input queue
|
||||
var mt = Components.classes["@mozilla.org/thread-manager;1"]
|
||||
.getService().mainThread;
|
||||
while (mt.hasPendingEvents())
|
||||
mt.processNextEvent(true);
|
||||
liberator.threadyield(true);
|
||||
|
||||
canUpdate = true;
|
||||
showHints();
|
||||
|
||||
@@ -1237,6 +1237,14 @@ const liberator = (function () //{{{
|
||||
return true;
|
||||
},
|
||||
|
||||
threadyield: function (flush)
|
||||
{
|
||||
let mainThread = threadManager.mainThread;
|
||||
do
|
||||
mainThread.processNextEvent(true);
|
||||
while (flush && mainThread.hasPendingEvents());
|
||||
},
|
||||
|
||||
get windows()
|
||||
{
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
|
||||
Reference in New Issue
Block a user