@@ -8,7 +8,7 @@ import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
88import { NULL_CELL_CODE , WHITESPACE_CELL_CHAR , Attributes } from 'common/buffer/Constants' ;
99import { CellData } from 'common/buffer/CellData' ;
1010import { IOptionsService } from 'common/services/Services' ;
11- import { ensureContrastRatio } from 'browser/Color' ;
11+ import { ensureContrastRatio , rgbaToColor } from 'browser/Color' ;
1212import { IColorSet , IColor } from 'browser/Types' ;
1313
1414export const BOLD_CLASS = 'xterm-bold' ;
@@ -129,7 +129,14 @@ export class DomRendererRowFactory {
129129 }
130130 break ;
131131 case Attributes . CM_RGB :
132- charElement . setAttribute ( 'style' , `${ charElement . getAttribute ( 'style' ) || '' } color:#${ padStart ( fg . toString ( 16 ) , '0' , 6 ) } ;` ) ;
132+ const color = rgbaToColor (
133+ ( fg >> 16 ) & 0xFF ,
134+ ( fg >> 8 ) & 0xFF ,
135+ ( fg ) & 0xFF
136+ ) ;
137+ if ( ! this . _applyMinimumContrast ( charElement , this . _colors . background , color ) ) {
138+ this . _addStyle ( charElement , `color:#${ padStart ( fg . toString ( 16 ) , '0' , 6 ) } ` ) ;
139+ }
133140 break ;
134141 case Attributes . CM_DEFAULT :
135142 default :
@@ -147,7 +154,7 @@ export class DomRendererRowFactory {
147154 charElement . classList . add ( `xterm-bg-${ bg } ` ) ;
148155 break ;
149156 case Attributes . CM_RGB :
150- charElement . setAttribute ( 'style' , `${ charElement . getAttribute ( 'style' ) || '' } background-color:#${ padStart ( bg . toString ( 16 ) , '0' , 6 ) } ; ` ) ;
157+ this . _addStyle ( charElement , `background-color:#${ padStart ( bg . toString ( 16 ) , '0' , 6 ) } ` ) ;
151158 break ;
152159 case Attributes . CM_DEFAULT :
153160 default :
@@ -176,12 +183,16 @@ export class DomRendererRowFactory {
176183 }
177184
178185 if ( adjustedColor ) {
179- element . setAttribute ( 'style' , `${ element . getAttribute ( 'style' ) || '' } color:${ adjustedColor . css } ` ) ;
186+ this . _addStyle ( element , `color:${ adjustedColor . css } ` ) ;
180187 return true ;
181188 }
182189
183190 return false ;
184191 }
192+
193+ private _addStyle ( element : HTMLElement , style : string ) : void {
194+ element . setAttribute ( 'style' , `${ element . getAttribute ( 'style' ) || '' } ${ style } ;` ) ;
195+ }
185196}
186197
187198function padStart ( text : string , padChar : string , length : number ) : string {
0 commit comments