Fix scrolling region and origin mode
This commit is contained in:
+16
-9
@@ -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 );
|
||||||
|
|||||||
@@ -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 );
|
||||||
|
|
||||||
|
|||||||
@@ -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 );
|
||||||
|
|||||||
Reference in New Issue
Block a user