fix: use rich markup instead of raw ansi in tui widgets
This commit is contained in:
@@ -20,13 +20,13 @@ class StatusBar(Static):
|
||||
|
||||
def render(self) -> str:
|
||||
if self.connected:
|
||||
conn = "\x1b[38;2;158;206;106m\u25cf connected\x1b[0m"
|
||||
conn = "[#9ece6a]\u25cf[/] connected"
|
||||
else:
|
||||
conn = "\x1b[38;2;247;118;142m\u25cb disconnected\x1b[0m"
|
||||
conn = "[#f7768e]\u25cb[/] disconnected"
|
||||
if self.ptt_active:
|
||||
ptt = "\x1b[38;2;224;175;104m\u25cf TX\x1b[0m"
|
||||
ptt = "[#e0af68]\u25cf[/] TX"
|
||||
else:
|
||||
ptt = "\x1b[38;2;86;95;137m\u25cb idle\x1b[0m"
|
||||
ptt = "[#565f89]\u25cb[/] idle"
|
||||
return f" {conn} {ptt}"
|
||||
|
||||
|
||||
@@ -34,14 +34,7 @@ class ChannelTree(Static):
|
||||
"""Channel and user list."""
|
||||
|
||||
def render(self) -> str:
|
||||
hdr = "\x1b[38;2;169;177;214m Channels\x1b[0m"
|
||||
empty = "\x1b[38;2;86;95;137m \u2514\u2500 (not connected)\x1b[0m"
|
||||
return f"{hdr}\n{empty}"
|
||||
|
||||
|
||||
class ChatLog(RichLog):
|
||||
"""Message log."""
|
||||
pass
|
||||
return " Channels\n [dim]\u2514\u2500 (not connected)[/]"
|
||||
|
||||
|
||||
class TuimbleApp(App):
|
||||
@@ -95,7 +88,9 @@ class TuimbleApp(App):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
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:
|
||||
yield Header()
|
||||
@@ -131,3 +126,9 @@ class TuimbleApp(App):
|
||||
"""Called when PTT state changes."""
|
||||
status = self.query_one("#status", StatusBar)
|
||||
status.ptt_active = transmitting
|
||||
|
||||
|
||||
class ChatLog(RichLog):
|
||||
"""Message log."""
|
||||
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user