mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 07:17:59 +01:00
Get rid of a lot of special casing in the event loops. Merge default.
--HG-- branch : mode-refactoring
This commit is contained in:
@@ -83,7 +83,7 @@ const Hints = Module("hints", {
|
||||
this._hintNumber = 0;
|
||||
this._hintString = "";
|
||||
statusline.updateInputBuffer("");
|
||||
commandline.command = "";
|
||||
commandline.widgets.command = "";
|
||||
}
|
||||
this._pageHints = [];
|
||||
this._validHints = [];
|
||||
@@ -97,9 +97,9 @@ const Hints = Module("hints", {
|
||||
if (!this._usedTabKey) {
|
||||
this._hintNumber = 0;
|
||||
}
|
||||
if (this.__continue && this._validHints.length <= 1) {
|
||||
if (this._continue && this._validHints.length <= 1) {
|
||||
this._hintString = "";
|
||||
commandline.command = this._hintString;
|
||||
commandline.widgets.command = this._hintString;
|
||||
this._showHints();
|
||||
}
|
||||
this._updateStatusline();
|
||||
@@ -347,8 +347,10 @@ const Hints = Module("hints", {
|
||||
let prefix = (elem.getAttributeNS(NS, "class") || "") + " ";
|
||||
if (active)
|
||||
elem.setAttributeNS(NS, "highlight", prefix + "HintActive");
|
||||
else
|
||||
else if (active != null)
|
||||
elem.setAttributeNS(NS, "highlight", prefix + "HintElem");
|
||||
else
|
||||
elem.removeAttributeNS(NS, "highlight");
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -429,7 +431,6 @@ const Hints = Module("hints", {
|
||||
*/
|
||||
_removeHints: function (timeout, slight) {
|
||||
for (let [,{ doc: doc, start: start, end: end }] in Iterator(this._docs)) {
|
||||
util.dump(String(doc), start, end);
|
||||
for (let elem in util.evaluateXPath("//*[@dactyl:highlight='hints']", doc))
|
||||
elem.parentNode.removeChild(elem);
|
||||
for (let i in util.range(start, end + 1))
|
||||
@@ -489,12 +490,10 @@ const Hints = Module("hints", {
|
||||
|
||||
let n = 5;
|
||||
(function next() {
|
||||
this._setClass(elem, n % 2);
|
||||
util.dump(n, String(this._top));
|
||||
let hinted = n || this._validHints.some(function (e) e === elem);
|
||||
this._setClass(elem, n ? n % 2 : !hinted ? null : this._validHints[Math.max(0, this._hintNumber-1)] === elem);
|
||||
if (n--)
|
||||
this.timeout(next, 50);
|
||||
else if (!this._validHints.some(function (h) h.elem == elem))
|
||||
elem.removeAttributeNS(NS, "highlight");
|
||||
}).call(this);
|
||||
|
||||
this.timeout(function () {
|
||||
@@ -765,6 +764,20 @@ const Hints = Module("hints", {
|
||||
*/
|
||||
isHintKey: function (key) this.hintKeys.indexOf(key) >= 0,
|
||||
|
||||
open: function (mode, opts) {
|
||||
this._extendedhintCount = opts.count;
|
||||
commandline.input(";", null, {
|
||||
promptHighlight: "Normal",
|
||||
completer: function (context) {
|
||||
context.compare = function () 0;
|
||||
context.completions = [[k, v.prompt] for ([k, v] in Iterator(hints._hintModes))];
|
||||
},
|
||||
onAccept: function (arg) { arg && util.timeout(function () hints.show(arg, opts), 0); },
|
||||
get onCancel() this.onAccept,
|
||||
onChange: function () { modes.pop(); }
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the display of hints.
|
||||
*
|
||||
@@ -782,7 +795,8 @@ const Hints = Module("hints", {
|
||||
if (!stack.push)
|
||||
hints.hide();
|
||||
},
|
||||
onChange: this.closure._onInput
|
||||
onChange: this.closure._onInput,
|
||||
onEvent: this.closure.onEvent
|
||||
});
|
||||
modes.extended = modes.HINTS;
|
||||
|
||||
@@ -864,9 +878,12 @@ const Hints = Module("hints", {
|
||||
}
|
||||
this._showActiveHint(this._hintNumber, oldId);
|
||||
this._updateStatusline();
|
||||
return;
|
||||
return false;
|
||||
|
||||
case "<BS>":
|
||||
if (this.prevInput !== "number")
|
||||
return true;
|
||||
|
||||
if (this._hintNumber > 0 && !this._usedTabKey) {
|
||||
this._hintNumber = Math.floor(this._hintNumber / this.hintKeys.length);
|
||||
if (this._hintNumber == 0)
|
||||
@@ -886,10 +903,10 @@ const Hints = Module("hints", {
|
||||
this._hintNumber = 0;
|
||||
|
||||
this._updateStatusline();
|
||||
return;
|
||||
return false;
|
||||
|
||||
default:
|
||||
if (this.isHintKey(key)) {
|
||||
if (!this.escNumbers && this.isHintKey(key)) {
|
||||
this.prevInput = "number";
|
||||
|
||||
let oldHintNumber = this._hintNumber;
|
||||
@@ -914,8 +931,9 @@ const Hints = Module("hints", {
|
||||
dactyl.assert(this._hintNumber != 0);
|
||||
|
||||
this._checkUnique();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
this._updateStatusline();
|
||||
@@ -927,6 +945,7 @@ const Hints = Module("hints", {
|
||||
this._showHints();
|
||||
this._processHints(followFirst);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//}}}
|
||||
}, {
|
||||
@@ -1052,30 +1071,15 @@ const Hints = Module("hints", {
|
||||
"Start QuickHint mode, but open link in a new tab",
|
||||
function () { hints.show(options.get("activate").has("links") ? "t" : "b"); });
|
||||
|
||||
function inputOpts(opts) ({
|
||||
promptHighlight: "Normal",
|
||||
completer: function (context) {
|
||||
context.compare = function () 0;
|
||||
context.completions = [[k, v.prompt] for ([k, v] in Iterator(hints._hintModes))];
|
||||
},
|
||||
onAccept: function (arg) { arg && util.timeout(function () hints.show(arg, opts), 0); },
|
||||
onChange: function () { modes.pop(); },
|
||||
onCancel: function (arg) { arg && util.timeout(function () hints.show(arg, opts), 0); }
|
||||
});
|
||||
|
||||
mappings.add(myModes, [";"],
|
||||
"Start an extended hint mode",
|
||||
function (count) {
|
||||
this._extendedhintCount = count;
|
||||
commandline.input(";", null, inputOpts());
|
||||
}, { count: true });
|
||||
function (count) { hints.open(";", { count: count }); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(myModes, ["g;"],
|
||||
"Start an extended hint mode and stay there until <Esc> is pressed",
|
||||
function (count) {
|
||||
this._extendedhintCount = count;
|
||||
commandline.input("g;", null, inputOpts({ continue: true }));
|
||||
}, { count: true });
|
||||
function (count) { hints.open("g;", { continue: true, count: count }); },
|
||||
{ count: true });
|
||||
},
|
||||
options: function () {
|
||||
const DEFAULT_HINTTAGS =
|
||||
|
||||
Reference in New Issue
Block a user