Fix scrolling region and origin mode

This commit is contained in:
Keith Winstein
2011-01-31 22:08:28 -05:00
parent bc5caae26b
commit aa4d9d4b23
3 changed files with 21 additions and 9 deletions
+16 -9
View File
@@ -73,16 +73,16 @@ void Framebuffer::scroll( int N )
{ {
if ( N >= 0 ) { if ( N >= 0 ) {
for ( int i = 0; i < N; i++ ) { for ( int i = 0; i < N; i++ ) {
rows.erase( rows.begin() + ds.limit_top() ); rows.erase( rows.begin() + ds.get_scrolling_region_top_row() );
rows.insert( rows.begin() + ds.limit_bottom(), Row( ds.get_width() ) ); rows.insert( rows.begin() + ds.get_scrolling_region_bottom_row(), Row( ds.get_width() ) );
ds.move_row( -1, true ); ds.move_row( -1, true );
} }
} else { } else {
N = -N; N = -N;
for ( int i = 0; i < N; i++ ) { for ( int i = 0; i < N; i++ ) {
rows.erase( rows.begin() + ds.limit_bottom() ); rows.erase( rows.begin() + ds.get_scrolling_region_bottom_row() );
rows.insert( rows.begin() + ds.limit_top(), Row( ds.get_width() ) ); rows.insert( rows.begin() + ds.get_scrolling_region_top_row(), Row( ds.get_width() ) );
ds.move_row( 1, true ); ds.move_row( 1, true );
} }
} }
@@ -107,7 +107,7 @@ void DrawState::move_row( int N, bool relative )
if ( relative ) { if ( relative ) {
cursor_row += N; cursor_row += N;
} else { } else {
cursor_row = N; cursor_row = N + limit_top();
} }
snap_cursor_to_border(); snap_cursor_to_border();
@@ -140,10 +140,17 @@ void DrawState::move_col( int N, bool relative, bool implicit )
void Framebuffer::move_rows_autoscroll( int rows ) void Framebuffer::move_rows_autoscroll( int rows )
{ {
if ( ds.get_cursor_row() + rows > ds.limit_bottom() ) { /* don't scroll if outside the scrolling region */
scroll( ds.get_cursor_row() + rows - ds.limit_bottom() ); if ( (ds.get_cursor_row() < ds.get_scrolling_region_top_row())
} else if ( ds.get_cursor_row() + rows < ds.limit_top() ) { || (ds.get_cursor_row() > ds.get_scrolling_region_bottom_row()) ) {
scroll( ds.get_cursor_row() + rows - ds.limit_top() ); ds.move_row( rows, true );
return;
}
if ( ds.get_cursor_row() + rows > ds.get_scrolling_region_bottom_row() ) {
scroll( ds.get_cursor_row() + rows - ds.get_scrolling_region_bottom_row() );
} else if ( ds.get_cursor_row() + rows < ds.get_scrolling_region_top_row() ) {
scroll( ds.get_cursor_row() + rows - ds.get_scrolling_region_top_row() );
} }
ds.move_row( rows, true ); ds.move_row( rows, true );
+3
View File
@@ -69,6 +69,9 @@ namespace Terminal {
void set_scrolling_region( int top, int bottom ); void set_scrolling_region( int top, int bottom );
int get_scrolling_region_top_row( void ) { return scrolling_region_top_row; }
int get_scrolling_region_bottom_row( void ) { return scrolling_region_bottom_row; }
int limit_top( void ); int limit_top( void );
int limit_bottom( void ); int limit_bottom( void );
+2
View File
@@ -227,6 +227,8 @@ void CSI_DECSTBM( Framebuffer *fb, Dispatcher *dispatch )
int bottom = dispatch->getparam( 1, fb->ds.get_height() ); int bottom = dispatch->getparam( 1, fb->ds.get_height() );
fb->ds.set_scrolling_region( top - 1, bottom - 1 ); fb->ds.set_scrolling_region( top - 1, bottom - 1 );
fb->ds.move_row( 0 );
fb->ds.move_col( 0 );
} }
static Function func_CSI_DECSTMB( CSI, "r", CSI_DECSTBM ); static Function func_CSI_DECSTMB( CSI, "r", CSI_DECSTBM );