diff --git a/common/content/hints.js b/common/content/hints.js index 4e718393..a46c59ae 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -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); }, /** diff --git a/pentadactyl/TODO b/pentadactyl/TODO index 043e3f26..87039fa9 100644 --- a/pentadactyl/TODO +++ b/pentadactyl/TODO @@ -15,7 +15,6 @@ REFACTORING: - remove unnecessary usage of "self" BUGS: -- add window resize support to hints - insert abbreviations broken on - :sidebar improvements (:sidebar! Downloads while downloads is open should refocus the sidebar) - ;s saves the page rather than the image