forked from Botanical/BotanJS
G / gg commands
This commit is contained in:
parent
e0c50f1bff
commit
f227c7e16b
@ -168,29 +168,45 @@
|
|||||||
else if( this.feeder.moreAt < Y )
|
else if( this.feeder.moreAt < Y )
|
||||||
{
|
{
|
||||||
var feeder = this.feeder;
|
var feeder = this.feeder;
|
||||||
var lastLine = feeder.lastBuffer.lineNum;
|
|
||||||
var lineShift = Y - feeder.moreAt;
|
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while( !feeder.EOF )
|
|
||||||
{
|
|
||||||
feeder.pan( undefined, lineShift + i );
|
|
||||||
|
|
||||||
// if it turns out to be the same line
|
if( penentrate )
|
||||||
// before after panning
|
{
|
||||||
// we keep scrolling it ( panning )
|
feeder.pan( undefined, Y - moreAt );
|
||||||
// until the entire line cosumes the screen
|
}
|
||||||
if( feeder.lastBuffer.lineNum == lastLine )
|
else if( feeder.linesTotal < Y )
|
||||||
|
{
|
||||||
|
while( !feeder.EOF )
|
||||||
{
|
{
|
||||||
i ++;
|
feeder.pan( undefined, 1 );
|
||||||
}
|
}
|
||||||
else break;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var lastLine = feeder.lastBuffer.lineNum;
|
||||||
|
var lineShift = Y - feeder.moreAt;
|
||||||
|
|
||||||
|
i = lineShift;
|
||||||
|
while( !feeder.EOF )
|
||||||
|
{
|
||||||
|
feeder.pan( undefined, i );
|
||||||
|
|
||||||
|
// if it turns out to be the same line
|
||||||
|
// before after panning
|
||||||
|
// we keep scrolling it ( panning )
|
||||||
|
// until the entire line cosumes the screen
|
||||||
|
if( feeder.lastBuffer.lineNum == lastLine )
|
||||||
|
{
|
||||||
|
i ++;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The line number cursor need to be in
|
||||||
|
Y = lastLine + lineShift;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The line number cursor need to be in
|
// Calculate the visual line position "i"
|
||||||
Y = lastLine + lineShift;
|
|
||||||
|
|
||||||
// Calculate the visual line position
|
|
||||||
for( i = 0, line = feeder.firstBuffer;
|
for( i = 0, line = feeder.firstBuffer;
|
||||||
line != feeder.lastBuffer;
|
line != feeder.lastBuffer;
|
||||||
line = line.next )
|
line = line.next )
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
/** @type {Components.Vim.Cursor} */
|
/** @type {Components.Vim.Cursor} */
|
||||||
var Cursor = ns[ NS_INVOKE ]( "Cursor" );
|
var Cursor = ns[ NS_INVOKE ]( "Cursor" );
|
||||||
|
|
||||||
|
var occurence = __import( "System.utils.Perf.CountSubstr" );
|
||||||
|
|
||||||
var Feeder = function( rows, cols )
|
var Feeder = function( rows, cols )
|
||||||
{
|
{
|
||||||
var lineBuffers = [];
|
var lineBuffers = [];
|
||||||
@ -170,7 +172,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
__readOnly( Feeder.prototype, "linesTotal", function() {
|
__readOnly( Feeder.prototype, "linesTotal", function() {
|
||||||
return this.content.match( "\n" );
|
return occurence( this.content, "\n" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
__readOnly( Feeder.prototype, "firstBuffer", function() {
|
__readOnly( Feeder.prototype, "firstBuffer", function() {
|
||||||
|
@ -37,6 +37,8 @@ Components.Vim.LineFeeder.panY;
|
|||||||
/** @type Number */
|
/** @type Number */
|
||||||
Components.Vim.LineFeeder.moreAt;
|
Components.Vim.LineFeeder.moreAt;
|
||||||
/** @type Number */
|
/** @type Number */
|
||||||
|
Components.Vim.LineFeeder.linesTotal;
|
||||||
|
/** @type Number */
|
||||||
Components.Vim.LineFeeder.linesOccupied;
|
Components.Vim.LineFeeder.linesOccupied;
|
||||||
/** @type String */
|
/** @type String */
|
||||||
Components.Vim.LineFeeder.docPos;
|
Components.Vim.LineFeeder.docPos;
|
||||||
|
Loading…
Reference in New Issue
Block a user