aboutsummaryrefslogtreecommitdiffstats
path: root/caret-hint.js
diff options
context:
space:
mode:
authoranekos2009-02-10 14:03:55 +0000
committeranekos2009-02-10 14:03:55 +0000
commit00defd3b5265637dfa805322533a50e3da0b2f4f (patch)
tree78d9b1edd10f916e2cc76e979e75ea98ddafdb7f /caret-hint.js
parent052f5a85cfd7c2f5cc3b5aafbf5c6a9623266ca0 (diff)
downloadvimperator-plugins-00defd3b5265637dfa805322533a50e3da0b2f4f.tar.bz2
選択モード追加
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@29866 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'caret-hint.js')
-rw-r--r--caret-hint.js45
1 files changed, 36 insertions, 9 deletions
diff --git a/caret-hint.js b/caret-hint.js
index 008affd..d38cc19 100644
--- a/caret-hint.js
+++ b/caret-hint.js
@@ -38,7 +38,7 @@ let PLUGIN_INFO =
<name>Caret Hint</name>
<description>Move the caret position by hint</description>
<description lang="ja">Hint を使ってキャレット位置を移動</description>
- <version>1.0.0</version>
+ <version>1.1.0</version>
<author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
<license>new BSD License (Please read the source code comments of this plugin)</license>
<license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license>
@@ -48,21 +48,30 @@ let PLUGIN_INFO =
<detail><![CDATA[
== Global Variables ==
let g:caret_hint_key:
- Hint mode key
+ Hint mode key.
+ Move the caret position to the selected element.
+ let g:caret_hint_select_key:
+ Hint mode key.
+ Move the caret position to the selected element, and select.
]]></detail>
<detail lang="ja"><![CDATA[
== Global Variables ==
let g:caret_hint_key:
- Hint モードのキー
+ Hint モードのキー。
+ 選択した要素の位置にキャレットを移動する。
+ let g:caret_hint_select_key:
+ Hint モードのキー。
+ 選択した要素の位置にキャレットを移動し、要素を選択する。
]]></detail>
</VimperatorPlugin>;
// }}}
(function () {
- let mode = liberator.globalVariables.caret_hint_key || 'c';
+ let headMode = liberator.globalVariables.caret_hint_key || 'c';
+ let selectMode = liberator.globalVariables.caret_hint_select_key || 'C';
- function moveCaret (elem) {
+ function moveCaret (elem, type) {
let doc = elem.ownerDocument;
let win = new XPCNativeWrapper(window.content.window);
@@ -71,17 +80,35 @@ let PLUGIN_INFO =
let r = doc.createRange();
r.selectNodeContents(elem);
- r.setEnd(r.startContainer, r.startOffset);
+
+ switch (type) {
+ case 'select':
+ mappings.getDefault(modes.NORMAL, 'i').action();
+ mappings.getDefault(modes.CARET, 'v').action();
+ break;
+ case 'head':
+ r.setEnd(r.startContainer, r.startOffset);
+ mappings.getDefault(modes.NORMAL, 'i').action();
+ break;
+ }
sel.addRange(r);
}
hints.addMode(
- 'c',
+ headMode,
'Move the caret position',
function (elem, _, count) {
- moveCaret(elem);
- mappings.getDefault(modes.NORMAL, 'i').action();
+ moveCaret(elem, 'head');
+ },
+ function () '//*'
+ );
+
+ hints.addMode(
+ selectMode,
+ 'Move the caret position and select',
+ function (elem, _, count) {
+ moveCaret(elem, 'select');
},
function () '//*'
);