7
7
8
8
import { Terminal , ITerminalAddon , IBuffer , IBufferCell , IBufferRange } from 'xterm' ;
9
9
import { IColorSet } from 'browser/Types' ;
10
- import { IAttributeData , IColor } from 'common/Types' ;
11
- import { DEFAULT_ANSI_COLORS } from 'browser/services/ThemeService' ;
10
+ import { IAttributeData } from 'common/Types' ;
12
11
13
12
function constrain ( value : number , low : number , high : number ) : number {
14
13
return Math . max ( low , Math . min ( value , high ) ) ;
@@ -535,7 +534,7 @@ export class HTMLSerializeHandler extends BaseSerializeHandler {
535
534
536
535
private _htmlContent = '' ;
537
536
538
- private _ansiColors : Readonly < IColor [ ] > ;
537
+ private _colors : IColorSet ;
539
538
540
539
constructor (
541
540
buffer : IBuffer ,
@@ -544,13 +543,8 @@ export class HTMLSerializeHandler extends BaseSerializeHandler {
544
543
) {
545
544
super ( buffer ) ;
546
545
547
- // For xterm headless: fallback to ansi colors
548
- if ( ( _terminal as any ) . _core . _themeService ) {
549
- this . _ansiColors = ( _terminal as any ) . _core . _themeService . colors . ansi ;
550
- }
551
- else {
552
- this . _ansiColors = DEFAULT_ANSI_COLORS ;
553
- }
546
+ // https://github.com/xtermjs/xterm.js/issues/3601
547
+ this . _colors = ( _terminal as any ) . _core . _themeService . colors ;
554
548
}
555
549
556
550
private _padStart ( target : string , targetLength : number , padString : string ) : string {
@@ -606,7 +600,7 @@ export class HTMLSerializeHandler extends BaseSerializeHandler {
606
600
return rgb . map ( x => this . _padStart ( x . toString ( 16 ) , 2 , '0' ) ) . join ( '' ) ;
607
601
}
608
602
if ( isFg ? cell . isFgPalette ( ) : cell . isBgPalette ( ) ) {
609
- return this . _ansiColors [ color ] . css ;
603
+ return this . _colors . ansi [ color ] . css ;
610
604
}
611
605
return undefined ;
612
606
}
0 commit comments