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

Re-apply hints after window resize.

This commit is contained in:
Kris Maglione
2010-09-24 10:15:45 -04:00
parent 519bf3b9c4
commit 4b5c0d1f84
2 changed files with 30 additions and 11 deletions

View File

@@ -11,6 +11,7 @@
const Hints = Module("hints", {
init: function () {
const self = this;
this._hintMode = null;
this._submode = ""; // used for extended mode, can be "o", "t", "y", etc.
@@ -30,6 +31,15 @@ const Hints = Module("hints", {
// this._docs = { doc: document, start: start_index in hints[], end: end_index in hints[] }
this._docs = [];
this._resizeTimer = Timer(100, 500, function () {
if (self._top && (modes.extended & modes.HINTS)) {
let win = self._top;
self._removeHints(0, true);
self._generate(win);
self._showHints();
}
});
const Mode = Hints.Mode;
Mode.defaultValue("tags", function () function () options.hinttags);
function extended() options.extendedhinttags;
@@ -62,17 +72,19 @@ const Hints = Module("hints", {
/**
* Reset hints, so that they can be cleanly used again.
*/
_reset: function () {
statusline.updateInputBuffer("");
this._hintString = "";
this._hintNumber = 0;
this._usedTabKey = false;
this.prevInput = "";
_reset: function (slight) {
if (!slight) {
statusline.updateInputBuffer("");
this._hintString = "";
this._hintNumber = 0;
this._usedTabKey = false;
this.prevInput = "";
this.escNumbers = false;
this._canUpdate = false;
}
this._pageHints = [];
this._validHints = [];
this._canUpdate = false;
this._docs = [];
hints.escNumbers = false;
if (this._activeTimeout)
this._activeTimeout.cancel();
@@ -236,6 +248,10 @@ const Hints = Module("hints", {
_generate: function (win) {
if (!win)
win = window.content;
if (!this._top) {
this._top = win;
win.addEventListener("resize", this._resizeTimer.closure.tell, true);
}
let doc = win.document;
let height = win.innerHeight;
@@ -401,9 +417,13 @@ const Hints = Module("hints", {
* @param {number} timeout The number of milliseconds before the active
* hint disappears.
*/
_removeHints: function (timeout) {
_removeHints: function (timeout, slight) {
let firstElem = this._validHints[0] || null;
if (this._top)
this._top.removeEventListener("resize", this._resizeTimer.closure.tell, true);
this._top = null;
for (let [,{ doc: doc, start: start, end: end }] in Iterator(this._docs)) {
for (let elem in util.evaluateXPath("//*[@dactyl:highlight='hints']", doc))
elem.parentNode.removeChild(elem);
@@ -419,7 +439,7 @@ const Hints = Module("hints", {
}
styles.removeSheet(true, "hint-positions");
this._reset();
this._reset(slight);
},
/**