aboutsummaryrefslogtreecommitdiffstats
path: root/linkHints.js
diff options
context:
space:
mode:
authorjez2010-12-29 11:36:20 +0800
committerjez2010-12-29 12:13:26 +0800
commitbe48ae257cb5165bc1811c58ab6e33bf040a3128 (patch)
treed99cf42b0c24493c11afdec8177bbad449c45ff3 /linkHints.js
parent5e76ae6624a264d1bd058cb756ee7528e199d77b (diff)
downloadvimium-be48ae257cb5165bc1811c58ab6e33bf040a3128.tar.bz2
Filter hints mode should automatically use numbers for hints
Also tidy up backspace handling.
Diffstat (limited to 'linkHints.js')
-rw-r--r--linkHints.js44
1 files changed, 31 insertions, 13 deletions
diff --git a/linkHints.js b/linkHints.js
index 44a574bc..9d2d4fc3 100644
--- a/linkHints.js
+++ b/linkHints.js
@@ -170,20 +170,37 @@ function onKeyDownInLinkHintsMode(event) {
// TODO(philc): Ignore keys that have modifiers.
if (isEscape(event)) {
deactivateLinkHintsMode();
- } else if (event.keyCode == keyCodes.backspace || event.keyCode == keyCodes.deleteKey) {
- if (hintKeystrokeQueue.length == 0) {
- deactivateLinkHintsMode();
+ } else {
+ if (isNarrowMode()) {
+ if (event.keyCode == keyCodes.backspace || event.keyCode == keyCodes.deleteKey) {
+ if (linkTextKeystrokeQueue.length == 0 && hintKeystrokeQueue.length == 0) {
+ deactivateLinkHintsMode();
+ } else {
+ // backspace clears hint key queue first, then acts on link text key queue
+ if (hintKeystrokeQueue.pop() === undefined)
+ linkTextKeystrokeQueue.pop();
+ updateLinkHints();
+ }
+ } else if (/[0-9]/.test(keyChar)) {
+ hintKeystrokeQueue.push(keyChar);
+ updateLinkHints();
+ } else {
+ linkTextKeystrokeQueue.push(keyChar);
+ updateLinkHints();
+ }
} else {
- linkTextKeystrokeQueue.pop();
- hintKeystrokeQueue.pop();
- updateLinkHints();
+ if (event.keyCode == keyCodes.backspace || event.keyCode == keyCodes.deleteKey) {
+ if (hintKeystrokeQueue.length == 0) {
+ deactivateLinkHintsMode();
+ } else {
+ hintKeystrokeQueue.pop();
+ updateLinkHints();
+ }
+ } else if (settings.linkHintCharacters.indexOf(keyChar) >= 0) {
+ hintKeystrokeQueue.push(keyChar);
+ updateLinkHints();
+ }
}
- } else if (settings.linkHintCharacters.indexOf(keyChar) >= 0) {
- hintKeystrokeQueue.push(keyChar);
- updateLinkHints();
- } else {
- linkTextKeystrokeQueue.push(keyChar);
- updateLinkHints();
}
event.stopPropagation();
@@ -349,7 +366,8 @@ function resetLinkHintsMode() {
* Creates a link marker for the given link.
*/
function createMarkerFor(link, linkHintNumber, linkHintDigits) {
- var hintString = numberToHintString(linkHintNumber, linkHintDigits);
+ var hintString = isNarrowMode() ?
+ linkHintNumber.toString() : numberToHintString(linkHintNumber, linkHintDigits);
var linkText = link.element.innerHTML.toLowerCase();
if (linkText == undefined)
linkText = "";