Read TUI colors from settings

This commit is contained in:
Ivan Habunek 2023-07-08 11:35:41 +02:00
parent 740f7fafd4
commit 0903dae8d3
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
1 changed files with 16 additions and 8 deletions

View File

@ -78,15 +78,11 @@ class TUI(urwid.Frame):
loop: urwid.MainLoop
screen: urwid.BaseScreen
@classmethod
def create(cls, app, user, args):
@staticmethod
def create(app, user, args):
"""Factory method, sets up TUI and an event loop."""
screen = urwid.raw_display.Screen()
tui = cls(app, user, screen, args)
if args.no_color:
screen.set_terminal_properties(1)
screen.reset_default_terminal_palette()
screen = TUI.create_screen(args)
tui = TUI(app, user, screen, args)
palette = MONO_PALETTE if args.no_color else PALETTE
overrides = settings.get_setting("tui.palette", dict, {})
@ -104,6 +100,18 @@ class TUI(urwid.Frame):
return tui
@staticmethod
def create_screen(args):
screen = urwid.raw_display.Screen()
# Determine how many colors to use
default_colors = 1 if args.no_color else 16
colors = settings.get_setting("tui.colors", int, default_colors)
logger.debug(f"Setting colors to {colors}")
screen.set_terminal_properties(colors)
return screen
def __init__(self, app, user, screen, args):
self.app = app
self.user = user