1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 08:57:59 +01:00

fixed some hints problem

This commit is contained in:
Martin Stubenschrott
2008-05-17 14:54:10 +00:00
parent c9cbedf439
commit 8a1162349a
2 changed files with 71 additions and 9 deletions

View File

@@ -403,22 +403,76 @@ liberator.Hints = function () //{{{
function charsAtBeginningOfWords(chars, words, allowWordOverleaping) function charsAtBeginningOfWords(chars, words, allowWordOverleaping)
{ {
var charIdx = 0; var charIdx = 0;
var numMatchedWords = 0;
for (var wIdx = 0; wIdx < words.length; wIdx++) for (var wIdx = 0; wIdx < words.length; wIdx++)
{ {
var word = words[wIdx]; var word = words[wIdx];
if (word.length == 0) if (word.length == 0)
continue; continue;
var prevCharIdx = charIdx; var wcIdx = 0;
for (var j = 0; j < word.length && charIdx < chars.length; j++, charIdx++) // Check if the current word matches same characters as the previous word.
// Each already matched word has matched at least one character.
if (charIdx > numMatchedWords)
{ {
if (word[j] != chars[charIdx]) var matchingStarted = false;
break; for (var i = numMatchedWords; i < charIdx; i++)
{
if (chars[i] == word[wcIdx])
{
matchingStarted = true;
wcIdx++;
}
else if (matchingStarted)
{
wcIdx = 0;
break;
}
}
} }
if (prevCharIdx == charIdx && ! allowWordOverleaping) // the current word matches same characters as the previous word
return false; if (wcIdx > 0) {
var prevCharIdx = charIdx;
// now check if it matches additional characters
for (; wcIdx < word.length && charIdx < chars.length; wcIdx++, charIdx++)
{
if (word[wcIdx] != chars[charIdx])
break;
}
// the word doesn't match additional characters, now check if the
// already matched characters are equal to the next characters for matching,
// if yes, then consume them
if (prevCharIdx == charIdx)
{
for (var i = 0; i < wcIdx && charIdx < chars.length; i++, charIdx++)
{
if (word[i] != chars[charIdx])
break;
}
}
numMatchedWords++;
}
// the current word doesn't match same characters as the previous word, just
// try to match the next characters
else {
var prevCharIdx = charIdx;
for (var i = 0; i < word.length && charIdx < chars.length; i++, charIdx++)
{
if (word[i] != chars[charIdx])
break;
}
if (prevCharIdx == charIdx) {
if (! allowWordOverleaping)
return false;
}
else
numMatchedWords++;
}
if (charIdx == chars.length) if (charIdx == chars.length)
return true; return true;

View File

@@ -21,7 +21,7 @@ section:Setting{nbsp}options[set-option,E764]
||:se[t] {option}?|| Show value of {option}. ||:se[t] {option}?|| Show value of {option}.
||:se[t] {option}|| Toggle option: set, switch it on. ||:se[t] {option}|| Toggle option: set, switch it on.
____ ____
Number option: show value. + Number option: show value. +
String option: show value. String option: show value.
@@ -95,6 +95,7 @@ all Firefox preferences work, because Vimperator overrides some key
bindings and changes Firefox's GUI. bindings and changes Firefox's GUI.
________________________________________________________________________________ ________________________________________________________________________________
|:prefs!| |:preferences!| |:prefs!| |:preferences!|
||:pref[erences]!|| ||:pref[erences]!||
________________________________________________________________________________ ________________________________________________________________________________
@@ -103,6 +104,14 @@ preferences.
________________________________________________________________________________ ________________________________________________________________________________
|:set-!|
||:se[t]! {preference}={value}|| +
________________________________________________________________________________
Change any Firefox {preference} (those in the about:config window). You can also
reset/delete those preferences with [c]:set! {preference}&[c].
________________________________________________________________________________
section:List{nbsp}of{nbsp}options[list-options] section:List{nbsp}of{nbsp}options[list-options]
|\'act'| |\'activate'| |\'act'| |\'activate'|
@@ -228,7 +237,6 @@ ____
A regex which defines the word separators which are used for the 'hintmatching' types A regex which defines the word separators which are used for the 'hintmatching' types
'wordstartswith' and 'firstletters' to split the words in the text of a link. + 'wordstartswith' and 'firstletters' to split the words in the text of a link. +
NOTE: Because 'wordseparators' is a string, each backspace has to be quoted by another backspace.
____ ____