aboutsummaryrefslogtreecommitdiffstats
path: root/char-hints-mod2.js
diff options
context:
space:
mode:
authorhogelog2009-01-29 05:04:57 +0000
committerhogelog2009-01-29 05:04:57 +0000
commit17b70385adbfbe240574661515b0dbc9cd492827 (patch)
tree254d49ae50e133da44aae91e6bc661208ddb3e95 /char-hints-mod2.js
parent4f25fb7bf6e95caaeadc2e1cc5a0b60a05ae665e (diff)
downloadvimperator-plugins-17b70385adbfbe240574661515b0dbc9cd492827.tar.bz2
* fix adjust labeling algorithm when more than pow(hintchars.length, 2) hints exist
* enable set old simple labeling algorithm (let g:hintlabeling="s") git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@29214 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'char-hints-mod2.js')
-rw-r--r--char-hints-mod2.js55
1 files changed, 34 insertions, 21 deletions
diff --git a/char-hints-mod2.js b/char-hints-mod2.js
index 28ca1f8..7b8c47d 100644
--- a/char-hints-mod2.js
+++ b/char-hints-mod2.js
@@ -4,10 +4,9 @@ var PLUGIN_INFO =
<name>{NAME}</name>
<description>character hint mode.</description>
<author mail="konbu.komuro@gmail.com" homepage="http://d.hatena.ne.jp/hogelog/">hogelog</author>
- <version>0.2.2</version>
+ <version>0.2.3</version>
<minVersion>2.0pre 2008/12/12</minVersion>
<maxVersion>2.0a1</maxVersion>
- <date>2009/1/28 15:34</date>
<updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/char-hints-mod2.js</updateURL>
<detail><![CDATA[
== Usage ==
@@ -29,6 +28,12 @@ let g:hintsio:
Default setting is "IO".
e.g.)
let g:histsio="i"
+let g:hintlabeling:
+ - "s" setting simple n-base decimal hint labeling (n = hintchars.length)
+ - "a" setting adjust no overlap labeling
+ Default setting is "a".
+ e.g.)
+ let g:hintlabeling="s"
== TODO ==
]]></detail>
@@ -51,6 +56,12 @@ let g:hintsio:
Default setting is "IO".
e.g.)
let g:histsio="i"
+let g:hintlabeling:
+ - "s" setting simple n-base decimal hint labeling (n = hintchars.length)
+ - "a" setting adjust no overlap labeling
+ Default setting is "a".
+ e.g.)
+ let g:hintlabeling="s"
== TODO ==
]]></detail>
@@ -66,6 +77,7 @@ let g:hintsio:
let inputCase = function(str) str.toUpperCase();
let inputRegex = /[A-Z]/;
let showCase = function(str) str.toUpperCase();
+ let getStartCount = getAdjustStartCount;
function chars2num(chars) //{{{
{
@@ -98,9 +110,14 @@ let g:hintsio:
}
return count;
} //}}}
- function getStartNumber(base, count) //{{{
+ function getAdjustStartCount(base, count) //{{{
{
- return count<base ? 0 : getMSD(base, count);
+ if(count < base) {
+ return 0;
+ } else if(count >= Math.pow(base, 2)) {
+ return base;
+ }
+ return Math.floor(count / base);
} //}}}
function getCharHints(win) //{{{
{
@@ -114,7 +131,7 @@ let g:hintsio:
} //}}}
function showCharHints(hints) //{{{
{
- let start = getStartNumber(hintchars.length, hints.length);
+ let start = getStartCount(hintchars.length, hints.length);
for(let i=0,len=hints.length;i<len;++i) {
let hint = hints[i];
let num = hint.getAttribute("number");
@@ -150,7 +167,7 @@ let g:hintsio:
} //}}}
function processHintInput(hintInput, hints) //{{{
{
- let start = getStartNumber(hintchars.length, hints.length);
+ let start = getStartCount(hintchars.length, hints.length);
let num = chars2num(hintInput)-start;
if(num < 0) return;
let numstr = String(num);
@@ -170,21 +187,6 @@ let g:hintsio:
}
}, 10);
} //}}}
- function setInputCase(type) //{{{
- {
- switch (type)
- {
- default:
- case "I":
- inputCase = function(str) str.toUpperCase();
- inputRegex = /[A-Z]/;
- break;
- case "i":
- inputCase = function(str) str.toLowerCase();
- inputRegex = /[a-z]/;
- break;
- }
- } //}}}
var hintInput = "";
var charhints = plugins.charhints = {
@@ -246,6 +248,17 @@ let g:hintsio:
if(liberator.globalVariables.hintchars) {
hintchars = liberator.globalVariables.hintchars;
}
+ if(liberator.globalVariables.hintlabeling) {
+ switch(liberator.globalVariables.hintlabeling) {
+ case "s":
+ getStartCount = function() 0;
+ break;
+ case "a":
+ default:
+ getStartCount = getAdjustStartCount;
+ break;
+ }
+ }
}; //}}}
charhints.uninstall = function () //{{{
{