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:
@@ -106,7 +106,7 @@ void Emulator::print( const Parser::Print *act )
|
||||
|
||||
fb.reset_cell( this_cell );
|
||||
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 );
|
||||
|
||||
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
|
||||
combining character has been cleared with
|
||||
a sequence like ED ("J") or EL ("K") */
|
||||
assert( combining_cell->get_width() == 1 );
|
||||
assert( !combining_cell->get_wide() );
|
||||
combining_cell->set_fallback( true );
|
||||
fb.ds.move_col( 1, true, true );
|
||||
}
|
||||
|
||||
@@ -41,14 +41,14 @@ using namespace Terminal;
|
||||
Cell::Cell( color_type background_color )
|
||||
: contents(),
|
||||
renditions( background_color ),
|
||||
width( 1 ),
|
||||
wide( false ),
|
||||
fallback( false ),
|
||||
wrap( false )
|
||||
{}
|
||||
Cell::Cell() /* default constructor required by C++11 STL */
|
||||
: contents(),
|
||||
renditions( 0 ),
|
||||
width( 1 ),
|
||||
wide( false ),
|
||||
fallback( false ),
|
||||
wrap( false )
|
||||
{
|
||||
@@ -59,7 +59,7 @@ void Cell::reset( color_type background_color )
|
||||
{
|
||||
contents.clear();
|
||||
renditions = Renditions( background_color );
|
||||
width = 1;
|
||||
wide = false;
|
||||
fallback = false;
|
||||
wrap = false;
|
||||
}
|
||||
@@ -642,10 +642,10 @@ bool Cell::compare( const Cell &other ) const
|
||||
fallback, other.fallback );
|
||||
}
|
||||
|
||||
if ( width != other.width ) {
|
||||
if ( wide != other.wide ) {
|
||||
ret = true;
|
||||
fprintf( stderr, "width: %d vs. %d\n",
|
||||
width, other.width );
|
||||
wide, other.wide );
|
||||
}
|
||||
|
||||
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 */
|
||||
content_type contents;
|
||||
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 wrap : 1;
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Terminal {
|
||||
{
|
||||
return ( (contents == x.contents)
|
||||
&& (fallback == x.fallback)
|
||||
&& (width == x.width)
|
||||
&& (wide == x.wide)
|
||||
&& (renditions == x.renditions)
|
||||
&& (wrap == x.wrap) );
|
||||
}
|
||||
@@ -190,8 +190,9 @@ namespace Terminal {
|
||||
const Renditions& get_renditions( void ) const { return renditions; }
|
||||
Renditions& get_renditions( void ) { return renditions; }
|
||||
void set_renditions( const Renditions& r ) { renditions = r; }
|
||||
unsigned int get_width( void ) const { return width; }
|
||||
void set_width( unsigned int w ) { width = w; }
|
||||
bool get_wide( void ) const { return wide; }
|
||||
void set_wide( bool w ) { wide = w; }
|
||||
unsigned int get_width( void ) const { return wide + 1; }
|
||||
bool get_fallback( void ) const { return fallback; }
|
||||
void set_fallback( bool f ) { fallback = f; }
|
||||
bool get_wrap( void ) const { return wrap; }
|
||||
|
||||
Reference in New Issue
Block a user