aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranekos2011-03-31 22:40:27 +0900
committeranekos2011-03-31 22:40:47 +0900
commit0314db072ede0592e12c74d0f1bb691d9b92da72 (patch)
tree9efe94413fe4009042c0e64ea4694d640f998a46
parentc0a76678c7817bd0d57a57aef15968097cd7eece (diff)
downloadvimperator-plugins-0314db072ede0592e12c74d0f1bb691d9b92da72.tar.bz2
ヒントなどで要素を基準にした動作を行う element サブコマンドを追加しました
-rw-r--r--win-mouse.js44
1 files changed, 28 insertions, 16 deletions
diff --git a/win-mouse.js b/win-mouse.js
index c54d22d..998f94d 100644
--- a/win-mouse.js
+++ b/win-mouse.js
@@ -35,7 +35,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
// INFO {{{
let INFO =
<>
- <plugin name="Win Cursor" version="1.2.0"
+ <plugin name="Win Cursor" version="1.3.0"
href="http://vimpr.github.com/"
summary="Cursor control plugin for MS Windows"
lang="en-US"
@@ -588,30 +588,42 @@ let INFO =
}
),
new Command(
- ['hint'],
- 'Hint',
+ ['e[lement]'],
+ 'Do something with the specified element. (use XPath)',
function (args) {
- showHint(
- function (elem) {
- API.move({
- elem: elem,
- x: args['-x'],
- y: args['-y']
- });
- if (args['-click'])
- API.click({name: args['-click']});
- },
- args.literalArg
- );
+ function action (elem) {
+ API.move({
+ elem: elem,
+ x: args['-x'],
+ y: args['-y']
+ });
+ if (args['-click'])
+ API.click({name: args['-click']});
+ }
+
+ let xpath = args.literalArg;
+ let index = args['-index'];
+
+ if (index !== undefined) {
+ let elem = [m for (m in util.evaluateXPath(xpath))][index];
+ if (elem)
+ action(elem);
+ else
+ liberator.echoerr('Not found the element: ' + xpath);
+ return
+ }
+
+ showHint(action, args.literalArg);
},
{
literal: 0,
bang: true,
options: [
+ [['-index'], commands.OPTION_INT],
[['-x'], commands.OPTION_INT],
[['-y'], commands.OPTION_INT],
[
- ['-click'],
+ ['-click', '-c'],
commands.OPTION_STRING,
function (it) (!!buttonNameToClickValues(it)),
[[name, name + ' click'] for ([, name] in Iterator('left right middle'.split(' ')))]