From a3eebedebcfd2550dfced0c5352f4000e4c88496 Mon Sep 17 00:00:00 2001 From: snaka Date: Sun, 24 May 2009 04:52:07 +0000 Subject: CARETモードの標準のキーバインドと同じものを追加 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@33539 d0d07461-0603-4401-acd4-de1884942a52 --- auto_word_select_mode.js | 54 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) (limited to 'auto_word_select_mode.js') diff --git a/auto_word_select_mode.js b/auto_word_select_mode.js index 552c256..244cb9d 100644 --- a/auto_word_select_mode.js +++ b/auto_word_select_mode.js @@ -154,6 +154,7 @@ const KEY = liberator.globalVariables.auto_word_select_key || 'I'; if (!modes.AUTO_WORD_SELECT) modes.addMode(NEW_MODE, false, function() NEW_MODE); +// MAPPINGS {{{ mappings.addUserMap( [modes.NORMAL, modes.CARET, modes.VISUAL], [KEY], @@ -206,7 +207,8 @@ mappings.add( } ); -mappings.add( [modes.AUTO_WORD_SELECT], +mappings.add( + [modes.AUTO_WORD_SELECT], ["l"], "Move to right word and select.", function() { @@ -215,7 +217,8 @@ mappings.add( [modes.AUTO_WORD_SELECT], } ); -mappings.add( [modes.AUTO_WORD_SELECT], +mappings.add( + [modes.AUTO_WORD_SELECT], ["L"], "Extend to right word.", function() { @@ -226,7 +229,8 @@ mappings.add( [modes.AUTO_WORD_SELECT], } ); -mappings.add( [modes.AUTO_WORD_SELECT], +mappings.add( + [modes.AUTO_WORD_SELECT], ["h"], "Move to left word and select.", function() { @@ -246,7 +250,8 @@ mappings.add( [modes.AUTO_WORD_SELECT], } ); -mappings.add( [modes.AUTO_WORD_SELECT], +mappings.add( + [modes.AUTO_WORD_SELECT], ["H"], "Extend to left word.", function() { @@ -257,7 +262,8 @@ mappings.add( [modes.AUTO_WORD_SELECT], } ); -mappings.add( [modes.AUTO_WORD_SELECT], +mappings.add( + [modes.AUTO_WORD_SELECT], ["j"], "Move to below word and select.", function() { @@ -267,7 +273,8 @@ mappings.add( [modes.AUTO_WORD_SELECT], } ); -mappings.add( [modes.AUTO_WORD_SELECT], +mappings.add( + [modes.AUTO_WORD_SELECT], ["k"], "Move to above word and select.", function() { @@ -287,6 +294,39 @@ mappings.add( [modes.AUTO_WORD_SELECT], } ); +// inherites key mappings from CARET mode +[ + // keys hasCount caretModeMethod caretModeArg + [["b", "B", ""], true, "wordMove", false], + [["w", "W", "e", ""], true, "wordMove", true ], + [["", ""], true, "pageMove", true ], + [["", ""], true, "pageMove", false], + [["gg", ""], false, "completeMove", false], + [["G", ""], false, "completeMove", true ], + [["0", "^", ""], false, "intraLineMove", false], + [["$", ""], false, "intraLineMove", true ], +].map(function(params) { + let [keys, hasCount, caretModeMethod, caretModeArg] = params; + + let extraInfo = {}; + if (hasCount) + extraInfo.flags = Mappings.flags.COUNT; + + mappings.add([modes.AUTO_WORD_SELECT], keys, "", + function (count) { + if (typeof count != "number" || count < 1) + count = 1; + + let controller = buffer.selectionController; + while (count--) + controller[caretModeMethod](caretModeArg, false); + }, + extraInfo + ); +}); + +// }}} +// PRIVATE FUNCTIONS {{{ function selectWord() { controller().wordMove(true, false); controller().wordMove(false, true); @@ -316,6 +356,7 @@ function selectable() { return true; } +// }}} //// for debuging //liberator.registerObserver("modeChange", function(oldModes, newModes, stack) { @@ -326,6 +367,7 @@ function selectable() { //}); //function getModeName(id) modes.getMode(id) ? modes.getMode(id).name : ""; +liberator.echo("loading ..."); })(); // vim:sw=2 ts=2 et si fdm=marker: -- cgit v1.2.3