diff --git a/botanjs/src/Components/Vim/Actions/INSERT.js b/botanjs/src/Components/Vim/Actions/INSERT.js index c35c1672..08310ea2 100644 --- a/botanjs/src/Components/Vim/Actions/INSERT.js +++ b/botanjs/src/Components/Vim/Actions/INSERT.js @@ -37,6 +37,7 @@ this.__stator = new Stator( Cursor ); this.__minReach = 0; this.__insertLen = 0; + this.__chopIndent = false; // Initialize this stack this.__rec( "", true ); @@ -52,6 +53,7 @@ INSERT.prototype.dispose = function() { + if( this.__chopIndent ) this.__realizeIndent(); if( this.__cancelIndent() ) { this.__cursor.feeder.pan(); @@ -175,6 +177,8 @@ var f = cur.aPos; + var chopIndent = feeder.content[ f ] != "\n"; + feeder.content = feeder.content.substring( 0, f ) + inputChar @@ -187,6 +191,7 @@ cur.moveY( 1 ); cur.lineStart(); this.__autoIndent( e ); + this.__chopIndent = chopIndent; } else { @@ -218,6 +223,7 @@ INSERT.prototype.__autoIndent = function( e ) { + var oInd = this.__phantomIndent; var carried = this.__cancelIndent(); var cur = this.__cursor; @@ -237,7 +243,7 @@ line = feeder.content.substring( i + 1, j - 1 ); } - var inDel = ""; + var inDel = carried ? oInd[ IN_DEL ] : ""; // Indent removed for( var ir = f; "\t ".indexOf( feeder.content[ ir ] ) != -1; ir ++ ) { diff --git a/botanjs/src/Components/Vim/Actions/SHIFT_LINES.js b/botanjs/src/Components/Vim/Actions/SHIFT_LINES.js index 1202b6cf..0e83a39f 100644 --- a/botanjs/src/Components/Vim/Actions/SHIFT_LINES.js +++ b/botanjs/src/Components/Vim/Actions/SHIFT_LINES.js @@ -15,10 +15,6 @@ var occurence = __import( "System.utils.Perf.CountSubstr" ); - var REPL_BEFORE = 0; - var REPL_OFFSET = 1; - var REPL_LENGTH = 2; - /** @type {Components.Vim.IAction} * Cursor @param {Components.Vim.Cursor} * e @param {Components.Vim.ActionEvent} @@ -32,8 +28,8 @@ this.__slineNum = Cursor.getLine().lineNum; - this.__lines = e.count; - debug.Info( "Open shift: " + this.__lines + " line(s) below the cursor" ); + this.__lines = e.count - 1; + debug.Info( "Open shift: " + this.__lines + " line(s) from the cursor" ); this.__direction = e.kMap( ">" ) ? 1 : -1; debug.Info( "Direction is: " + ( this.__direction == 1 ? ">" : "<" ) ); @@ -66,7 +62,7 @@ if( 1 < e.count ) { - nline += e.count; + nline += ( e.count - 1 ); } // default: >>, <<, >l, "; + case SHIFT + SLASH: return "?"; case SHIFT + BACK_SLASH: return "|"; + case SHIFT + DASH: case SHIFT + GECKO_DASH: return "_"; + case SHIFT + EQUAL: case SHIFT + GECKO_EQUAL: return "+"; + + case SHIFT + A: return "A"; case SHIFT + B: return "B"; case SHIFT + C: return "C"; + case SHIFT + D: return "D"; case SHIFT + E: return "E"; case SHIFT + F: return "F"; + case SHIFT + G: return "G"; case SHIFT + H: return "H"; case SHIFT + I: return "I"; + case SHIFT + J: return "J"; case SHIFT + K: return "K"; case SHIFT + L: return "L"; + case SHIFT + M: return "M"; case SHIFT + N: return "N"; case SHIFT + O: return "O"; + case SHIFT + P: return "P"; case SHIFT + Q: return "Q"; case SHIFT + R: return "R"; + case SHIFT + S: return "S"; case SHIFT + T: return "T"; case SHIFT + U: return "U"; + case SHIFT + V: return "V"; case SHIFT + W: return "W"; case SHIFT + X: return "X"; + case SHIFT + Y: return "Y"; case SHIFT + Z: return "Z"; + case ESC: return "Escape"; case BACKSPACE: return "Backspace"; case DELETE: return "Delete"; + case SHIFT: return "Shift"; case ALT: return "Alt"; case CTRL: return "Control"; + case ENTER: return "Enter"; case TAB: return "Tab"; + } + + return "?"; + }; + var Controls = function( vimArea ) { /** @type {Components.Vim.VimArea} */ @@ -277,6 +334,7 @@ break; case SHIFT + SEMI_COLON: // ":" Command line + case SHIFT + GECKO_SEMI_COLON: this.__divedCCmd = new ExCommand( ccur, ":" ); this.__divedCCmd.handler( e ); break; @@ -349,7 +407,13 @@ _self.__mod = false; }, ANY_KEY ); break; - case _0: case _1: case _2: case _3: case _4: + case _0: // No 0 for first count + if( !this.__compositeReg ) + { + mod = false; + break; + } + case _1: case _2: case _3: case _4: case _5: case _6: case _7: case _8: case _9: var Count = e.key; @@ -412,10 +476,12 @@ switch( kCode ) { case BACKSPACE: this.__cMoveX( -1, true ); break; // Backspace, go back 1 char - case H: this.__cMoveX( -1 ); break; // Left - case L: this.__cMoveX( 1 ); break; // Right - case K: this.__cMoveY( -1 ); break; // Up - case J: this.__cMoveY( 1 ); break; // Down + case H: this.__cMoveX( - e.count ); break; // Left + case L: this.__cMoveX( e.count ); break; // Right + case DASH: case GECKO_DASH: + case K: this.__cMoveY( - e.count ); break; // Up + case ENTER: + case J: this.__cMoveY( e.count ); break; // Down case CTRL + F: // Page Down if( cfeeder.firstBuffer.nextLine.placeholder ) @@ -650,17 +716,21 @@ this.__divedCCmd.dispose(); this.__cMovement = false; this.__divedCCmd = null; + return; } if( e.canceled ) return; } - this.__modCommand( e ); - if( e.canceled ) return; - var cfeeder = this.__cfeeder; var ccur = this.__ccur; + if( !ccur.action || ccur.action.allowMovement ) + { + this.__modCommand( e ); + if( e.canceled ) return; + } + var kCode = e.keyCode; // Action commands are handled by the actions themselves @@ -729,7 +799,7 @@ + ( e.altKey ? ALT : 0 ); this.__modKeys = c == KEY_SHIFT || c == KEY_CTRL || c == KEY_ALT; - this.__key = e.key; + this.__key = e.key || RMap( this.__kCode ); } this.__count = 1;