From 0e766869af68d4f18bbedd8075056a981c379bc4 Mon Sep 17 00:00:00 2001 From: anekos Date: Sun, 27 Mar 2011 02:29:08 +0900 Subject: Vimeperator 本体で実現するようになったので削除 --- char-hints-mod2.js | 311 ----------------------------------------------------- 1 file changed, 311 deletions(-) delete mode 100644 char-hints-mod2.js (limited to 'char-hints-mod2.js') diff --git a/char-hints-mod2.js b/char-hints-mod2.js deleted file mode 100644 index 4dfebe3..0000000 --- a/char-hints-mod2.js +++ /dev/null @@ -1,311 +0,0 @@ -// PLUGIN_INFO//{{{ -var PLUGIN_INFO = - - {NAME} - character hint mode. - hogelog - 0.3.2 - 2.3pre 2010/01/26 - 2.4pre - https://github.com/vimpr/vimperator-plugins/raw/master/char-hints-mod2.js - - -; -//}}} - -(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; - - let hintchars = DEFAULT_HINTCHARS; - let inputCase = function(str) str.toUpperCase(); - let inputRegex = /[A-Z]/; - let showCase = function(str) str.toUpperCase(); - let getStartCount = function() 0; - - let timer = null; - - function chars2num(chars) //{{{ - { - let num = 0; - hintchars = inputCase(hintchars); - let base = hintchars.length; - for(let i=0,l=chars.length;i0); - - return chars; - } //}}} - function getAdjustStartCount(base, count) //{{{ - { - if(count < base) { - return 0; - } else if(count >= Math.pow(base, 2)) { - return base; - } - var start = Math.floor(count / base); - var adjust = count + start; - var next_start; - while(start != (next_start = Math.floor(adjust / base))) { - adjust += start; - start = next_start; - } - return start; - } //}}} - function getCharHints(win) //{{{ - { - let hints = []; - (function (win) { - let elems = [elem for(elem in util.evaluateXPath('//*[@liberator:highlight="Hint" and @number]', win.document))]; - hints = hints.concat(elems); - Array.forEach(win.frames, arguments.callee); - })(win); - return hints; - } //}}} - function showCharHints(hints) //{{{ - { - let start = getStartCount(hintchars.length, hints.length); - for(let i=0,len=hints.length;i0) processHintInput(hintInput, hints); - }, //}}} - onEvent: function (event) //{{{ - { - if(/^\d$/.test(events.toString(event))) { - charhints.onInput(event); - } else { - charhints.original.onEvent.apply(hintContext,arguments); - clearOriginalTimeout(); - statusline.updateInputBuffer(hintInput); - } - }, //}}} - processHints: function (followFirst) //{{{ - { - // don't followFirst if processHints call from - // charhints.original.onEvent(alt) in processHintInput - let caller = arguments.callee.caller; - if(caller == charhints.original.onEvent && caller.caller == processHintInput) - return charhints.original.processHints.apply(hintContext,[false]); - - return charhints.original.processHints.apply(hintContext,arguments); - }, //}}} - }; - - if(!charhints.original) { - charhints.original = { - show: hints.show, - onInput: hints._onInput, - onEvent: hints.onEvent, - processHints: hints._processHints, - }; - - charhints.install = function () //{{{ - { - hints.show = charhints.show; - hints.onEvent = charhints.onEvent; - liberator.eval("_onInput = liberator.plugins.charhints.onInput", hintContext); - liberator.eval("_processHints = liberator.plugins.charhints.processHints", hintContext); - - liberator.execute(":hi Hint::after content: attr(hintchar)", true, true); - if(liberator.globalVariables.hintsio) { - let hintsio = liberator.globalVariables.hintsio; - Array.forEach(hintsio, setIOType); - } - if(liberator.globalVariables.hintchars) { - hintchars = liberator.globalVariables.hintchars; - } - if(liberator.globalVariables.hintlabeling) { - switch(liberator.globalVariables.hintlabeling) { - default: - case "s": - getStartCount = function() 0; - break; - case "a": - getStartCount = getAdjustStartCount; - break; - } - } - }; //}}} - charhints.uninstall = function () //{{{ - { - hints.show = charhints.original.show; - hints.onEvent = charhints.original.onEvent; - liberator.eval("_onInput = liberator.plugins.charhints.original.onInput", hintContext); - liberator.eval("_processHints = liberator.plugins.charhints.original.processHints", hintContext); - - liberator.execute(":hi Hint::after content: attr(number)", true, true); - }; //}}} - } - charhints.install(); -})(); - -// vim: set fdm=marker sw=4 ts=4 et fenc=utf-8: -- cgit v1.2.3