From 1de1f6717b68f934019baf2fa52c76e0f94f2e38 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sun, 15 Mar 2020 21:21:19 +0100 Subject: Tremulous color support (24-bit modes only) --- rcon.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'rcon.py') diff --git a/rcon.py b/rcon.py index 0185f12..d744792 100644 --- a/rcon.py +++ b/rcon.py @@ -1,4 +1,5 @@ import urwid, os, subprocess, fcntl, glob +from trem_colors import trem_to_markup, trem_palette try: from local_config import * @@ -34,9 +35,14 @@ class JournalViewer: lc, "" if lc == 1 else "s", "on" if self.following else "off")) - def write(self, text): + def write(self, text, color_override=None): for line in str(text).split("\n"): - self.list_walker.append(urwid.Text(line)) + if color_override is None: + markup = trem_to_markup(line) + else: + markup = (color_override, line) + self.list_walker.append(urwid.Text(markup)) + self.update() def proc_open(self, argv): @@ -147,7 +153,8 @@ class Console: def select_server(self, server): self.server = server - self.viewer.write("*** Now viewing logs from %s ***" % server) + self.viewer.write("Now viewing logs from %s" % server, + color_override="system") self.edit_pre.button.set_label(server) argv = [arg % server if "%s" in arg else arg for arg in LOG_COMMAND] @@ -161,15 +168,26 @@ class Console: palette = [ + # UI elements ("button", "white", "dark red"), ("button focus", "white, bold", "light red"), ("status", "black", "white"), ("edit focus", "white", "black"), ("edit", "white", "dark gray"), ("popup", "white", "dark red"), -] -loop = urwid.MainLoop(None, palette, pop_ups=True) + # Log text + ("system", "white, bold", "dark gray"), + + ("WTF", "black", "black", "black", "#123456", "black"), +] \ + + trem_palette + +screen = urwid.raw_display.Screen() +screen.set_terminal_properties(colors=2**24) +screen.register_palette(palette) + +loop = urwid.MainLoop(None, screen=screen, pop_ups=True) console = Console(loop) loop.widget = console.root loop.unhandled_input = console.unhandled_input -- cgit