Color support (and bold and other renditions)
This commit is contained in:
@@ -77,6 +77,7 @@ void Emulator::print( Parser::Print *act )
|
||||
this_cell->reset();
|
||||
this_cell->contents.push_back( act->ch );
|
||||
this_cell->width = chwidth;
|
||||
fb.apply_renditions_to_current_cell();
|
||||
|
||||
fb.claim_overlap( fb.ds.get_cursor_row(), fb.ds.get_cursor_col() );
|
||||
|
||||
@@ -143,6 +144,20 @@ void Emulator::debug_printout( int fd )
|
||||
assert( (cell->overlapped_cells.size() + 1 == (size_t)cell->width)
|
||||
|| (x == fb.ds.get_width() - 1) );
|
||||
|
||||
/* print renditions */
|
||||
screen.append( "\033[0" );
|
||||
char rendition[ 32 ];
|
||||
for ( std::vector<int>::iterator i = cell->renditions.begin();
|
||||
i != cell->renditions.end();
|
||||
i++ ) {
|
||||
snprintf( rendition, 32, ";%d", *i );
|
||||
screen.append( rendition );
|
||||
}
|
||||
screen.append( "m" );
|
||||
|
||||
/* print cell contents */
|
||||
|
||||
/* cells that begin with combining character get combiner attached to no-break space */
|
||||
if ( cell->fallback ) {
|
||||
char utf8[ 8 ];
|
||||
snprintf( utf8, 8, "%lc", 0xA0 );
|
||||
|
||||
+16
-2
@@ -9,7 +9,8 @@ Cell::Cell()
|
||||
contents(),
|
||||
overlapped_cells(),
|
||||
fallback( false ),
|
||||
width( 1 )
|
||||
width( 1 ),
|
||||
renditions()
|
||||
{}
|
||||
|
||||
Cell::Cell( const Cell &x )
|
||||
@@ -17,7 +18,8 @@ Cell::Cell( const Cell &x )
|
||||
contents( x.contents ),
|
||||
overlapped_cells( x.overlapped_cells ),
|
||||
fallback( x.fallback ),
|
||||
width( 1 )
|
||||
width( x.width ),
|
||||
renditions( x.renditions )
|
||||
{}
|
||||
|
||||
Cell & Cell::operator=( const Cell &x )
|
||||
@@ -26,6 +28,8 @@ Cell & Cell::operator=( const Cell &x )
|
||||
contents = x.contents;
|
||||
overlapped_cells = x.overlapped_cells;
|
||||
fallback = x.fallback;
|
||||
width = x.width;
|
||||
renditions = x.renditions;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -39,6 +43,7 @@ void Cell::reset( void )
|
||||
contents.clear();
|
||||
fallback = false;
|
||||
width = 1;
|
||||
renditions.clear();
|
||||
|
||||
if ( overlapping_cell ) {
|
||||
assert( overlapped_cells.size() == 0 );
|
||||
@@ -58,6 +63,7 @@ DrawState::DrawState( int s_width, int s_height )
|
||||
cursor_col( 0 ), cursor_row( 0 ),
|
||||
combining_char_col( 0 ), combining_char_row( 0 ), tabs( s_width ),
|
||||
scrolling_region_top_row( 0 ), scrolling_region_bottom_row( height - 1 ),
|
||||
renditions(),
|
||||
next_print_will_wrap( false ), origin_mode( false ), auto_wrap_mode( true )
|
||||
{
|
||||
for ( int i = 0; i < width; i++ ) {
|
||||
@@ -256,3 +262,11 @@ std::vector<int> DrawState::get_tabs( void )
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Framebuffer::apply_renditions_to_current_cell( void )
|
||||
{
|
||||
Cell *this_cell = get_cell();
|
||||
assert( this_cell );
|
||||
|
||||
this_cell->renditions = ds.get_renditions();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Terminal {
|
||||
std::vector<Cell *> overlapped_cells;
|
||||
char fallback; /* first character is combining character */
|
||||
int width;
|
||||
std::vector<int> renditions; /* e.g., bold, blinking, etc. */
|
||||
|
||||
Cell();
|
||||
|
||||
@@ -44,6 +45,8 @@ namespace Terminal {
|
||||
|
||||
int scrolling_region_top_row, scrolling_region_bottom_row;
|
||||
|
||||
std::vector<int> renditions;
|
||||
|
||||
public:
|
||||
bool next_print_will_wrap;
|
||||
bool origin_mode;
|
||||
@@ -75,6 +78,10 @@ namespace Terminal {
|
||||
int limit_top( void );
|
||||
int limit_bottom( void );
|
||||
|
||||
void clear_renditions( void ) { renditions.clear(); }
|
||||
void add_rendition( int x ) { renditions.push_back( x ); }
|
||||
const std::vector<int> get_renditions( void ) { return renditions; }
|
||||
|
||||
DrawState( int s_width, int s_height );
|
||||
};
|
||||
|
||||
@@ -94,6 +101,7 @@ namespace Terminal {
|
||||
Cell *get_cell( int row, int col );
|
||||
Cell *get_combining_cell( void );
|
||||
|
||||
void apply_renditions_to_current_cell( void );
|
||||
void claim_overlap( int row, int col );
|
||||
};
|
||||
}
|
||||
|
||||
@@ -259,3 +259,18 @@ void Ctrl_BEL( Framebuffer *fb __attribute((unused)), Dispatcher *dispatch __att
|
||||
{}
|
||||
|
||||
static Function func_Ctrl_BEL( CONTROL, "\x07", Ctrl_BEL );
|
||||
|
||||
/* select graphics rendition -- e.g., bold, blinking, etc. */
|
||||
void CSI_SGR( Framebuffer *fb, Dispatcher *dispatch )
|
||||
{
|
||||
for ( int i = 0; i < dispatch->param_count(); i++ ) {
|
||||
int rendition = dispatch->getparam( i, 0 );
|
||||
if ( rendition == 0 ) {
|
||||
fb->ds.clear_renditions();
|
||||
} else {
|
||||
fb->ds.add_rendition( rendition );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Function func_CSI_SGR( CSI, "m", CSI_SGR );
|
||||
|
||||
Reference in New Issue
Block a user