issue #507: fix/simplify parsing of colors

This commit is contained in:
John Hood
2014-09-15 00:28:28 -04:00
parent fb97e54b2f
commit 67c22e5065
+12 -14
View File
@@ -380,24 +380,22 @@ static Function func_Ctrl_BEL( CONTROL, "\x07", Ctrl_BEL );
/* select graphics rendition -- e.g., bold, blinking, etc. */ /* select graphics rendition -- e.g., bold, blinking, etc. */
static void CSI_SGR( Framebuffer *fb, Dispatcher *dispatch ) static void CSI_SGR( Framebuffer *fb, Dispatcher *dispatch )
{ {
/* We need to special-case the handling of CSI [34]8 ; 5 ; Ps m, for ( int i = 0; i < dispatch->param_count(); i++ ) {
int rendition = dispatch->getparam( i, 0 );
/* We need to special-case the handling of [34]8 ; 5 ; Ps,
because Ps of 0 in that case does not mean reset to default, even because Ps of 0 in that case does not mean reset to default, even
though it means that otherwise (as usually renditions are applied though it means that otherwise (as usually renditions are applied
in order). */ in order). */
if ((rendition == 38 || rendition == 48) &&
if ( (dispatch->param_count() == 3) (dispatch->param_count() - i >= 3) &&
&& (dispatch->getparam( 0, -1 ) == 38) (dispatch->getparam( i+1, -1 ) == 5)) {
&& (dispatch->getparam( 1, -1 ) == 5) ) { (rendition == 38) ?
fb->ds.set_foreground_color( dispatch->getparam( 2, 0 ) ); fb->ds.set_foreground_color( dispatch->getparam( i+2, 0 ) ) :
} else if ( (dispatch->param_count() == 3) fb->ds.set_background_color( dispatch->getparam( i+2, 0 ) );
&& (dispatch->getparam( 0, -1 ) == 48) i += 2;
&& (dispatch->getparam( 1, -1 ) == 5) ) { continue;
fb->ds.set_background_color( dispatch->getparam( 2, 0 ) );
} else {
for ( int i = 0; i < dispatch->param_count(); i++ ) {
int rendition = dispatch->getparam( i, 0 );
fb->ds.add_rendition( rendition );
} }
fb->ds.add_rendition( rendition );
} }
} }