Insert and delete lines
This commit is contained in:
@@ -298,3 +298,25 @@ void DrawState::restore_cursor( void )
|
||||
snap_cursor_to_border();
|
||||
new_grapheme();
|
||||
}
|
||||
|
||||
void Framebuffer::insert_line( int before_row )
|
||||
{
|
||||
if ( (before_row < ds.get_scrolling_region_top_row())
|
||||
|| (before_row > ds.get_scrolling_region_bottom_row() + 1) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
rows.erase( rows.begin() + ds.get_scrolling_region_bottom_row() );
|
||||
rows.insert( rows.begin() + before_row, Row( ds.get_width() ) );
|
||||
}
|
||||
|
||||
void Framebuffer::delete_line( int row )
|
||||
{
|
||||
if ( (row < ds.get_scrolling_region_top_row())
|
||||
|| (row > ds.get_scrolling_region_bottom_row() + 1) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
rows.erase( rows.begin() + row );
|
||||
rows.insert( rows.begin() + ds.get_scrolling_region_bottom_row(), Row( ds.get_width() ) );
|
||||
}
|
||||
|
||||
@@ -120,6 +120,8 @@ namespace Terminal {
|
||||
|
||||
void apply_renditions_to_current_cell( void );
|
||||
void claim_overlap( int row, int col );
|
||||
void insert_line( int before_row );
|
||||
void delete_line( int row );
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -309,3 +309,35 @@ void CSI_DSR( Framebuffer *fb, Dispatcher *dispatch )
|
||||
}
|
||||
|
||||
static Function func_CSI_DSR( CSI, "n", CSI_DSR );
|
||||
|
||||
/* insert line */
|
||||
void CSI_IL( Framebuffer *fb, Dispatcher *dispatch )
|
||||
{
|
||||
int lines = dispatch->getparam( 0, 1 );
|
||||
|
||||
for ( int i = 0; i < lines; i++ ) {
|
||||
fb->insert_line( fb->ds.get_cursor_row() );
|
||||
}
|
||||
|
||||
/* vt220 manual and Ecma-48 say to move to first column */
|
||||
/* but xterm and gnome-terminal don't */
|
||||
fb->ds.move_col( 0 );
|
||||
}
|
||||
|
||||
static Function func_CSI_IL( CSI, "L", CSI_IL );
|
||||
|
||||
/* delete line */
|
||||
void CSI_DL( Framebuffer *fb, Dispatcher *dispatch )
|
||||
{
|
||||
int lines = dispatch->getparam( 0, 1 );
|
||||
|
||||
for ( int i = 0; i < lines; i++ ) {
|
||||
fb->delete_line( fb->ds.get_cursor_row() );
|
||||
}
|
||||
|
||||
/* same story -- xterm and gnome-terminal don't
|
||||
move to first column */
|
||||
fb->ds.move_col( 0 );
|
||||
}
|
||||
|
||||
static Function func_CSI_DL( CSI, "M", CSI_DL );
|
||||
|
||||
Reference in New Issue
Block a user