aboutsummaryrefslogtreecommitdiffstats
path: root/migemo_hint.js
blob: a3278a817df8ef152bd43c08226595ca54669542 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Vimperator plugin: 'Hint Matching with XUL/Migemo'
// Last Change: 23-Mar-2011.
// License: Creative Commons
// Maintainer: Trapezoid <trapezoid.g@gmail.com> - http://unsigned.g.hatena.ne.jp/Trapezoid
// Require: XUL/Migemo add-on - https://addons.mozilla.org/firefox/addon/5239
//
// extended hint matching with migemo for Vimperator

options.get('hintmatching').set('custom');
liberator.plugins.customHintMatcher = function(inputString){
    var XMigemoCore, XMigemoTextUtils;
    try{
        XMigemoCore = Cc['@piro.sakura.ne.jp/xmigemo/factory;1']
                                .getService(Components.interfaces.pIXMigemoFactory)
                                .getService('ja');
        XMigemoTextUtils = Cc['@piro.sakura.ne.jp/xmigemo/text-utility;1']
                                .getService(Ci.pIXMigemoTextUtils);
    }
    catch(ex if ex instanceof TypeError){}
    var r = new RegExp(XMigemoTextUtils.getANDFindRegExpFromTerms(XMigemoCore.getRegExps(inputString)), 'gi');
    return function(hintString) r.test(hintString);
};