mirror of
https://github.com/ihabunek/toot.git
synced 2024-09-29 04:35:54 -04:00
Read TUI colors from settings
This commit is contained in:
parent
740f7fafd4
commit
0903dae8d3
@ -78,15 +78,11 @@ class TUI(urwid.Frame):
|
|||||||
loop: urwid.MainLoop
|
loop: urwid.MainLoop
|
||||||
screen: urwid.BaseScreen
|
screen: urwid.BaseScreen
|
||||||
|
|
||||||
@classmethod
|
@staticmethod
|
||||||
def create(cls, app, user, args):
|
def create(app, user, args):
|
||||||
"""Factory method, sets up TUI and an event loop."""
|
"""Factory method, sets up TUI and an event loop."""
|
||||||
screen = urwid.raw_display.Screen()
|
screen = TUI.create_screen(args)
|
||||||
tui = cls(app, user, screen, args)
|
tui = TUI(app, user, screen, args)
|
||||||
|
|
||||||
if args.no_color:
|
|
||||||
screen.set_terminal_properties(1)
|
|
||||||
screen.reset_default_terminal_palette()
|
|
||||||
|
|
||||||
palette = MONO_PALETTE if args.no_color else PALETTE
|
palette = MONO_PALETTE if args.no_color else PALETTE
|
||||||
overrides = settings.get_setting("tui.palette", dict, {})
|
overrides = settings.get_setting("tui.palette", dict, {})
|
||||||
@ -104,6 +100,18 @@ class TUI(urwid.Frame):
|
|||||||
|
|
||||||
return tui
|
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):
|
def __init__(self, app, user, screen, args):
|
||||||
self.app = app
|
self.app = app
|
||||||
self.user = user
|
self.user = user
|
||||||
|
Loading…
Reference in New Issue
Block a user