@@ -227,7 +227,7 @@ def __init__(self, terminal_theme: TerminalTheme, enabled: bool = True):
227
227
super ().__init__ (enabled = enabled )
228
228
229
229
@lru_cache (1024 )
230
- def truecolor_style (self , style : Style ) -> Style :
230
+ def truecolor_style (self , style : Style , background : RichColor ) -> Style :
231
231
"""Replace system colors with truecolor equivalent.
232
232
233
233
Args:
@@ -247,8 +247,11 @@ def truecolor_style(self, style: Style) -> Style:
247
247
bgcolor = RichColor .from_rgb (
248
248
* bgcolor .get_truecolor (terminal_theme , foreground = False )
249
249
)
250
+ # Convert dim style to RGB
251
+ if style .dim and color is not None :
252
+ color = dim_color (background , color , 0.5 )
250
253
251
- return style + Style .from_color (color , bgcolor )
254
+ return Style .from_color (color , bgcolor )
252
255
253
256
def apply (self , segments : list [Segment ], background : Color ) -> list [Segment ]:
254
257
"""Transform a list of segments.
@@ -263,10 +266,16 @@ def apply(self, segments: list[Segment], background: Color) -> list[Segment]:
263
266
_Segment = Segment
264
267
truecolor_style = self .truecolor_style
265
268
269
+ background_rich_color = background .rich_color
270
+
266
271
return [
267
272
_Segment (
268
273
text ,
269
- None if style is None else truecolor_style (style ),
274
+ (
275
+ None
276
+ if style is None
277
+ else truecolor_style (style , background_rich_color )
278
+ ),
270
279
None ,
271
280
)
272
281
for text , style , _ in segments
0 commit comments