Describe Cell width as a narrow/wide boolean.
A character cell can only be either narrow or wide. It's more convenient to represent that as an int containing 1 or 2, but slightly more correct to represent it as a "boolean" single-bit integer.
This commit is contained in:
@@ -280,7 +280,7 @@ void NotificationEngine::apply( Framebuffer &fb ) const
|
|||||||
this_cell->get_renditions().background_color = 44;
|
this_cell->get_renditions().background_color = 44;
|
||||||
|
|
||||||
this_cell->append( ch );
|
this_cell->append( ch );
|
||||||
this_cell->set_width( chwidth );
|
this_cell->set_wide( chwidth == 2 );
|
||||||
combining_cell = this_cell;
|
combining_cell = this_cell;
|
||||||
|
|
||||||
overlay_col += chwidth;
|
overlay_col += chwidth;
|
||||||
@@ -291,7 +291,7 @@ void NotificationEngine::apply( Framebuffer &fb ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( combining_cell->empty() ) {
|
if ( combining_cell->empty() ) {
|
||||||
assert( combining_cell->get_width() == 1 );
|
assert( !combining_cell->get_wide() );
|
||||||
combining_cell->set_fallback( true );
|
combining_cell->set_fallback( true );
|
||||||
overlay_col++;
|
overlay_col++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ void Emulator::print( const Parser::Print *act )
|
|||||||
|
|
||||||
fb.reset_cell( this_cell );
|
fb.reset_cell( this_cell );
|
||||||
this_cell->append( ch );
|
this_cell->append( ch );
|
||||||
this_cell->set_width( chwidth );
|
this_cell->set_wide( chwidth == 2 ); /* chwidth had better be 1 or 2 here */
|
||||||
fb.apply_renditions_to_cell( this_cell );
|
fb.apply_renditions_to_cell( this_cell );
|
||||||
|
|
||||||
if ( chwidth == 2 ) { /* erase overlapped cell */
|
if ( chwidth == 2 ) { /* erase overlapped cell */
|
||||||
@@ -131,7 +131,7 @@ void Emulator::print( const Parser::Print *act )
|
|||||||
base character [e.g. start of line], if the
|
base character [e.g. start of line], if the
|
||||||
combining character has been cleared with
|
combining character has been cleared with
|
||||||
a sequence like ED ("J") or EL ("K") */
|
a sequence like ED ("J") or EL ("K") */
|
||||||
assert( combining_cell->get_width() == 1 );
|
assert( !combining_cell->get_wide() );
|
||||||
combining_cell->set_fallback( true );
|
combining_cell->set_fallback( true );
|
||||||
fb.ds.move_col( 1, true, true );
|
fb.ds.move_col( 1, true, true );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,14 +41,14 @@ using namespace Terminal;
|
|||||||
Cell::Cell( color_type background_color )
|
Cell::Cell( color_type background_color )
|
||||||
: contents(),
|
: contents(),
|
||||||
renditions( background_color ),
|
renditions( background_color ),
|
||||||
width( 1 ),
|
wide( false ),
|
||||||
fallback( false ),
|
fallback( false ),
|
||||||
wrap( false )
|
wrap( false )
|
||||||
{}
|
{}
|
||||||
Cell::Cell() /* default constructor required by C++11 STL */
|
Cell::Cell() /* default constructor required by C++11 STL */
|
||||||
: contents(),
|
: contents(),
|
||||||
renditions( 0 ),
|
renditions( 0 ),
|
||||||
width( 1 ),
|
wide( false ),
|
||||||
fallback( false ),
|
fallback( false ),
|
||||||
wrap( false )
|
wrap( false )
|
||||||
{
|
{
|
||||||
@@ -59,7 +59,7 @@ void Cell::reset( color_type background_color )
|
|||||||
{
|
{
|
||||||
contents.clear();
|
contents.clear();
|
||||||
renditions = Renditions( background_color );
|
renditions = Renditions( background_color );
|
||||||
width = 1;
|
wide = false;
|
||||||
fallback = false;
|
fallback = false;
|
||||||
wrap = false;
|
wrap = false;
|
||||||
}
|
}
|
||||||
@@ -642,10 +642,10 @@ bool Cell::compare( const Cell &other ) const
|
|||||||
fallback, other.fallback );
|
fallback, other.fallback );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( width != other.width ) {
|
if ( wide != other.wide ) {
|
||||||
ret = true;
|
ret = true;
|
||||||
fprintf( stderr, "width: %d vs. %d\n",
|
fprintf( stderr, "width: %d vs. %d\n",
|
||||||
width, other.width );
|
wide, other.wide );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !(renditions == other.renditions) ) {
|
if ( !(renditions == other.renditions) ) {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace Terminal {
|
|||||||
typedef std::string content_type; /* can be std::string, std::vector<uint8_t>, or __gnu_cxx::__vstring */
|
typedef std::string content_type; /* can be std::string, std::vector<uint8_t>, or __gnu_cxx::__vstring */
|
||||||
content_type contents;
|
content_type contents;
|
||||||
Renditions renditions;
|
Renditions renditions;
|
||||||
unsigned int width : 2;
|
unsigned int wide : 1; /* 0 = narrow, 1 = wide */
|
||||||
unsigned int fallback : 1; /* first character is combining character */
|
unsigned int fallback : 1; /* first character is combining character */
|
||||||
unsigned int wrap : 1;
|
unsigned int wrap : 1;
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ namespace Terminal {
|
|||||||
{
|
{
|
||||||
return ( (contents == x.contents)
|
return ( (contents == x.contents)
|
||||||
&& (fallback == x.fallback)
|
&& (fallback == x.fallback)
|
||||||
&& (width == x.width)
|
&& (wide == x.wide)
|
||||||
&& (renditions == x.renditions)
|
&& (renditions == x.renditions)
|
||||||
&& (wrap == x.wrap) );
|
&& (wrap == x.wrap) );
|
||||||
}
|
}
|
||||||
@@ -190,8 +190,9 @@ namespace Terminal {
|
|||||||
const Renditions& get_renditions( void ) const { return renditions; }
|
const Renditions& get_renditions( void ) const { return renditions; }
|
||||||
Renditions& get_renditions( void ) { return renditions; }
|
Renditions& get_renditions( void ) { return renditions; }
|
||||||
void set_renditions( const Renditions& r ) { renditions = r; }
|
void set_renditions( const Renditions& r ) { renditions = r; }
|
||||||
unsigned int get_width( void ) const { return width; }
|
bool get_wide( void ) const { return wide; }
|
||||||
void set_width( unsigned int w ) { width = w; }
|
void set_wide( bool w ) { wide = w; }
|
||||||
|
unsigned int get_width( void ) const { return wide + 1; }
|
||||||
bool get_fallback( void ) const { return fallback; }
|
bool get_fallback( void ) const { return fallback; }
|
||||||
void set_fallback( bool f ) { fallback = f; }
|
void set_fallback( bool f ) { fallback = f; }
|
||||||
bool get_wrap( void ) const { return wrap; }
|
bool get_wrap( void ) const { return wrap; }
|
||||||
|
|||||||
Reference in New Issue
Block a user