fix: use rich markup instead of raw ansi in tui widgets

This commit is contained in:
Username
2026-02-24 11:48:30 +01:00
parent 836018d146
commit 5df1f484a4

View File

@@ -20,13 +20,13 @@ class StatusBar(Static):
def render(self) -> str: def render(self) -> str:
if self.connected: if self.connected:
conn = "\x1b[38;2;158;206;106m\u25cf connected\x1b[0m" conn = "[#9ece6a]\u25cf[/] connected"
else: else:
conn = "\x1b[38;2;247;118;142m\u25cb disconnected\x1b[0m" conn = "[#f7768e]\u25cb[/] disconnected"
if self.ptt_active: if self.ptt_active:
ptt = "\x1b[38;2;224;175;104m\u25cf TX\x1b[0m" ptt = "[#e0af68]\u25cf[/] TX"
else: else:
ptt = "\x1b[38;2;86;95;137m\u25cb idle\x1b[0m" ptt = "[#565f89]\u25cb[/] idle"
return f" {conn} {ptt}" return f" {conn} {ptt}"
@@ -34,14 +34,7 @@ class ChannelTree(Static):
"""Channel and user list.""" """Channel and user list."""
def render(self) -> str: def render(self) -> str:
hdr = "\x1b[38;2;169;177;214m Channels\x1b[0m" return " Channels\n [dim]\u2514\u2500 (not connected)[/]"
empty = "\x1b[38;2;86;95;137m \u2514\u2500 (not connected)\x1b[0m"
return f"{hdr}\n{empty}"
class ChatLog(RichLog):
"""Message log."""
pass
class TuimbleApp(App): class TuimbleApp(App):
@@ -95,7 +88,9 @@ class TuimbleApp(App):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self._config: Config = load_config() self._config: Config = load_config()
self._ptt = detect_backend(self._on_ptt_change, self._config.ptt.backend) self._ptt = detect_backend(
self._on_ptt_change, self._config.ptt.backend
)
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield Header() yield Header()
@@ -131,3 +126,9 @@ class TuimbleApp(App):
"""Called when PTT state changes.""" """Called when PTT state changes."""
status = self.query_one("#status", StatusBar) status = self.query_one("#status", StatusBar)
status.ptt_active = transmitting status.ptt_active = transmitting
class ChatLog(RichLog):
"""Message log."""
pass