diff options
author | anekos | 2008-10-29 06:00:31 +0000 |
---|---|---|
committer | anekos | 2008-10-29 06:00:31 +0000 |
commit | 281f04d3983af074dc144f6f23c0d22bb1e6dc50 (patch) | |
tree | c5ec96d4b500272eed248bc80b1f39e1c4e981c8 | |
parent | 3aa686e2cfe5a8505ed3d0a65dd48603e0f7d31b (diff) | |
download | vimperator-plugins-281f04d3983af074dc144f6f23c0d22bb1e6dc50.tar.bz2 |
hint の変更に対応。
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@22313 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | asdfghjkl.js | 49 | ||||
-rw-r--r-- | ldrize_cooperation.js | 14 |
2 files changed, 34 insertions, 29 deletions
diff --git a/asdfghjkl.js b/asdfghjkl.js index 4218e09..2eafdde 100644 --- a/asdfghjkl.js +++ b/asdfghjkl.js @@ -3,7 +3,7 @@ // @description Inputting numbers by asdfghjkl; keys in hint mode. // @description-ja Hintモードで、asdfghjkl;キーを使って数字入力をする。 // @license Creative Commons 2.1 (Attribution + Share Alike) -// @version 1.0 +// @version 1.1 // @author anekos (anekos@snca.net) // ==/VimperatorPlugin== // @@ -15,38 +15,49 @@ // ヒントモードで、<Space> を押すと asdfghjkl; モード(?)に入ります。 // 出たい場合は、もう一度押します。 // +// 切り替えキーを変更したい場合は、以下のように設定できます。 +// let g:asdfghjkl_mode_change_key = "<C-c>" +// +// // Links: // http://d.hatena.ne.jp/nokturnalmortum/20081021#1224543467 // { - let asdfghjkl_default = eval(liberator.globalVariables.asdfghjkl_default || "false"); + let asdfghjkl_default = eval(liberator.globalVariables.asdfghjkl_default || 'false'); + let mode_change_key = liberator.globalVariables.asdfghjkl_mode_change_key || '<Space>'; let active = false; let original = { show: hints.show, - onEvent: hints.onEvent, + onKeyPress: events.onKeyPress, }; - hints.show = function () { - active = asdfghjkl_default; - return original.show.apply(this, arguments); - }; - - hints.onEvent = function (event) { - let key = events.toString(event); - if (key == "<Space>") { - active = !active; - return; - } - if (active && key.length == 1) { - let n = ";asdfghjkl".indexOf(key); - if (n >= 0) { - events.feedkeys(n.toString(), true); + events.onKeyPress = function (event) { + if (modes.extended & modes.HINTS) { + let key = events.toString(event); + if (key == mode_change_key) { + active = !active; + event.preventDefault(); + event.stopPropagation(); return; } + if (active && key.length == 1) { + let n = ';asdfghjkl'.indexOf(key); + if (n >= 0) { + events.feedkeys(n.toString(), true); + event.preventDefault(); + event.stopPropagation(); + return; + } + } } - return original.onEvent.call(this, event); + return original.onKeyPress.call(this, event); + }; + + hints.show = function () { + active = asdfghjkl_default; + return original.show.apply(this, arguments); }; } diff --git a/ldrize_cooperation.js b/ldrize_cooperation.js index f431e29..dd48fae 100644 --- a/ldrize_cooperation.js +++ b/ldrize_cooperation.js @@ -222,7 +222,7 @@ "Start QuickHint mode with LDRize",
function(){
setHinttags(true);
- liberator.modules.hints.show(liberator.modules.modes.QUICK_HINT);
+ liberator.modules.hints.show("o");
setHinttags(self.isEnableLDRizeCooperation() && self.isModHints);
} ,{});
@@ -230,27 +230,21 @@ "Start QuickHint mode",
function(){
setHinttags(self.isEnableLDRizeCooperation() && self.isModHints);
- liberator.modules.hints.show(liberator.modules.modes.QUICK_HINT);
+ liberator.modules.hints.show("o");
},{});
liberator.modules.mappings.addUserMap([liberator.modules.modes.NORMAL], ["F"],
"Start QuickHint mode, but open link in a new tab",
function(){
setHinttags(self.isEnableLDRizeCooperation() && self.isModHints);
- liberator.modules.hints.show(liberator.modules.modes.QUICK_HINT, "t");
+ liberator.modules.hints.show("t");
},{});
liberator.modules.mappings.addUserMap([liberator.modules.modes.NORMAL], [";"],
"Start an extended hint mode",
function(arg){
setHinttags(self.isEnableLDRizeCooperation() && self.isModHints);
-
- if(arg == "f")
- liberator.modules.hints.show(liberator.modules.modes.ALWAYS_HINT, "o");
- else if(arg == "F")
- liberator.modules.hints.show(liberator.modules.modes.ALWAYS_HINT, "t");
- else
- liberator.modules.hints.show(liberator.modules.modes.EXTENDED_HINT, arg);
+ liberator.modules.hints.show(arg);
},
{ flags: liberator.modules.Mappings.flags.ARGUMENT });
//Commands
|