mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 08:37:59 +01:00
Add 'ambiguous' attribute to hints which can't be unambiguously typed.
This commit is contained in:
@@ -30,7 +30,7 @@ var Buffer = Module("buffer", {
|
||||
if (verbose)
|
||||
for (let link in engines)
|
||||
yield [link.title || /*L*/ "Engine " + n++,
|
||||
<a xmlns={XHTML} href={link.href} onclick="window.external.AddSearchProvider(this.href); return false;">{link.href}</a>];
|
||||
<a xmlns={XHTML} href={link.href} onclick="if (event.button == 0) { window.external.AddSearchProvider(this.href); return false; }">{link.href}</a>];
|
||||
}
|
||||
|
||||
if (!verbose && nEngines)
|
||||
|
||||
@@ -70,6 +70,15 @@ var HintSession = Class("HintSession", CommandMode, {
|
||||
hints.setClass(this.imgSpan, this.valid ? val : null);
|
||||
},
|
||||
|
||||
get ambiguous() this.span.hasAttribute("ambiguous"),
|
||||
set ambiguous(val) {
|
||||
let meth = val ? "setAttribute" : "removeAttribute";
|
||||
this.elem[meth]("ambiguous", "true");
|
||||
this.span[meth]("ambiguous", "true");
|
||||
if (this.imgSpan)
|
||||
this.imgSpan[meth]("ambiguous", "true");
|
||||
},
|
||||
|
||||
get valid() this._valid,
|
||||
set valid(val) {
|
||||
this._valid = val,
|
||||
@@ -155,6 +164,21 @@ var HintSession = Class("HintSession", CommandMode, {
|
||||
return res.reverse().join("");
|
||||
},
|
||||
|
||||
/**
|
||||
* The reverse of {@link #getHintString}. Given a hint string,
|
||||
* returns its index.
|
||||
*
|
||||
* @param {string} str The hint's string.
|
||||
* @returns {number} The hint's index.
|
||||
*/
|
||||
getHintNumber: function getHintNumber(str) {
|
||||
let base = this.hintKeys.length;
|
||||
let res = 0;
|
||||
for (let char in values(str))
|
||||
res = res * base + this.hintKeys.indexOf(char);
|
||||
return res;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if the given key string represents a
|
||||
* pseudo-hint-number.
|
||||
@@ -511,9 +535,11 @@ var HintSession = Class("HintSession", CommandMode, {
|
||||
|
||||
for (let elem in util.evaluateXPath("//*[@dactyl:highlight='hints']", doc))
|
||||
elem.parentNode.removeChild(elem);
|
||||
for (let i in util.range(start, end + 1))
|
||||
for (let i in util.range(start, end + 1)) {
|
||||
this.pageHints[i].ambiguous = false;
|
||||
this.pageHints[i].valid = false;
|
||||
}
|
||||
}
|
||||
styles.system.remove("hint-positions");
|
||||
|
||||
this.reset();
|
||||
@@ -586,12 +612,17 @@ var HintSession = Class("HintSession", CommandMode, {
|
||||
hint.span.setAttribute("number", str);
|
||||
if (hint.imgSpan)
|
||||
hint.imgSpan.setAttribute("number", str);
|
||||
|
||||
hint.active = activeHint == hintnum;
|
||||
|
||||
this.validHints.push(hint);
|
||||
hintnum++;
|
||||
}
|
||||
}
|
||||
|
||||
for (let [i, hint] in Iterator(this.validHints))
|
||||
hint.ambiguous = i * this.hintKeys.length < this.validHints.length;
|
||||
|
||||
if (options["usermode"]) {
|
||||
let css = [];
|
||||
for (let hint in values(this.pageHints)) {
|
||||
|
||||
Reference in New Issue
Block a user