This commit is contained in:
Keith Winstein
2011-02-05 07:16:33 -05:00
parent 9b02204d72
commit 2f964f80f4
3 changed files with 38 additions and 67 deletions
+1 -61
View File
@@ -4,18 +4,6 @@
using namespace Terminal; using namespace Terminal;
Cell::Cell()
: contents(),
fallback( false ),
width( 1 ),
renditions(),
need_back_color_erase( true )
{}
Row::Row( size_t s_width )
: cells( s_width )
{}
void Cell::reset( void ) void Cell::reset( void )
{ {
contents.clear(); contents.clear();
@@ -25,17 +13,6 @@ void Cell::reset( void )
need_back_color_erase = true; need_back_color_erase = true;
} }
bool Cell::operator==( const Cell &x )
{
assert( !need_back_color_erase );
assert( !x.need_back_color_erase );
return ( (contents == x.contents)
&& (fallback == x.fallback)
&& (width == x.width)
&& (renditions == x.renditions) );
}
DrawState::DrawState( int s_width, int s_height ) DrawState::DrawState( int s_width, int s_height )
: width( s_width ), height( s_height ), : width( s_width ), height( s_height ),
cursor_col( 0 ), cursor_row( 0 ), cursor_col( 0 ), cursor_row( 0 ),
@@ -144,43 +121,6 @@ void Framebuffer::move_rows_autoscroll( int rows )
ds.move_row( rows, true ); ds.move_row( rows, true );
} }
Cell *Framebuffer::get_cell( void )
{
assert( ds.get_width() );
assert( ds.get_height() );
assert( ds.get_cursor_row() < ds.get_height() );
assert( ds.get_cursor_col() < ds.get_width() );
assert( ds.get_cursor_row() >= 0 );
assert( ds.get_cursor_col() >= 0 );
assert( rows.size() == (size_t)ds.get_height() );
assert( rows[ ds.get_cursor_row() ].cells.size() == (size_t)ds.get_width() );
return &rows[ ds.get_cursor_row() ].cells[ ds.get_cursor_col() ];
}
Cell *Framebuffer::get_cell( int row, int col )
{
if ( row == -1 ) row = ds.get_cursor_row();
if ( col == -1 ) col = ds.get_cursor_col();
assert( ds.get_width() );
assert( ds.get_height() );
assert( row < ds.get_height() );
assert( col < ds.get_width() );
assert( row >= 0 );
assert( col >= 0 );
assert( rows.size() == (size_t)ds.get_height() );
assert( rows[ row ].cells.size() == (size_t)ds.get_width() );
return &rows[ row ].cells[ col ];
}
Cell *Framebuffer::get_combining_cell( void ) Cell *Framebuffer::get_combining_cell( void )
{ {
if ( (ds.get_combining_char_col() < 0) if ( (ds.get_combining_char_col() < 0)
@@ -427,7 +367,7 @@ void Framebuffer::back_color_erase( void )
for ( int col = 0; col < ds.get_width(); col++ ) { for ( int col = 0; col < ds.get_width(); col++ ) {
Cell *cell = get_cell( row, col ); Cell *cell = get_cell( row, col );
if ( cell->need_back_color_erase ) { if ( cell->need_back_color_erase ) {
assert( cell->renditions.empty() ); // assert( cell->renditions.empty() );
if ( bg_color > 0 ) { if ( bg_color > 0 ) {
cell->renditions.push_back( bg_color ); cell->renditions.push_back( bg_color );
} }
+30 -5
View File
@@ -17,18 +17,32 @@ namespace Terminal {
std::list<int> renditions; /* e.g., bold, blinking, etc. */ std::list<int> renditions; /* e.g., bold, blinking, etc. */
bool need_back_color_erase; bool need_back_color_erase;
Cell(); Cell()
: contents(),
fallback( false ),
width( 1 ),
renditions(),
need_back_color_erase( true )
{}
void reset( void ); void reset( void );
bool operator==( const Cell &x ); inline bool operator==( const Cell &x )
{
return ( (contents == x.contents)
&& (fallback == x.fallback)
&& (width == x.width)
&& (renditions == x.renditions) );
}
}; };
class Row { class Row {
public: public:
std::vector<Cell> cells; std::vector<Cell> cells;
Row( size_t s_width ); Row( size_t s_width )
: cells( s_width )
{}
void insert_cell( int col ); void insert_cell( int col );
void delete_cell( int col ); void delete_cell( int col );
@@ -127,8 +141,19 @@ namespace Terminal {
void move_rows_autoscroll( int rows ); void move_rows_autoscroll( int rows );
Cell *get_cell( void ); inline Cell *get_cell( void )
Cell *get_cell( int row, int col ); {
return &rows[ ds.get_cursor_row() ].cells[ ds.get_cursor_col() ];
}
inline Cell *get_cell( int row, int col )
{
if ( row == -1 ) row = ds.get_cursor_row();
if ( col == -1 ) col = ds.get_cursor_col();
return &rows[ row ].cells[ col ];
}
Cell *get_combining_cell( void ); Cell *get_combining_cell( void );
void apply_renditions_to_current_cell( void ); void apply_renditions_to_current_cell( void );
+7 -1
View File
@@ -312,10 +312,16 @@ static Function func_Ctrl_BEL( CONTROL, "\x07", Ctrl_BEL );
/* select graphics rendition -- e.g., bold, blinking, etc. */ /* select graphics rendition -- e.g., bold, blinking, etc. */
void CSI_SGR( Framebuffer *fb, Dispatcher *dispatch ) void CSI_SGR( Framebuffer *fb, Dispatcher *dispatch )
{ {
fb->back_color_erase(); bool bce = false;
for ( int i = 0; i < dispatch->param_count(); i++ ) { for ( int i = 0; i < dispatch->param_count(); i++ ) {
int rendition = dispatch->getparam( i, 0 ); int rendition = dispatch->getparam( i, 0 );
if ( (40 <= rendition) && (rendition <= 49) && (!bce) ) {
/* we're changing the background color */
fb->back_color_erase();
bce = true;
}
if ( rendition == 0 ) { if ( rendition == 0 ) {
fb->ds.clear_renditions(); fb->ds.clear_renditions();
} else { } else {