diff --git a/src/terminal/terminal.cc b/src/terminal/terminal.cc index 4db42fa..18e9cdf 100644 --- a/src/terminal/terminal.cc +++ b/src/terminal/terminal.cc @@ -57,7 +57,7 @@ void Emulator::print( const Parser::Print *act ) case 1: /* normal character */ case 2: /* wide character */ if ( fb.ds.auto_wrap_mode && fb.ds.next_print_will_wrap ) { - fb.get_mutable_row( -1 )->wrap = true; + fb.get_mutable_row( -1 )->set_wrap( true ); fb.ds.move_col( 0 ); fb.move_rows_autoscroll( 1 ); } @@ -67,7 +67,7 @@ void Emulator::print( const Parser::Print *act ) && (chwidth == 2) && (fb.ds.get_cursor_col() == fb.ds.get_width() - 1) ) { fb.reset_cell( this_cell ); - fb.get_mutable_row( -1 )->wrap = false; + fb.get_mutable_row( -1 )->set_wrap( false ); /* There doesn't seem to be a consistent way to get the downstream terminal emulator to set the wrap-around copy-and-paste flag on a row that ends with an empty cell diff --git a/src/terminal/terminaldisplay.cc b/src/terminal/terminaldisplay.cc index 92f92d1..dd1bfab 100644 --- a/src/terminal/terminaldisplay.cc +++ b/src/terminal/terminaldisplay.cc @@ -175,8 +175,8 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const if ( (frame.cursor_x >= f.ds.get_width()) && (frame.y < f.ds.get_height() - 1) - && f.get_row( frame.y )->wrap - && (!initialized || !frame.last_frame.get_row( frame.y )->wrap) ) { + && f.get_row( frame.y )->get_wrap() + && (!initialized || !frame.last_frame.get_row( frame.y )->get_wrap()) ) { /* next write will wrap */ frame.cursor_x = 0; frame.cursor_y++; @@ -185,8 +185,8 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const /* Turn off wrap */ if ( (frame.y < f.ds.get_height() - 1) - && (!f.get_row( frame.y )->wrap) - && (!initialized || frame.last_frame.get_row( frame.y )->wrap) ) { + && (!f.get_row( frame.y )->get_wrap()) + && (!initialized || frame.last_frame.get_row( frame.y )->get_wrap()) ) { frame.x = last_x; if ( initialized ) { frame.last_frame.reset_cell( frame.last_frame.get_mutable_cell( frame.y, frame.x ) ); diff --git a/src/terminal/terminalframebuffer.cc b/src/terminal/terminalframebuffer.cc index 22a3880..efb574d 100644 --- a/src/terminal/terminalframebuffer.cc +++ b/src/terminal/terminalframebuffer.cc @@ -30,6 +30,7 @@ void Cell::reset( int background_color ) fallback = false; width = 1; renditions = Renditions( background_color ); + wrap = false; } DrawState::DrawState( int s_width, int s_height ) @@ -339,7 +340,8 @@ void Framebuffer::resize( int s_width, int s_height ) for ( std::deque::iterator i = rows.begin(); i != rows.end(); i++ ) { - (*i).cells.resize( s_width, Cell( ds.get_background_rendition() ) ); + i->set_wrap( false ); + i->cells.resize( s_width, Cell( ds.get_background_rendition() ) ); } ds.resize( s_width, s_height ); diff --git a/src/terminal/terminalframebuffer.h b/src/terminal/terminalframebuffer.h index 74f605f..f2215e3 100644 --- a/src/terminal/terminalframebuffer.h +++ b/src/terminal/terminalframebuffer.h @@ -57,19 +57,22 @@ namespace Terminal { char fallback; /* first character is combining character */ int width; Renditions renditions; + bool wrap; /* if last cell, wrap to next line */ Cell( int background_color ) : contents(), fallback( false ), width( 1 ), - renditions( background_color ) + renditions( background_color ), + wrap( false ) {} Cell() /* default constructor required by C++11 STL */ : contents(), fallback( false ), width( 1 ), - renditions( 0 ) + renditions( 0 ), + wrap( false ) { assert( false ); } @@ -81,7 +84,8 @@ namespace Terminal { return ( (contents == x.contents) && (fallback == x.fallback) && (width == x.width) - && (renditions == x.renditions) ); + && (renditions == x.renditions) + && (wrap == x.wrap) ); } wchar_t debug_contents( void ) const; @@ -97,14 +101,13 @@ namespace Terminal { class Row { public: std::vector cells; - bool wrap; Row( size_t s_width, int background_color ) - : cells( s_width, Cell( background_color ) ), wrap( false ) + : cells( s_width, Cell( background_color ) ) {} Row() /* default constructor required by C++11 STL */ - : cells( 1, Cell() ), wrap( false ) + : cells( 1, Cell() ) { assert( false ); } @@ -116,8 +119,11 @@ namespace Terminal { bool operator==( const Row &x ) const { - return ( (cells == x.cells) && (wrap == x.wrap) ); + return ( cells == x.cells ); } + + bool get_wrap( void ) const { return cells.back().wrap; } + void set_wrap( bool w ) { cells.back().wrap = w; } }; class SavedCursor {