From 030fb3226bc8abd668d11e24d0de7b19b2ee48b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Wed, 30 Mar 2016 21:12:01 +0800 Subject: [PATCH] Word range viw --- botanjs/src/Components/Vim/Actions/VISUAL.js | 31 ++++++++++++++++---- botanjs/src/Components/Vim/Controls.js | 1 - 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/botanjs/src/Components/Vim/Actions/VISUAL.js b/botanjs/src/Components/Vim/Actions/VISUAL.js index 8072e6b..1574d95 100644 --- a/botanjs/src/Components/Vim/Actions/VISUAL.js +++ b/botanjs/src/Components/Vim/Actions/VISUAL.js @@ -13,6 +13,16 @@ /** @type {Components.Vim.Cursor.IAction} */ var VISUAL = function( Cursor ) + { + this.__reset( Cursor ); + this.__msg = Mesg( "VISUAL" ); + this.__leaveMesg = ""; + + Cursor.blink = false; + Cursor.pSpace = true; + }; + + VISUAL.prototype.__reset = function( Cursor ) { /** @type {Components.Vim.Cursor} */ this.__cursor = Cursor; @@ -20,11 +30,6 @@ this.__startP = { x: Cursor.X, y: Cursor.Y, p: Cursor.P }; this.__start = Cursor.PStart; this.__selStart = Cursor.PStart; - this.__msg = Mesg( "VISUAL" ); - this.__leaveMesg = ""; - - Cursor.blink = false; - Cursor.pSpace = true; }; VISUAL.prototype.allowMovement = true; @@ -84,6 +89,22 @@ } else { + if( e.range ) + { + cur.suppressEvent(); + + var r = e.range; + + if( cur.aPos == this.__startaP ) + { + cur.moveX( r.open - this.__startaP ); + this.__reset( cur ); + } + + cur.unsuppressEvent(); + cur.moveX( r.close - cur.aPos ); + } + var prevPos = this.__start; var newPos = cur.PStart; diff --git a/botanjs/src/Components/Vim/Controls.js b/botanjs/src/Components/Vim/Controls.js index 29e86c4..f318060 100644 --- a/botanjs/src/Components/Vim/Controls.js +++ b/botanjs/src/Components/Vim/Controls.js @@ -322,7 +322,6 @@ ); e2.__range = WordMatch; - }, W ); this.__comp( e, function(){ debug.Info( "Bracket boundary [" );