mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 16:22:27 +01:00
Re-apply hints after window resize.
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
const Hints = Module("hints", {
|
const Hints = Module("hints", {
|
||||||
init: function () {
|
init: function () {
|
||||||
|
const self = this;
|
||||||
|
|
||||||
this._hintMode = null;
|
this._hintMode = null;
|
||||||
this._submode = ""; // used for extended mode, can be "o", "t", "y", etc.
|
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 = { doc: document, start: start_index in hints[], end: end_index in hints[] }
|
||||||
this._docs = [];
|
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;
|
const Mode = Hints.Mode;
|
||||||
Mode.defaultValue("tags", function () function () options.hinttags);
|
Mode.defaultValue("tags", function () function () options.hinttags);
|
||||||
function extended() options.extendedhinttags;
|
function extended() options.extendedhinttags;
|
||||||
@@ -62,17 +72,19 @@ const Hints = Module("hints", {
|
|||||||
/**
|
/**
|
||||||
* Reset hints, so that they can be cleanly used again.
|
* Reset hints, so that they can be cleanly used again.
|
||||||
*/
|
*/
|
||||||
_reset: function () {
|
_reset: function (slight) {
|
||||||
statusline.updateInputBuffer("");
|
if (!slight) {
|
||||||
this._hintString = "";
|
statusline.updateInputBuffer("");
|
||||||
this._hintNumber = 0;
|
this._hintString = "";
|
||||||
this._usedTabKey = false;
|
this._hintNumber = 0;
|
||||||
this.prevInput = "";
|
this._usedTabKey = false;
|
||||||
|
this.prevInput = "";
|
||||||
|
this.escNumbers = false;
|
||||||
|
this._canUpdate = false;
|
||||||
|
}
|
||||||
this._pageHints = [];
|
this._pageHints = [];
|
||||||
this._validHints = [];
|
this._validHints = [];
|
||||||
this._canUpdate = false;
|
|
||||||
this._docs = [];
|
this._docs = [];
|
||||||
hints.escNumbers = false;
|
|
||||||
|
|
||||||
if (this._activeTimeout)
|
if (this._activeTimeout)
|
||||||
this._activeTimeout.cancel();
|
this._activeTimeout.cancel();
|
||||||
@@ -236,6 +248,10 @@ const Hints = Module("hints", {
|
|||||||
_generate: function (win) {
|
_generate: function (win) {
|
||||||
if (!win)
|
if (!win)
|
||||||
win = window.content;
|
win = window.content;
|
||||||
|
if (!this._top) {
|
||||||
|
this._top = win;
|
||||||
|
win.addEventListener("resize", this._resizeTimer.closure.tell, true);
|
||||||
|
}
|
||||||
|
|
||||||
let doc = win.document;
|
let doc = win.document;
|
||||||
let height = win.innerHeight;
|
let height = win.innerHeight;
|
||||||
@@ -401,9 +417,13 @@ const Hints = Module("hints", {
|
|||||||
* @param {number} timeout The number of milliseconds before the active
|
* @param {number} timeout The number of milliseconds before the active
|
||||||
* hint disappears.
|
* hint disappears.
|
||||||
*/
|
*/
|
||||||
_removeHints: function (timeout) {
|
_removeHints: function (timeout, slight) {
|
||||||
let firstElem = this._validHints[0] || null;
|
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 [,{ doc: doc, start: start, end: end }] in Iterator(this._docs)) {
|
||||||
for (let elem in util.evaluateXPath("//*[@dactyl:highlight='hints']", doc))
|
for (let elem in util.evaluateXPath("//*[@dactyl:highlight='hints']", doc))
|
||||||
elem.parentNode.removeChild(elem);
|
elem.parentNode.removeChild(elem);
|
||||||
@@ -419,7 +439,7 @@ const Hints = Module("hints", {
|
|||||||
}
|
}
|
||||||
styles.removeSheet(true, "hint-positions");
|
styles.removeSheet(true, "hint-positions");
|
||||||
|
|
||||||
this._reset();
|
this._reset(slight);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ REFACTORING:
|
|||||||
- remove unnecessary usage of "self"
|
- remove unnecessary usage of "self"
|
||||||
|
|
||||||
BUGS:
|
BUGS:
|
||||||
- add window resize support to hints
|
|
||||||
- insert abbreviations broken on <space>
|
- insert abbreviations broken on <space>
|
||||||
- :sidebar improvements (:sidebar! Downloads while downloads is open should refocus the sidebar)
|
- :sidebar improvements (:sidebar! Downloads while downloads is open should refocus the sidebar)
|
||||||
- ;s saves the page rather than the image
|
- ;s saves the page rather than the image
|
||||||
|
|||||||
Reference in New Issue
Block a user