Move grapheme printing from FrameState::append_cell() to Framebuffer::Cell::print_grapheme().

This commit is contained in:
John Hood
2015-10-19 18:40:24 -04:00
parent 0b51260540
commit 66634eb97c
3 changed files with 18 additions and 16 deletions
-15
View File
@@ -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;
+1 -1
View File
@@ -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 );
+17
View File
@@ -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 {