1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 21:17:59 +01:00

fixed combination of tab + numbers in hints

This commit is contained in:
Martin Stubenschrott
2007-11-02 14:15:07 +00:00
parent 8cc89de62d
commit 386b0e78f2

View File

@@ -28,9 +28,10 @@ the terms of any one of the MPL, the GPL or the LGPL.
vimperator.Hints = function() //{{{ vimperator.Hints = function() //{{{
{ {
var submode = ""; // used for extended mode, can be "o", "t", "y", etc.
var hintString = ""; // the typed string part of the hint is in this string var hintString = ""; // the typed string part of the hint is in this string
var hintNumber = 0; // only the numerical part of the hint var hintNumber = 0; // only the numerical part of the hint
var submode = ""; // used for extended mode, can be "o", "t", "y", etc. var usedTabKey = false; // when we used <Tab> to select an element
// hints[] = [elem, text, span, imgspan, elem.style.backgroundColor, elem.style.color] // hints[] = [elem, text, span, imgspan, elem.style.backgroundColor, elem.style.color]
var hints = []; var hints = [];
@@ -40,6 +41,19 @@ vimperator.Hints = function() //{{{
var hintsGenerated = false; var hintsGenerated = false;
var docs = []; // keep track of the documents which we display the hints for var docs = []; // keep track of the documents which we display the hints for
// reset all important variables
function reset()
{
vimperator.statusline.updateInputBuffer("");
hintString = "";
hintNumber = 0;
usedTabKey = false;
hints = [];
valid_hints = [];
canUpdate = false;
hintsGenerated = false;
}
// this function 'click' an element, which also works // this function 'click' an element, which also works
// for javascript links // for javascript links
function openHint(new_tab, new_window) function openHint(new_tab, new_window)
@@ -217,18 +231,6 @@ vimperator.Hints = function() //{{{
return true; return true;
} }
// reset all important variables
function reset()
{
vimperator.statusline.updateInputBuffer("");
hintString = "";
hintNumber = 0;
hints = [];
valid_hints = [];
canUpdate = false;
hintsGenerated = false;
}
// no safety checks are done, be careful with this function // no safety checks are done, be careful with this function
// TODO: make it aware of imgspans // TODO: make it aware of imgspans
function showActiveHint(newID, oldID) function showActiveHint(newID, oldID)
@@ -539,6 +541,7 @@ outer:
case "<Tab>": case "<Tab>":
case "<S-Tab>": case "<S-Tab>":
usedTabKey = true;
if (hintNumber == 0) if (hintNumber == 0)
hintNumber = 1; hintNumber = 1;
@@ -557,16 +560,20 @@ outer:
return; return;
case "<BS>": case "<BS>":
if (hintNumber > 0) if (hintNumber > 0 && !usedTabKey)
{ {
hintNumber = Math.floor(hintNumber/10); hintNumber = Math.floor(hintNumber/10);
} }
else if (hintString != "") else if (hintString != "")
{ {
usedTabKey = false;
hintNumber = 0;
hintString = hintString.substr(0, hintString.length-1); hintString = hintString.substr(0, hintString.length-1);
} }
else else
{ {
usedTabKey = false;
hintNumber = 0;
vimperator.beep(); vimperator.beep();
return; return;
} }
@@ -596,8 +603,11 @@ outer:
if (/^[0-9]$/.test(key)) if (/^[0-9]$/.test(key))
{ {
if (hintNumber == 0) if (hintNumber == 0 || usedTabKey)
{
usedTabKey = false;
hintNumber = parseInt(key, 10); hintNumber = parseInt(key, 10);
}
else else
hintNumber = (hintNumber * 10) + parseInt(key, 10); hintNumber = (hintNumber * 10) + parseInt(key, 10);