fix: map pyte color names to Rich-compatible names

Pyte uses 'brightblack', 'brightred', etc. but Rich expects
'bright_black', 'bright_red' with underscores. Added PYTE_TO_RICH_COLOR
mapping to translate color names in screenshot rendering.
This commit is contained in:
GitHub Copilot
2026-01-24 11:11:35 +00:00
parent 4f8c7d88d5
commit 3e433f5af5
+15 -2
View File
@@ -44,6 +44,18 @@ SVG_MONO_FONT_STACK = (
'"DejaVu Sans Mono", "Courier New", monospace' '"DejaVu Sans Mono", "Courier New", monospace'
) )
# Map pyte color names to Rich-compatible names
PYTE_TO_RICH_COLOR = {
"brightblack": "bright_black",
"brightred": "bright_red",
"brightgreen": "bright_green",
"brightyellow": "bright_yellow",
"brightblue": "bright_blue",
"brightmagenta": "bright_magenta",
"brightcyan": "bright_cyan",
"brightwhite": "bright_white",
}
WEBTERM_STATIC_PATH = Path(__file__).parent / "static" WEBTERM_STATIC_PATH = Path(__file__).parent / "static"
@@ -541,11 +553,12 @@ class LocalServer:
char_data = char.data if char.data else " " char_data = char.data if char.data else " "
# Build Rich style from pyte character attributes # Build Rich style from pyte character attributes
# Map pyte color names to Rich-compatible names
style_kwargs = {} style_kwargs = {}
if char.fg != "default": if char.fg != "default":
style_kwargs["color"] = char.fg style_kwargs["color"] = PYTE_TO_RICH_COLOR.get(char.fg, char.fg)
if char.bg != "default": if char.bg != "default":
style_kwargs["bgcolor"] = char.bg style_kwargs["bgcolor"] = PYTE_TO_RICH_COLOR.get(char.bg, char.bg)
if char.bold: if char.bold:
style_kwargs["bold"] = True style_kwargs["bold"] = True
if char.italics: if char.italics: