diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2020-03-15 21:21:19 +0100 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2020-03-15 21:21:19 +0100 |
commit | 1de1f6717b68f934019baf2fa52c76e0f94f2e38 (patch) | |
tree | a65d4c110cca4c46ff9c9a1ef7f131eb3c1b75e3 /rcon.py | |
parent | d9e323fd4f7ee4cae48bd786f94dd3ca6e2a800b (diff) |
Tremulous color support (24-bit modes only)
Diffstat (limited to 'rcon.py')
-rw-r--r-- | rcon.py | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -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 |