diff --git a/terminal.cpp b/terminal.cpp index c7155f9..d60412b 100644 --- a/terminal.cpp +++ b/terminal.cpp @@ -79,7 +79,12 @@ void Emulator::print( Parser::Print *act ) this_cell->width = chwidth; fb.apply_renditions_to_current_cell(); - fb.claim_overlap( fb.ds.get_cursor_row(), fb.ds.get_cursor_col() ); + if ( chwidth == 2 ) { /* erase overlapped cell */ + Cell *next = fb.get_cell( fb.ds.get_cursor_row(), fb.ds.get_cursor_col() + 1 ); + if ( next ) { + next->reset(); + } + } fb.ds.move_col( chwidth, true, true ); @@ -134,15 +139,11 @@ void Emulator::debug_printout( int fd ) screen.append( "\033[H" ); for ( int y = 0; y < fb.ds.get_height(); y++ ) { - for ( int x = 0; x < fb.ds.get_width(); x++ ) { + for ( int x = 0; x < fb.ds.get_width(); /* let charwidth handle advance */ ) { char curmove[ 32 ]; snprintf( curmove, 32, "\033[%d;%dH\033[X", y + 1, x + 1 ); screen.append( curmove ); Cell *cell = fb.get_cell( y, x ); - if ( cell->overlapping_cell ) continue; - - assert( (cell->overlapped_cells.size() + 1 == (size_t)cell->width) - || (x == fb.ds.get_width() - 1) ); /* print renditions */ screen.append( "\033[0" ); @@ -171,6 +172,8 @@ void Emulator::debug_printout( int fd ) snprintf( utf8, 8, "%lc", *i ); screen.append( utf8 ); } + + x += cell->width; } } diff --git a/terminalframebuffer.cpp b/terminalframebuffer.cpp index b0c5212..0a6a82b 100644 --- a/terminalframebuffer.cpp +++ b/terminalframebuffer.cpp @@ -5,18 +5,14 @@ using namespace Terminal; Cell::Cell() - : overlapping_cell( NULL ), - contents(), - overlapped_cells(), + : contents(), fallback( false ), width( 1 ), renditions() {} Cell::Cell( const Cell &x ) - : overlapping_cell( x.overlapping_cell ), - contents( x.contents ), - overlapped_cells( x.overlapped_cells ), + : contents( x.contents ), fallback( x.fallback ), width( x.width ), renditions( x.renditions ) @@ -24,9 +20,7 @@ Cell::Cell( const Cell &x ) Cell & Cell::operator=( const Cell &x ) { - overlapping_cell = x.overlapping_cell; contents = x.contents; - overlapped_cells = x.overlapped_cells; fallback = x.fallback; width = x.width; renditions = x.renditions; @@ -44,18 +38,6 @@ void Cell::reset( void ) fallback = false; width = 1; renditions.clear(); - - if ( overlapping_cell ) { - assert( overlapped_cells.size() == 0 ); - } else { - for ( std::vector::iterator i = overlapped_cells.begin(); - i != overlapped_cells.end(); - i++ ) { - (*i)->overlapping_cell = NULL; - (*i)->reset(); - } - overlapped_cells.clear(); - } } DrawState::DrawState( int s_width, int s_height ) @@ -183,20 +165,6 @@ Cell *Framebuffer::get_combining_cell( void ) return &rows[ ds.get_combining_char_row() ].cells[ ds.get_combining_char_col() ]; } -void Framebuffer::claim_overlap( int row, int col ) -{ - Cell *the_cell = &rows[ row ].cells[ col ]; - - for ( int i = col + 1; i < col + the_cell->width; i++ ) { - if ( i < ds.get_width() ) { - Cell *next_cell = get_cell( row, i ); - next_cell->reset(); - the_cell->overlapped_cells.push_back( next_cell ); - next_cell->overlapping_cell = the_cell; - } - } -} - void DrawState::set_tab( void ) { tabs[ cursor_col ] = true; @@ -319,3 +287,8 @@ void Framebuffer::delete_line( int row ) rows.erase( rows.begin() + row ); rows.insert( rows.begin() + ds.get_scrolling_region_bottom_row(), Row( ds.get_width() ) ); } + +void Row::insert_cell( int col ) +{ + cells.insert( cells.begin() + col, Cell() ); +} diff --git a/terminalframebuffer.hpp b/terminalframebuffer.hpp index 112befd..5471892 100644 --- a/terminalframebuffer.hpp +++ b/terminalframebuffer.hpp @@ -9,9 +9,7 @@ namespace Terminal { class Cell { public: - Cell *overlapping_cell; std::vector contents; - std::vector overlapped_cells; char fallback; /* first character is combining character */ int width; std::vector renditions; /* e.g., bold, blinking, etc. */ @@ -29,6 +27,9 @@ namespace Terminal { std::vector cells; Row( size_t s_width ); + + void insert_cell( int col ); + void delete_cell( int col ); }; class SavedCursor { @@ -119,7 +120,7 @@ namespace Terminal { Cell *get_combining_cell( void ); 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 ); };