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
+15 -17
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++ ) {
because Ps of 0 in that case does not mean reset to default, even int rendition = dispatch->getparam( i, 0 );
though it means that otherwise (as usually renditions are applied /* We need to special-case the handling of [34]8 ; 5 ; Ps,
in order). */ because Ps of 0 in that case does not mean reset to default, even
though it means that otherwise (as usually renditions are applied
if ( (dispatch->param_count() == 3) in order). */
&& (dispatch->getparam( 0, -1 ) == 38) if ((rendition == 38 || rendition == 48) &&
&& (dispatch->getparam( 1, -1 ) == 5) ) { (dispatch->param_count() - i >= 3) &&
fb->ds.set_foreground_color( dispatch->getparam( 2, 0 ) ); (dispatch->getparam( i+1, -1 ) == 5)) {
} else if ( (dispatch->param_count() == 3) (rendition == 38) ?
&& (dispatch->getparam( 0, -1 ) == 48) fb->ds.set_foreground_color( dispatch->getparam( i+2, 0 ) ) :
&& (dispatch->getparam( 1, -1 ) == 5) ) { fb->ds.set_background_color( dispatch->getparam( i+2, 0 ) );
fb->ds.set_background_color( dispatch->getparam( 2, 0 ) ); i += 2;
} else { continue;
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 );
} }
} }