From 05494c71f1a1e8b06cb4b7e7815c61524725ff4c Mon Sep 17 00:00:00 2001 From: anekos Date: Sat, 8 Nov 2008 16:35:49 +0000 Subject: added git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/branches/1.2@23016 d0d07461-0603-4401-acd4-de1884942a52 --- asdfghjkl.js | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 asdfghjkl.js (limited to 'asdfghjkl.js') diff --git a/asdfghjkl.js b/asdfghjkl.js new file mode 100644 index 0000000..87f960d --- /dev/null +++ b/asdfghjkl.js @@ -0,0 +1,58 @@ +// ==VimperatorPlugin== +// @name asdfghjkl; +// @description Inputting numbers by asdfghjkl; keys in hint mode. +// @description-ja Hintモードで、asdfghjkl;キーを使って数字入力をする。 +// @license Creative Commons 2.1 (Attribution + Share Alike) +// @version 1.1 +// @minVersion 1.2 +// @maxVersion 1.2 +// @author anekos (anekos@snca.net) +// ==/VimperatorPlugin== +// +// Usage: +// In hint-mode, When press , enter into asdfghjkl; mode. +// (If you want to leave this mode, re-press ) +// +// Usage-ja: +// ヒントモードで、 を押すと asdfghjkl; モード(?)に入ります。 +// 出たい場合は、もう一度押します。 +// +// 切り替えキーを変更したい場合は、以下のように設定できます。 +// let g:asdfghjkl_mode_change_key = "" +// +// +// Links: +// http://d.hatena.ne.jp/nokturnalmortum/20081021#1224543467 +// + +{ + let asdfghjkl_default = window.eval(liberator.globalVariables.asdfghjkl_default || "false"); + let active = false; + + let original = { + show: hints.show, + onEvent: hints.onEvent, + }; + + hints.show = function () { + active = asdfghjkl_default; + return original.show.apply(this, arguments); + }; + + hints.onEvent = function (event) { + let key = events.toString(event); + if (key == "") { + active = !active; + return; + } + if (active && key.length == 1) { + let n = ";asdfghjkl".indexOf(key); + if (n >= 0) { + events.feedkeys(n.toString(), true); + return; + } + } + return original.onEvent.call(this, event); + }; + +} -- cgit v1.2.3