From 31fefb5179cb04ece9fd321c531c7a311c65c2e0 Mon Sep 17 00:00:00 2001
From: anekos
Date: Mon, 28 Mar 2011 17:09:54 +0900
Subject: マッピングの設定を可能にした
---
win-mouse.js | 68 +++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 47 insertions(+), 21 deletions(-)
(limited to 'win-mouse.js')
diff --git a/win-mouse.js b/win-mouse.js
index b6b19cd..ae9f817 100644
--- a/win-mouse.js
+++ b/win-mouse.js
@@ -54,6 +54,24 @@ let INFO =
+ -
+ g:win_mouse_map_move_DIR
+ g:win_mouse_map_move_(left|right|up|down)=keys
+
+
+ If given this global variable, this plugin map the keys to mouse moving action in all mode.
+
+
+
+ -
+ g:win_mouse_map_BUTTON_click
+ g:win_mouse_map_(left|right|middle)_click=keys
+
+
+ If given this global variable, this plugin map the keys to mouse clicking action in all mode.
+
+
+
>;
// }}}
@@ -187,35 +205,43 @@ let INFO =
for (let i = 1; i <= modes.PROMPT; i *= 2)
ALL_MODE.push(i);
- const D = function (v, p) (v * (p > 0 ? p : 10));
- [
- [[''], 'left', -1, 0],
- [[''], 'right', 1, 0],
- [[''], 'up', 0, -1],
- [[''], 'down', 0, 1],
- ].forEach(function ([keys, name, dx, dy]) {
+ function mapIfGiven (name, description, action, extra) {
+ let keys = liberator.globalVariables[name];
+ if (!keys)
+ return;
+
mappings.addUserMap(
ALL_MODE,
- keys,
+ [keys],
+ description,
+ action,
+ extra
+ );
+ }
+
+ const D = function (v, p) (v * (p > 0 ? p : 10));
+ [
+ ['left', -1, 0],
+ ['right', 1, 0],
+ ['up', 0, -1],
+ ['down', 0, 1],
+ ].forEach(function ([name, dx, dy]) {
+ mapIfGiven(
+ 'win_mouse_map_move_' + name,
'Move cursor to' + name,
function (count) API.move(D(dx, count), D(dy, count), true),
{count: true}
);
});
- mappings.addUserMap(
- [modes.NORMAL],
- [''],
- 'Click (Left button)',
- function () API.click('left')
- );
-
- mappings.addUserMap(
- [modes.NORMAL],
- [''],
- 'Click (Right button)',
- function () API.click('right')
- );
+ ['left', 'right', 'middle'].forEach(function (name) {
+ mapIfGiven(
+ 'win_mouse_map_' + name + '_click',
+ name + ' click',
+ function () API.click(name),
+ {}
+ );
+ });
// }}}
// Define commands {{{
--
cgit v1.2.3