diff --git a/pyproject.toml b/pyproject.toml index 6d08267..b2767ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "textual-webterm" -version = "0.1.14" +version = "0.1.15" description = "Serve terminal sessions over the web" authors = ["Will McGugan "] license = "MIT" diff --git a/src/textual_webterm/local_server.py b/src/textual_webterm/local_server.py index 4dafd22..7827bad 100644 --- a/src/textual_webterm/local_server.py +++ b/src/textual_webterm/local_server.py @@ -44,21 +44,32 @@ SVG_MONO_FONT_STACK = ( ) # Map pyte color names to Rich-compatible names +# pyte uses different naming conventions than Rich for some colors PYTE_TO_RICH_COLOR = { + # Bright colors (pyte concatenates, Rich uses underscore) "brightblack": "bright_black", "brightred": "bright_red", "brightgreen": "bright_green", + "brightbrown": "bright_yellow", # bright brown = bright yellow "brightyellow": "bright_yellow", "brightblue": "bright_blue", "brightmagenta": "bright_magenta", + "bfightmagenta": "bright_magenta", # typo in pyte's BG_AIXTERM "brightcyan": "bright_cyan", "brightwhite": "bright_white", - "brown": "yellow", # pyte uses 'brown' for ANSI yellow + # Standard colors + "brown": "yellow", # pyte uses 'brown' for ANSI color 33 (yellow) } def _pyte_color_to_rich(color: str) -> str: - """Convert pyte color to Rich-compatible color string.""" + """Convert pyte color to Rich-compatible color string. + + Handles: + - Named color mappings (e.g., 'brown' -> 'yellow') + - Bright color name format (e.g., 'brightred' -> 'bright_red') + - Hex colors from 256-color/truecolor (e.g., 'ff8700' -> '#ff8700') + """ if color == "default": return color # Check mapping first