Simplify display output and fix bug with bce status
This commit is contained in:
+16
-35
@@ -49,19 +49,18 @@ std::string Display::new_frame( Framebuffer &f )
|
|||||||
/* iterate for every cell */
|
/* iterate for every cell */
|
||||||
for ( int y = 0; y < f.ds.get_height(); y++ ) {
|
for ( int y = 0; y < f.ds.get_height(); y++ ) {
|
||||||
for ( int x = 0; x < f.ds.get_width(); /* let charwidth handle advance */ ) {
|
for ( int x = 0; x < f.ds.get_width(); /* let charwidth handle advance */ ) {
|
||||||
std::string cell_string;
|
|
||||||
Cell *cell = f.get_cell( y, x );
|
Cell *cell = f.get_cell( y, x );
|
||||||
bool different = false;
|
|
||||||
|
if ( initialized
|
||||||
|
&& ( *cell == *(last_frame.get_cell( y, x )) ) ) {
|
||||||
|
x += cell->width;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
char curmove[ 32 ];
|
char curmove[ 32 ];
|
||||||
snprintf( curmove, 32, "\033[%d;%dH", y + 1, x + 1 );
|
snprintf( curmove, 32, "\033[%d;%dH", y + 1, x + 1 );
|
||||||
cell_string.append( curmove );
|
screen.append( curmove );
|
||||||
|
cursor_was_moved = true;
|
||||||
/* have renditions changed? */
|
|
||||||
if ( (!initialized)
|
|
||||||
|| (cell->renditions != last_frame.get_cell( y, x )->renditions) ) {
|
|
||||||
different = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<int> cell_print_renditions;
|
std::vector<int> cell_print_renditions;
|
||||||
cell_print_renditions = cell->renditions;
|
cell_print_renditions = cell->renditions;
|
||||||
@@ -69,53 +68,35 @@ std::string Display::new_frame( Framebuffer &f )
|
|||||||
|
|
||||||
if ( cell_print_renditions != current_renditions ) {
|
if ( cell_print_renditions != current_renditions ) {
|
||||||
/* print renditions */
|
/* print renditions */
|
||||||
cell_string.append( "\033[0" );
|
screen.append( "\033[0" );
|
||||||
char rendition[ 32 ];
|
char rendition[ 32 ];
|
||||||
for ( std::vector<int>::iterator i = cell->renditions.begin();
|
for ( std::vector<int>::iterator i = cell->renditions.begin();
|
||||||
i != cell->renditions.end();
|
i != cell->renditions.end();
|
||||||
i++ ) {
|
i++ ) {
|
||||||
snprintf( rendition, 32, ";%d", *i );
|
snprintf( rendition, 32, ";%d", *i );
|
||||||
cell_string.append( rendition );
|
screen.append( rendition );
|
||||||
}
|
}
|
||||||
cell_string.append( "m" );
|
screen.append( "m" );
|
||||||
|
|
||||||
|
current_renditions = cell_print_renditions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear cell */
|
/* clear cell */
|
||||||
cell_string.append( "\033[X" );
|
screen.append( "\033[X" );
|
||||||
|
|
||||||
/* did fallback status change? */
|
|
||||||
if ( (!initialized)
|
|
||||||
|| (cell->fallback != last_frame.get_cell( y, x )->fallback) ) {
|
|
||||||
different = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cells that begin with combining character get combiner attached to no-break space */
|
/* cells that begin with combining character get combiner attached to no-break space */
|
||||||
if ( cell->fallback ) {
|
if ( cell->fallback ) {
|
||||||
char utf8[ 8 ];
|
char utf8[ 8 ];
|
||||||
snprintf( utf8, 8, "%lc", 0xA0 );
|
snprintf( utf8, 8, "%lc", 0xA0 );
|
||||||
cell_string.append( utf8 );
|
screen.append( utf8 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* have cell contents changed? */
|
|
||||||
if ( (!initialized)
|
|
||||||
|| (cell->contents != last_frame.get_cell( y, x )->contents) ) {
|
|
||||||
different = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* always restrike the cell contents if anything changed */
|
|
||||||
for ( std::vector<wchar_t>::iterator i = cell->contents.begin();
|
for ( std::vector<wchar_t>::iterator i = cell->contents.begin();
|
||||||
i != cell->contents.end();
|
i != cell->contents.end();
|
||||||
i++ ) {
|
i++ ) {
|
||||||
char utf8[ 8 ];
|
char utf8[ 8 ];
|
||||||
snprintf( utf8, 8, "%lc", *i );
|
snprintf( utf8, 8, "%lc", *i );
|
||||||
cell_string.append( utf8 );
|
screen.append( utf8 );
|
||||||
}
|
|
||||||
|
|
||||||
/* if anything changed, redo cell */
|
|
||||||
if ( different ) {
|
|
||||||
screen.append( cell_string );
|
|
||||||
cursor_was_moved = true;
|
|
||||||
current_renditions = cell_print_renditions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
x += cell->width;
|
x += cell->width;
|
||||||
|
|||||||
+14
-5
@@ -25,6 +25,17 @@ 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 ),
|
||||||
@@ -412,16 +423,14 @@ void Framebuffer::back_color_erase( void )
|
|||||||
{
|
{
|
||||||
int bg_color = ds.get_background_rendition();
|
int bg_color = ds.get_background_rendition();
|
||||||
|
|
||||||
if ( bg_color < 0 ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( int row = 0; row < ds.get_height(); row++ ) {
|
for ( int row = 0; row < ds.get_height(); row++ ) {
|
||||||
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() );
|
||||||
cell->renditions.push_back( bg_color );
|
if ( bg_color > 0 ) {
|
||||||
|
cell->renditions.push_back( bg_color );
|
||||||
|
}
|
||||||
cell->need_back_color_erase = false;
|
cell->need_back_color_erase = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ namespace Terminal {
|
|||||||
Cell();
|
Cell();
|
||||||
|
|
||||||
void reset( void );
|
void reset( void );
|
||||||
|
|
||||||
|
bool operator==( const Cell &x );
|
||||||
};
|
};
|
||||||
|
|
||||||
class Row {
|
class Row {
|
||||||
|
|||||||
Reference in New Issue
Block a user