diff --git a/botanjs/src/Components/Vim/Cursor.js b/botanjs/src/Components/Vim/Cursor.js index 0fb6284..542051c 100644 --- a/botanjs/src/Components/Vim/Cursor.js +++ b/botanjs/src/Components/Vim/Cursor.js @@ -54,7 +54,7 @@ } else { - offset += line.cols + 1; + offset += line.toString().length + 1; } line = line.next; @@ -180,6 +180,8 @@ this.moveX(); this.updatePosition(); + feeder.softReset(); + return; } diff --git a/botanjs/src/Components/Vim/LineBuffer.js b/botanjs/src/Components/Vim/LineBuffer.js index ed612a6..05a7f5c 100644 --- a/botanjs/src/Components/Vim/LineBuffer.js +++ b/botanjs/src/Components/Vim/LineBuffer.js @@ -20,6 +20,7 @@ this.br = false; this.placeholder = true; this.lineNum = 0; + this.tabWidth = 8; if( nextLineBuffer ) { @@ -45,9 +46,10 @@ var br = false; var i = 0; + var numTabs = 0; if( wrap ) { - for( ; i < this.cols; i ++ ) + for( ; i < this.cols - numTabs * this.tabWidth; i ++ ) { var c = content[i]; if( c === undefined ) break; @@ -58,6 +60,10 @@ i ++; break; } + else if( c == "\t" ) + { + numTabs ++; + } line += c; } @@ -75,8 +81,12 @@ i ++; break; } + else if( c == "\t" ) + { + numTabs ++; + } - if( i < this.cols ) + if( i < this.cols - numTabs * this.tabWidth ) { line += c; } diff --git a/botanjs/src/Components/Vim/LineFeeder.js b/botanjs/src/Components/Vim/LineFeeder.js index 3edc1b7..b86f17f 100644 --- a/botanjs/src/Components/Vim/LineFeeder.js +++ b/botanjs/src/Components/Vim/LineFeeder.js @@ -75,7 +75,8 @@ { var display = ( line == undefined ? "" : line ) + ""; - var atSpace = false + var atSpace = false; + for( var i = 0; line && i < steps && ( line = line.next ) && placeholdCond( line ); i ++ ) @@ -93,6 +94,23 @@ return display; }; + + this.__softRender = function() + { + var line = _self.lineBuffers[ _self.__rStart ]; + var steps = _self.__rLength; + + for( var i = 0; + line && i < steps && ( line = line.next ) && placeholdCond( line ); + i ++ ) + { + if( line.br && steps < ( i + line.visualLines.length ) ) + { + _self.__clseLine = line; + break; + } + } + }; } Feeder.prototype.render = function( start, length ) @@ -107,7 +125,9 @@ if( length == 0 ) return ""; - return this.__render( buffs[ start ], length - 1 ); + this.__rStart = start; + this.__rLength = length - 1; + return this.__render( buffs[ start ], this.__rLength ); }; Feeder.prototype.pan = function( dX, dY ) @@ -137,6 +157,13 @@ this.panY = Y; }; + Feeder.prototype.softReset = function() + { + this.__moreAt = -1; + this.__clseLine = null; + this.__softRender(); + }; + __readOnly( Feeder.prototype, "firstBuffer", function() { return this.lineBuffers[ 0 ]; } ); @@ -145,6 +172,10 @@ return this.lineBuffers[ this.__rows - 1 ]; } ); + __readOnly( Feeder.prototype, "EOF", function() { + return this.lineBuffers[ this.__rows ].placeholder; + } ); + __readOnly( Feeder.prototype, "moreAt", function() { if( 0 < this.__moreAt ) return this.__moreAt; @@ -159,18 +190,35 @@ } while( line = line.next ); + if( line == undefined ) i --; + return ( this.__moreAt = i ); } ); __readOnly( Feeder.prototype, "lineStat", function() { var X = this.cursor.X; - return ( this.cursor.getLine().lineNum + 1 ) + "," + X + "-" + ( X ); + + var line = this.cursor.getLine(); + var tabStat = ""; + + var tabs = line.content.match( /\t/g ); + + if( tabs ) + { + tabStat = "-" + ( X + tabs.length * line.tabWidth ); + } + + return ( line.lineNum + 1 ) + "," + X + tabStat; } ); __readOnly( Feeder.prototype, "docPos", function() { var pos = "ALL"; - if( this.panY == 0 ) + if( 0 < this.panY && this.EOF ) + { + pos = "BOTTOM"; + } + else { if( this.__clseLine || !this.EOF ) { @@ -178,6 +226,7 @@ } } + return pos; } );