aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranekos2008-11-09 09:53:44 +0000
committeranekos2008-11-09 09:53:44 +0000
commit28a7da6b0da9513beacc1a5e3ae570bd5283cbdf (patch)
tree1b3cf811479b24106b1ee2e803c24a482d106417
parent8c0e42c0a52007071176b29a0d0cdd22cae5a13c (diff)
downloadvimperator-plugins-28a7da6b0da9513beacc1a5e3ae570bd5283cbdf.tar.bz2
Initial release: まだマッピングされていないキーを表示するプラグイン
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@23050 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r--yetmappings.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/yetmappings.js b/yetmappings.js
new file mode 100644
index 0000000..41722bc
--- /dev/null
+++ b/yetmappings.js
@@ -0,0 +1,53 @@
+// @name yet mappings
+// @description display the keys that are not mapped yet.
+// @description-ja まだマップされていないキーを表示する
+// @license Creative Commons 2.1 (Attribution + Share Alike)
+// @version 1.0
+// @author anekos (anekos@snca.net)
+// @maxVersion 1.2
+// @minVersion 2.0pre
+// ==/VimperatorPlugin==
+//
+// Usage:
+// :yetmap[pings] [<KEYS>]
+// :ymap [<KEYS>]
+//
+// Links:
+// http://d.hatena.ne.jp/nokturnalmortum/20081109#1226223461
+//
+
+(function () {
+ const other = '! @ # $ % ^ & * ( ) _ + | ~ { } : " < > ? - = \\ ` [ ] ; \' , . /'.split(/\s/);
+ const special = 'Esc Return Tab Del BS Home Insert End Left Right Up Down PageUp PageDown F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12'.split(/\s/).map(function (it) ("<" + it + ">"));
+ const alpha = 'a b c d e f g h i j k l m n o p q r s t u v w x y z'.split(/\s/);
+ const keys = alpha.concat(alpha.map(String.toUpperCase)).concat(other).concat(special);
+
+ function exists (modes, key)
+ (mappings.getCandidates(modes, key).length || mappings.get(modes, key));
+
+ function getYetMappings (pre) {
+ let result = [];
+ keys.forEach(function (key) {
+ if (!exists([modes.NORMAL], pre + key))
+ result.push(key);
+ });
+ return result;
+ }
+
+ commands.addUserCommand(
+ ['yetmap[pings]', 'ymap'],
+ 'display the keys that are not mapped yet.',
+ function (arg) {
+ liberator.echo(getYetMappings(arg.string || '').join(' '), commandline.FORCE_MULTILINE);
+ },
+ {
+ argCount: '*'
+ },
+ true
+ );
+
+ liberator.plugins.yet_mappgins = {
+ get: getYetMappings
+ };
+})();
+