mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-17 20:35:46 +01:00
Add Classeditor.jssetTimeout. Fix some broken timeouts.
This commit is contained in:
@@ -8,19 +8,6 @@ const Ci = Components.interfaces;
|
|||||||
const Cr = Components.results;
|
const Cr = Components.results;
|
||||||
const Cu = Components.utils;
|
const Cu = Components.utils;
|
||||||
|
|
||||||
// TODO: Move to liberator.
|
|
||||||
function setTimeout(callback, timeout, self) {
|
|
||||||
function target() {
|
|
||||||
try {
|
|
||||||
callback.call(self);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
liberator.reportError(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return window.setTimeout(target, timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
function array(obj) {
|
function array(obj) {
|
||||||
if (isgenerator(obj))
|
if (isgenerator(obj))
|
||||||
obj = [k for (k in obj)];
|
obj = [k for (k in obj)];
|
||||||
@@ -288,7 +275,14 @@ function Class() {
|
|||||||
Class.toString = function () "[class " + this.constructor.name + "]",
|
Class.toString = function () "[class " + this.constructor.name + "]",
|
||||||
Class.prototype = {
|
Class.prototype = {
|
||||||
init: function() {},
|
init: function() {},
|
||||||
|
|
||||||
toString: function () "[instance " + this.constructor.name + "]",
|
toString: function () "[instance " + this.constructor.name + "]",
|
||||||
|
|
||||||
|
setTimeout: function (callback, timeout) {
|
||||||
|
const self = this;
|
||||||
|
function target() callback.call(self);
|
||||||
|
return window.setTimeout(target, timeout);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const Struct = Class("Struct", {
|
const Struct = Class("Struct", {
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ const CommandLine = Module("commandline", {
|
|||||||
this._multilineInputWidget.value = "";
|
this._multilineInputWidget.value = "";
|
||||||
this._autosizeMultilineInputWidget();
|
this._autosizeMultilineInputWidget();
|
||||||
|
|
||||||
setTimeout(function () { this._multilineInputWidget.focus(); }, 10);
|
this.setTimeout(function () { this._multilineInputWidget.focus(); }, 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -608,18 +608,17 @@ const CommandLine = Module("commandline", {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
onEvent: function onEvent(event) {
|
onEvent: function onEvent(event) {
|
||||||
const self = this;
|
|
||||||
let command = this.command;
|
let command = this.command;
|
||||||
|
|
||||||
if (event.type == "blur") {
|
if (event.type == "blur") {
|
||||||
// prevent losing focus, there should be a better way, but it just didn't work otherwise
|
// prevent losing focus, there should be a better way, but it just didn't work otherwise
|
||||||
setTimeout(function () {
|
this.setTimeout(function () {
|
||||||
if (self._commandShown() && event.originalTarget == self._commandWidget.inputField)
|
if (this._commandShown() && event.originalTarget == this._commandWidget.inputField)
|
||||||
self._commandWidget.inputField.focus();
|
this._commandWidget.inputField.focus();
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
else if (event.type == "focus") {
|
else if (event.type == "focus") {
|
||||||
if (!self._commandShown() && event.target == self._commandWidget.inputField) {
|
if (!this._commandShown() && event.target == this._commandWidget.inputField) {
|
||||||
event.target.blur();
|
event.target.blur();
|
||||||
liberator.beep();
|
liberator.beep();
|
||||||
}
|
}
|
||||||
@@ -711,7 +710,7 @@ const CommandLine = Module("commandline", {
|
|||||||
}
|
}
|
||||||
else if (event.type == "blur") {
|
else if (event.type == "blur") {
|
||||||
if (modes.extended & modes.INPUT_MULTILINE)
|
if (modes.extended & modes.INPUT_MULTILINE)
|
||||||
setTimeout(function () { this._multilineInputWidget.inputField.focus(); }, 0);
|
this.setTimeout(function () { this._multilineInputWidget.inputField.focus(); }, 0);
|
||||||
}
|
}
|
||||||
else if (event.type == "input")
|
else if (event.type == "input")
|
||||||
this._autosizeMultilineInputWidget();
|
this._autosizeMultilineInputWidget();
|
||||||
@@ -1038,6 +1037,7 @@ const CommandLine = Module("commandline", {
|
|||||||
if (liberator.has("sanitizer") && (timespan || options["sanitizetimespan"]))
|
if (liberator.has("sanitizer") && (timespan || options["sanitizetimespan"]))
|
||||||
range = sanitizer.getClearRange(timespan || options["sanitizetimespan"]);
|
range = sanitizer.getClearRange(timespan || options["sanitizetimespan"]);
|
||||||
|
|
||||||
|
const self = this;
|
||||||
this.store.mutate("filter", function (item) {
|
this.store.mutate("filter", function (item) {
|
||||||
let timestamp = (item.timestamp || Date.now()/1000) * 1000;
|
let timestamp = (item.timestamp || Date.now()/1000) * 1000;
|
||||||
return !line.privateData || timestamp < self.range[0] || timestamp > self.range[1];
|
return !line.privateData || timestamp < self.range[0] || timestamp > self.range[1];
|
||||||
@@ -1653,16 +1653,18 @@ const ItemList = Class("ItemList", {
|
|||||||
_dom: function (xml, map) util.xmlToDom(xml, this._doc, map),
|
_dom: function (xml, map) util.xmlToDom(xml, this._doc, map),
|
||||||
|
|
||||||
_autoSize: function () {
|
_autoSize: function () {
|
||||||
const self = this;
|
|
||||||
if (this._container.collapsed)
|
if (this._container.collapsed)
|
||||||
this._div.style.minWidth = document.getElementById("liberator-commandline").scrollWidth + "px";
|
this._div.style.minWidth = document.getElementById("liberator-commandline").scrollWidth + "px";
|
||||||
|
|
||||||
this._minHeight = Math.max(this._minHeight, this._divNodes.completions.getBoundingClientRect().bottom);
|
this._minHeight = Math.max(this._minHeight, this._divNodes.completions.getBoundingClientRect().bottom);
|
||||||
this._container.height = this._minHeight;
|
this._container.height = this._minHeight;
|
||||||
|
|
||||||
if (this._container.collapsed)
|
if (this._container.collapsed)
|
||||||
this._div.style.minWidth = "";
|
this._div.style.minWidth = "";
|
||||||
|
|
||||||
// FIXME: Belongs elsewhere.
|
// FIXME: Belongs elsewhere.
|
||||||
commandline.updateOutputHeight(false);
|
commandline.updateOutputHeight(false);
|
||||||
setTimeout(function () { self._container.height -= commandline.getSpaceNeeded() }, 0);
|
this.setTimeout(function () { this._container.height -= commandline.getSpaceNeeded() }, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
_getCompletion: function (index) this._completionElements.snapshotItem(index - this._startIndex),
|
_getCompletion: function (index) this._completionElements.snapshotItem(index - this._startIndex),
|
||||||
|
|||||||
@@ -880,7 +880,7 @@ const Events = Module("events", {
|
|||||||
events.feedingKeys = false;
|
events.feedingKeys = false;
|
||||||
if (modes.isReplaying) {
|
if (modes.isReplaying) {
|
||||||
modes.isReplaying = false;
|
modes.isReplaying = false;
|
||||||
setTimeout(function () { liberator.echomsg("Canceled playback of macro '" + this._lastMacro + "'"); }, 100);
|
this.setTimeout(function () { liberator.echomsg("Canceled playback of macro '" + this._lastMacro + "'"); }, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ const Finder = Module("finder", {
|
|||||||
this._found = fastFind.find(this._searchString, this._linksOnly) != Ci.nsITypeAheadFind.FIND_NOTFOUND;
|
this._found = fastFind.find(this._searchString, this._linksOnly) != Ci.nsITypeAheadFind.FIND_NOTFOUND;
|
||||||
|
|
||||||
if (!this._found)
|
if (!this._found)
|
||||||
setTimeout(function () liberator.echoerr("E486: Pattern not found: " + finder._searchPattern, commandline.FORCE_SINGLELINE), 0);
|
this.setTimeout(function () liberator.echoerr("E486: Pattern not found: " + this._searchPattern, commandline.FORCE_SINGLELINE), 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,7 +325,7 @@ const Finder = Module("finder", {
|
|||||||
// TODO: move to find() when reverse incremental searching is kludged in
|
// TODO: move to find() when reverse incremental searching is kludged in
|
||||||
// need to find again for reverse searching
|
// need to find again for reverse searching
|
||||||
if (this._backwards)
|
if (this._backwards)
|
||||||
setTimeout(function () { finder.findAgain(false); }, 0);
|
this.setTimeout(function () { this.findAgain(false); }, 0);
|
||||||
|
|
||||||
if (options["hlsearch"])
|
if (options["hlsearch"])
|
||||||
this.highlight(this._searchString);
|
this.highlight(this._searchString);
|
||||||
@@ -493,9 +493,9 @@ const RangeFinder = Module("rangefinder", {
|
|||||||
else if (this.rangeFind.wrapped) {
|
else if (this.rangeFind.wrapped) {
|
||||||
// hack needed, because wrapping causes a "scroll" event which clears
|
// hack needed, because wrapping causes a "scroll" event which clears
|
||||||
// our command line
|
// our command line
|
||||||
setTimeout(function () {
|
this.setTimeout(function () {
|
||||||
let msg = rangfinder.rangeFind.backward ? "search hit TOP, continuing at BOTTOM"
|
let msg = this.rangeFind.backward ? "search hit TOP, continuing at BOTTOM"
|
||||||
: "search hit BOTTOM, continuing at TOP";
|
: "search hit BOTTOM, continuing at TOP";
|
||||||
commandline.echo(msg, commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES);
|
commandline.echo(msg, commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -488,10 +488,10 @@ const Hints = Module("hints", {
|
|||||||
if (timeout == 0)
|
if (timeout == 0)
|
||||||
// force a possible mode change, based on whether an input field has focus
|
// force a possible mode change, based on whether an input field has focus
|
||||||
events.onFocusChange();
|
events.onFocusChange();
|
||||||
setTimeout(function () {
|
this.setTimeout(function () {
|
||||||
if (modes.extended & modes.HINTS)
|
if (modes.extended & modes.HINTS)
|
||||||
modes.reset();
|
modes.reset();
|
||||||
hints._hintMode.action(elem, elem.href || "", hints._extendedhintCount);
|
this._hintMode.action(elem, elem.href || "", hints._extendedhintCount);
|
||||||
}, timeout);
|
}, timeout);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@@ -507,7 +507,7 @@ const Hints = Module("hints", {
|
|||||||
if (this._hintNumber > 0 && this._hintNumber * 10 <= this._validHints.length) {
|
if (this._hintNumber > 0 && this._hintNumber * 10 <= this._validHints.length) {
|
||||||
let timeout = options["hinttimeout"];
|
let timeout = options["hinttimeout"];
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
this._activeTimeout = setTimeout(function () { hints._processHints(true); }, timeout);
|
this._activeTimeout = this.setTimeout(function () { this._processHints(true); }, timeout);
|
||||||
}
|
}
|
||||||
else // we have a unique hint
|
else // we have a unique hint
|
||||||
this._processHints(true);
|
this._processHints(true);
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ const StatusLine = Module("statusline", {
|
|||||||
updateTabCount: function updateTabCount(delayed) {
|
updateTabCount: function updateTabCount(delayed) {
|
||||||
if (liberator.has("tabs")) {
|
if (liberator.has("tabs")) {
|
||||||
if (delayed)
|
if (delayed)
|
||||||
return void setTimeout(function () statusline.updateTabCount(false), 0);
|
return void this.setTimeout(function () this.updateTabCount(false), 0);
|
||||||
|
|
||||||
// update the ordinal which is used for numbered tabs
|
// update the ordinal which is used for numbered tabs
|
||||||
if (options.get("guioptions").has("n", "N"))
|
if (options.get("guioptions").has("n", "N"))
|
||||||
|
|||||||
Reference in New Issue
Block a user