Insert and delete lines

This commit is contained in:
Keith Winstein
2011-02-01 00:25:16 -05:00
parent 405cd3a703
commit c95c835853
3 changed files with 56 additions and 0 deletions
+22
View File
@@ -298,3 +298,25 @@ void DrawState::restore_cursor( void )
snap_cursor_to_border(); snap_cursor_to_border();
new_grapheme(); 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() ) );
}
+2
View File
@@ -120,6 +120,8 @@ namespace Terminal {
void apply_renditions_to_current_cell( void ); void apply_renditions_to_current_cell( void );
void claim_overlap( int row, int col ); void claim_overlap( int row, int col );
void insert_line( int before_row );
void delete_line( int row );
}; };
} }
+32
View File
@@ -309,3 +309,35 @@ void CSI_DSR( Framebuffer *fb, Dispatcher *dispatch )
} }
static Function func_CSI_DSR( CSI, "n", CSI_DSR ); 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 );