From 00defd3b5265637dfa805322533a50e3da0b2f4f Mon Sep 17 00:00:00 2001 From: anekos Date: Tue, 10 Feb 2009 14:03:55 +0000 Subject: 選択モード追加 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@29866 d0d07461-0603-4401-acd4-de1884942a52 --- caret-hint.js | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'caret-hint.js') 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 = Caret Hint Move the caret position by hint Hint を使ってキャレット位置を移動 - 1.0.0 + 1.1.0 anekos new BSD License (Please read the source code comments of this plugin) 修正BSDライセンス (ソースコードのコメントを参照してください) @@ -48,21 +48,30 @@ let PLUGIN_INFO = ; // }}} (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 () '//*' ); -- cgit v1.2.3