Move grapheme printing from FrameState::append_cell() to Framebuffer::Cell::print_grapheme().
This commit is contained in:
@@ -462,21 +462,6 @@ FrameState::FrameState( const Framebuffer &s_last )
|
||||
str.reserve( last_frame.ds.get_width() * last_frame.ds.get_height() * 4 );
|
||||
}
|
||||
|
||||
/* Write a character cell */
|
||||
void FrameState::append_cell(const Cell & cell)
|
||||
{
|
||||
if ( cell.contents.empty() ) {
|
||||
append( ' ' );
|
||||
return;
|
||||
}
|
||||
/* cells that begin with combining character get combiner attached to no-break space */
|
||||
if ( cell.fallback ) {
|
||||
append( "\xC2\xA0" );
|
||||
}
|
||||
append( cell.contents );
|
||||
}
|
||||
|
||||
|
||||
void FrameState::append_silent_move( int y, int x )
|
||||
{
|
||||
if ( cursor_x == x && cursor_y == y ) return;
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Terminal {
|
||||
void append( const Cell::content_type &contents ) { str.append( contents.begin(), contents.end() ); }
|
||||
void append_string( const std::string &append ) { str.append(append); }
|
||||
|
||||
void append_cell(const Cell & cell);
|
||||
void append_cell(const Cell & cell) { cell.print_grapheme( str ); }
|
||||
void append_silent_move( int y, int x );
|
||||
void append_move( int y, int x );
|
||||
void update_rendition( const Renditions &r, bool force = false );
|
||||
|
||||
@@ -113,6 +113,7 @@ namespace Terminal {
|
||||
|
||||
bool is_blank( void ) const
|
||||
{
|
||||
// XXX fix.
|
||||
return ( contents.empty()
|
||||
|| contents == " "
|
||||
|| contents == "\xC2\xA0" );
|
||||
@@ -161,6 +162,22 @@ namespace Terminal {
|
||||
size_t len = wcrtomb(tmp, c, &ps);
|
||||
contents.insert( contents.end(), tmp, tmp+len );
|
||||
}
|
||||
|
||||
void print_grapheme( std::string &output ) const
|
||||
{
|
||||
if ( cell.contents.empty() ) {
|
||||
output.append( ' ' );
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* cells that begin with combining character get combiner
|
||||
* attached to no-break space
|
||||
*/
|
||||
if ( cell.fallback ) {
|
||||
output.append( "\xC2\xA0" );
|
||||
}
|
||||
output.append( cell.contents );
|
||||
}
|
||||
};
|
||||
|
||||
class Row {
|
||||
|
||||
Reference in New Issue
Block a user