diff options
author | anekos | 2010-05-22 03:23:18 +0000 |
---|---|---|
committer | anekos | 2010-05-22 03:23:18 +0000 |
commit | fa402e02902722748a66f4be0fa1f6740d763ba1 (patch) | |
tree | cc618091ef47c0570ac378861e45eae51fe0cc04 /char-hints-mod2.js | |
parent | f185128f6d5345d9369376ea7c761ab7627ee595 (diff) | |
download | vimperator-plugins-fa402e02902722748a66f4be0fa1f6740d763ba1.tar.bz2 |
Caisui さんの修正パッチ Thanks!
http://gist.github.com/409711
http://d.hatena.ne.jp/caisui/searchdiary?word=char-hints-mod2&.submit=%B8%A1%BA%F7&type=detail
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37683 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'char-hints-mod2.js')
-rw-r--r-- | char-hints-mod2.js | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/char-hints-mod2.js b/char-hints-mod2.js index 8bb373b..a5bd246 100644 --- a/char-hints-mod2.js +++ b/char-hints-mod2.js @@ -71,6 +71,31 @@ let g:hintlabeling: //}}} (function () { + (function(){ + //override _showHints + const key = "Hints.prototype._showHints"; + let conf = userContext[key],original; + if(conf) original = conf; + else original = userContext[key] = Hints.prototype._showHints; + + const target = "String(hintnum).indexOf(String(activeHint)) == 0"; + + let source = original.toSource(); + if(source.indexOf(target)>=0){ + source = source.replace(target, + "num2chars(hintnum).indexOf(num2chars(activeHint)) == 0"); + Hints.prototype._showHints = eval("(function() "+source+")()"); + }else{ + liberator.echoerr(new Error("_showHints override failed!")); + } + })() + ; + (function(){ + const source = Hints.prototype._checkUnique.toSource(); + if(source.indexOf("10")<0) return; + Hints.prototype._checkUnique = eval("(function() "+source.replace("10",<>hintchars.length</>)+")()"); + })() + ; const DEFAULT_HINTCHARS = "HJKLASDFGYUIOPQWERTNMZXCVB"; const hintContext = modules.hints; @@ -173,40 +198,15 @@ let g:hintlabeling: } //}}} function processHintInput(hintInput, hints) //{{{ { - if (timer) { - clearTimeout(timer); - timer = null; - } let start = getStartCount(hintchars.length, hints.length); let num = chars2num(hintInput)-start; if(num < 0) return; - let numstr = String(num); - for(let i=0,l=numstr.length;i<l;++i) { - let num = numstr[i]; - // events.toString(e) return e.liberatorString - // if e.liberatorString. - // so alt handled as press number event by vimperator. - let alt = new Object; - alt.liberatorString = num; - charhints.original.onEvent.apply(hintContext,[alt]); - } - clearOriginalTimeout(); + hintContext._hintNumber = Math.floor(num/10); + charhints.original.onEvent.apply(hintContext,[{ + liberatorString: String(num%10) + }]); statusline.updateInputBuffer(hintInput); - - let validHints = hints.filter(function(hint) isValidHint(hintInput, hint)); - if(validHints.length == 1) { - charhints.original.processHints.apply(hintContext,[true]); - return true; - } - - let timeout = options["hinttimeout"]; - if (timeout > 0) { - timer = setTimeout(function () { - charhints.original.processHints.apply(hintContext,[true]); - }, timeout); - } - } //}}} var hintInput = ""; |