/** * ==VimperatorPlugin== * @name feedSomeKeys * @description feed some defined key events into the Web content * @description-ja 定義したkeyイベントをWebページ側へ送ってあげます * @author teramako teramako@gmail.com * @version 0.1a * ==/VimperatorPlugin== * * 英語での説明を放棄する * * keyイベント(正確にはkepressイベント)をWebコンテンツ側へ送る事を可能にするプラグイン * Gmailとかlivedoor ReaderとかGreasemonkeyでキーを割り当てている場合に活躍するでしょう。 * それ以外の場面ではむしろ邪魔になる諸刃の剣 * * :f[eed]map lhs -> lhsのキーマップをそのままWebコンテンツへ * :f[eed]map lhs [num]rhs -> lhsのキーマップをrhsへ変換してWebコンテンツへ * [num]はフレームの番号(省略時はトップウィンドウへイベントが送られる) * * :fmapc * :feedmapclear -> 全てを無に帰して元に戻す * * :f[eed]map! lhs -> "!" をつけると、仮想キーコードでイベントを送るように * * == LDR の場合 == js < z b < >".split(/ +/));'); EOF * とかやると幸せになれるかも。 * * == Gmail の場合 == js < ') != 0) { // origMapをそのままpushするとオブジェクト内の参照先を消されてしまう // 仕方なく複製を試みる var clone = new Map(origMap.modes.map(function(m) m), origMap.names.map(function(n) n), origMap.description, origMap.action, { flags:origMap.flags, rhs:origMap.rhs, noremap:origMap.noremap }); origMaps.push(clone); } } var map = new (liberator.Map)([modes.NORMAL], [origKey], origKey + ' -> ' + feedKey, function(count){ count = count > 1 ? count : 1; for (var i=0; i 0){ var frames = []; (function(frame){// @see liberator.buffer.shiftFrameFocus if (frame.document.body.localName.toLowerCase() == 'body') { frames.push(frame); } for (var i=0; i]+)/); if (matches) { if (matches[1]) { ctrl = /[cC]-/.test(matches[1]); alt = /[aA]-/.test(matches[1]); shift = /[sS]-/.test(matches[1]); meta = /[mM]-/.test(matches[1]); } if (matches[2].length == 1) { if (!ctrl && !alt && !shift && !meta) return false; if (useVkey && (keyCode = getKeyCode(matches[2], true))) { charCode = 0; } else { charCode = matches[2].charCodeAt(0); } } else if (matches[2].toLowerCase() == "space") { if (useVkey) { charCode = 0; keyCode = KeyEvent.DOM_VK_SPACE; } else { charCode = KeyEvent.DOM_VK_SPACE; } } else if (keyCode = getKeyCode(matches[2])) { charCode = 0; } else { return false; } i += matches[0].length + 1; } } else { shift = (keys[i] >= "A" && keys[i] <= "Z"); } //liberator.log({ctrl:ctrl, alt:alt, shift:shift, meta:meta, keyCode:keyCode, charCode:charCode, useVkey: useVkey}); var evt = content.document.createEvent('KeyEvents'); evt.initKeyEvent('keypress', true, true, content, ctrl, alt, shift, meta, keyCode, charCode); destElem.document.dispatchEvent(evt); } modes.passAllKeys = false; } // -------------------------- // Command // -------------------------- commands.addUserCommand(['feedmap','fmap'],'Feed Map a key sequence', function(args, bang){ if(!args){ echo(feedMaps.map(function(map) map.description.replace(//g,'>')),true); } var [ ,lhs,rhs] = args.match(/(\S+)(?:\s+(.+))?/); if (!rhs){ replaceUserMap(lhs,lhs,bang); } else { replaceUserMap(lhs,rhs,bang); } } ); commands.addUserCommand(['feedmapclear','fmapc'],'Clear Feed Maps',destroy); var converter = { get origMap() origMaps, get feedMap() feedMaps, setup: init, reset: destroy }; return converter; })(); // vim: fdm=marker sw=4 ts=4 et: