ui/urwid: respect --no-colors

This commit is contained in:
rr-
2019-01-13 17:46:07 +01:00
parent a47d6233be
commit ae99f1f1a4
2 changed files with 14 additions and 3 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ def parse_args() -> argparse.Namespace:
"--no-colors", "--no-colors",
dest="colors", dest="colors",
action="store_false", action="store_false",
help="Disable color highlighting in curses interface", help="Disable color highlighting in curses and urwid interface",
) )
parser.add_argument( parser.add_argument(
+13 -2
View File
@@ -13,7 +13,7 @@ from ..base import BaseUserInterface
TICK_FREQ = 0.1 TICK_FREQ = 0.1
SAVE_FREQ = 60.0 SAVE_FREQ = 60.0
PALETTE: T.List[T.Tuple[str, ...]] = [ PALETTE_COLORS: T.List[T.Tuple[str, ...]] = [
("logo", "light green", ""), ("logo", "light green", ""),
("button", "", ""), ("button", "", ""),
("button-focus", "light red", "black"), ("button-focus", "light red", "black"),
@@ -29,6 +29,13 @@ PALETTE: T.List[T.Tuple[str, ...]] = [
("scrollable", "", ""), ("scrollable", "", ""),
("scrollable-focus", "", ""), ("scrollable-focus", "", ""),
] ]
PALETTE_NO_COLORS: T.List[T.Tuple[str, ...]] = [
("button-focus", "", "", "standout"),
("linebox-focus", "", "", "standout"),
("progressbar-normal", "black", "white"),
("progressbar-done", "black", "white", "standout"),
("progressbar-smooth", "black", "white"),
]
class ConfirmExitDialog(ConfirmView): class ConfirmExitDialog(ConfirmView):
@@ -54,8 +61,12 @@ class UrwidUserInterface(BaseUserInterface):
bind_commands() bind_commands()
self.loop = urwid.MainLoop( self.loop = urwid.MainLoop(
None, PALETTE, unhandled_input=self.unhandled_input None,
PALETTE_COLORS if args.colors else PALETTE_NO_COLORS,
unhandled_input=self.unhandled_input,
) )
if not args.colors:
self.loop.screen.set_terminal_properties(1)
self.old_views: T.List[urwid.Widget] = [] self.old_views: T.List[urwid.Widget] = []
self.switch_to_roster_view() self.switch_to_roster_view()