From: Thomas Csovcsity <thc.fr13nd@gmail.com> add simple RGB24 to 3bit RGB --- programs/conhost/conhost.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 2d4c7f1c011..de0f239f204 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -2125,7 +2125,7 @@ static unsigned int next_csi_sgr_argument(const WCHAR *seq, size_t len, unsigned } value = 10 * value + seq[i]-'0'; } - return i; + return 0; } static void process_csi_sequence_console( struct screen_buffer *screen_buffer, const WCHAR *seq, size_t len ) @@ -2148,7 +2148,7 @@ static void process_csi_sequence_console( struct screen_buffer *screen_buffer, c { len -= seq_len; seq += seq_len; - info_params.info.attr = ( info_params.info.attr & 0xff00 ) | colors[*arg-30]; + info_params.info.attr = ( info_params.info.attr & 0xf0 ) | colors[*arg-30]; break; } case 38: @@ -2158,6 +2158,7 @@ static void process_csi_sequence_console( struct screen_buffer *screen_buffer, c seq_len = next_csi_sgr_argument(seq, len, arg); if ( *arg == 2 ) { + int color = BLACK; len -= seq_len; seq += seq_len; seq_len = next_csi_sgr_argument(seq, len, &r); @@ -2169,8 +2170,14 @@ static void process_csi_sequence_console( struct screen_buffer *screen_buffer, c seq_len = next_csi_sgr_argument(seq, len, &b); len -= seq_len; seq += seq_len; - FIXME("24bit rgb is not supported yet for foreground r[%d]g[%d]b[%d]\n", r, g, b); - info_params.info.attr = ( BLACK < 8 ) | ( WHITE ); /* Fixme set correct color */ + /* a simple color mapping for basic support */ + if ( r > 127 ) + color |= RED; + if ( g > 127 ) + color |= GREEN; + if ( b > 127 ) + color |= BLUE; + info_params.info.attr = ( info_params.info.attr & 0xf0 ) | color; } if ( *arg == 5 ) { @@ -2179,7 +2186,7 @@ static void process_csi_sequence_console( struct screen_buffer *screen_buffer, c seq_len = next_csi_sgr_argument(seq, len, arg); len -= seq_len; seq += seq_len; - info_params.info.attr = ( info_params.info.attr & 0xff00 ) | colors[*arg]; + info_params.info.attr = ( info_params.info.attr & 0xf0 ) | colors[*arg]; } break; } @@ -2204,6 +2211,7 @@ static void process_csi_sequence_console( struct screen_buffer *screen_buffer, c seq_len = next_csi_sgr_argument(seq, len, arg); if ( *arg == 2 ) { + int color = BLACK; len -= seq_len; seq += seq_len; seq_len = next_csi_sgr_argument(seq, len, &r); @@ -2215,8 +2223,15 @@ static void process_csi_sequence_console( struct screen_buffer *screen_buffer, c seq_len = next_csi_sgr_argument(seq, len, &b); len -= seq_len; seq += seq_len; - FIXME("24bit rgb is not supported yet for background r[%d]g[%d]b[%d]\n", r, g, b); - info_params.info.attr = ( BLACK < 4 ) | ( WHITE ); /* Fixme set correct color */ + /* a simple color mapping for basic support */ + if ( r > 127 ) + color |= RED; + if ( g > 127 ) + color |= GREEN; + if ( b > 127 ) + color |= BLUE; + info_params.info.attr = ( info_params.info.attr & 0x0f ) | ( color << 4 ); + } if ( *arg == 5 ) { @@ -2316,6 +2331,7 @@ static NTSTATUS write_console( struct screen_buffer *screen_buffer, const WCHAR else { ERR("Invalid CSI start sequence\n"); + ERR( "%s\n", debugstr_wn(buffer, len) ); break; } /* intermediate bytes 0x30 - 0x3f (0-?) */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9973