diff --git a/terminal.cpp b/terminal.cpp index 216d7b4..9dcffe8 100644 --- a/terminal.cpp +++ b/terminal.cpp @@ -123,6 +123,8 @@ void Emulator::Esc_dispatch( Parser::Esc_Dispatch *act ) void Emulator::debug_printout( int fd ) { + fb.back_color_erase(); + std::string screen; screen.append( "\033[H" ); diff --git a/terminalframebuffer.cpp b/terminalframebuffer.cpp index b8fde46..e6632d0 100644 --- a/terminalframebuffer.cpp +++ b/terminalframebuffer.cpp @@ -8,7 +8,8 @@ Cell::Cell() : contents(), fallback( false ), width( 1 ), - renditions() + renditions(), + need_back_color_erase( true ) {} Row::Row( size_t s_width ) @@ -21,6 +22,7 @@ void Cell::reset( void ) fallback = false; width = 1; renditions.clear(); + need_back_color_erase = true; } DrawState::DrawState( int s_width, int s_height ) @@ -247,6 +249,7 @@ std::vector DrawState::get_tabs( void ) void Framebuffer::apply_renditions_to_current_cell( void ) { + get_cell()->need_back_color_erase = false; get_cell()->renditions = ds.get_renditions(); } @@ -389,3 +392,34 @@ void DrawState::resize( int s_width, int s_height ) combining_char_col = combining_char_row = -1; } } + +int DrawState::get_background_rendition( void ) +{ + int color = 0; + for ( std::vector::iterator i = renditions.begin(); + i != renditions.end(); + i++ ) { + int r = *i; + if ( (40 <= r) && (r <= 47) ) { + color = r; + } + } + + return color; +} + +void Framebuffer::back_color_erase( void ) +{ + int bg_color = ds.get_background_rendition(); + + for ( int row = 0; row < ds.get_height(); row++ ) { + for ( int col = 0; col < ds.get_width(); col++ ) { + Cell *cell = get_cell( row, col ); + if ( cell->need_back_color_erase ) { + assert( cell->renditions.empty() ); + cell->renditions.push_back( bg_color ); + cell->need_back_color_erase = false; + } + } + } +} diff --git a/terminalframebuffer.hpp b/terminalframebuffer.hpp index 827b791..15bfe0a 100644 --- a/terminalframebuffer.hpp +++ b/terminalframebuffer.hpp @@ -14,6 +14,7 @@ namespace Terminal { char fallback; /* first character is combining character */ int width; std::vector renditions; /* e.g., bold, blinking, etc. */ + bool need_back_color_erase; Cell(); @@ -99,6 +100,7 @@ namespace Terminal { void clear_renditions( void ) { renditions.clear(); } void add_rendition( int x ) { renditions.push_back( x ); } const std::vector get_renditions( void ) { return renditions; } + int get_background_rendition( void ); void save_cursor( void ); void restore_cursor( void ); @@ -141,6 +143,8 @@ namespace Terminal { std::vector get_window_title( void ) { return window_title; } void resize( int s_width, int s_height ); + + void back_color_erase( void ); }; } diff --git a/terminalfunctions.cpp b/terminalfunctions.cpp index 62d5c42..ab144a4 100644 --- a/terminalfunctions.cpp +++ b/terminalfunctions.cpp @@ -312,6 +312,8 @@ static Function func_Ctrl_BEL( CONTROL, "\x07", Ctrl_BEL ); /* select graphics rendition -- e.g., bold, blinking, etc. */ void CSI_SGR( Framebuffer *fb, Dispatcher *dispatch ) { + fb->back_color_erase(); + for ( int i = 0; i < dispatch->param_count(); i++ ) { int rendition = dispatch->getparam( i, 0 ); if ( rendition == 0 ) {