diff --git a/terminal.cpp b/terminal.cpp index d60412b..e55948c 100644 --- a/terminal.cpp +++ b/terminal.cpp @@ -58,10 +58,6 @@ void Emulator::print( Parser::Print *act ) Cell *this_cell = fb.get_cell(); - if ( !this_cell ) { /* zero-size framebuffer */ - return; - } - Cell *combining_cell = fb.get_combining_cell(); switch ( chwidth ) { diff --git a/terminalframebuffer.cpp b/terminalframebuffer.cpp index 0a6a82b..3af159e 100644 --- a/terminalframebuffer.cpp +++ b/terminalframebuffer.cpp @@ -145,9 +145,8 @@ void Framebuffer::move_rows_autoscroll( int rows ) Cell *Framebuffer::get_cell( void ) { - if ( (ds.get_width() == 0) || (ds.get_height() == 0) ) { - return NULL; - } + assert( ds.get_width() ); + assert( ds.get_height() ); return &rows[ ds.get_cursor_row() ].cells[ ds.get_cursor_col() ]; } @@ -232,10 +231,7 @@ std::vector DrawState::get_tabs( void ) void Framebuffer::apply_renditions_to_current_cell( void ) { - Cell *this_cell = get_cell(); - assert( this_cell ); - - this_cell->renditions = ds.get_renditions(); + get_cell()->renditions = ds.get_renditions(); } SavedCursor::SavedCursor() @@ -291,4 +287,21 @@ void Framebuffer::delete_line( int row ) void Row::insert_cell( int col ) { cells.insert( cells.begin() + col, Cell() ); + cells.erase( cells.end() - 1 ); +} + +void Row::delete_cell( int col ) +{ + cells.erase( cells.begin() + col ); + cells.push_back( Cell() ); +} + +void Framebuffer::insert_cell( int row, int col ) +{ + rows[ row ].insert_cell( col ); +} + +void Framebuffer::delete_cell( int row, int col ) +{ + rows[ row ].delete_cell( col ); } diff --git a/terminalframebuffer.hpp b/terminalframebuffer.hpp index 5471892..a5072e8 100644 --- a/terminalframebuffer.hpp +++ b/terminalframebuffer.hpp @@ -123,6 +123,9 @@ namespace Terminal { void insert_line( int before_row ); void delete_line( int row ); + + void insert_cell( int row, int col ); + void delete_cell( int row, int col ); }; } diff --git a/terminalfunctions.cpp b/terminalfunctions.cpp index daacb46..4cf4086 100644 --- a/terminalfunctions.cpp +++ b/terminalfunctions.cpp @@ -341,3 +341,28 @@ void CSI_DL( Framebuffer *fb, Dispatcher *dispatch ) } static Function func_CSI_DL( CSI, "M", CSI_DL ); + +/* insert characters */ +void CSI_ICH( Framebuffer *fb, Dispatcher *dispatch ) +{ + int cells = dispatch->getparam( 0, 1 ); + + for ( int i = 0; i < cells; i++ ) { + fb->insert_cell( fb->ds.get_cursor_row(), fb->ds.get_cursor_col() ); + } +} + +static Function func_CSI_ICH( CSI, "@", CSI_ICH ); + +/* delete character */ +void CSI_DCH( Framebuffer *fb, Dispatcher *dispatch ) +{ + int cells = dispatch->getparam( 0, 1 ); + + for ( int i = 0; i < cells; i++ ) { + fb->delete_cell( fb->ds.get_cursor_row(), fb->ds.get_cursor_col() ); + } +} + +static Function func_CSI_DCH( CSI, "P", CSI_DCH ); +