Lots of tests
This commit is contained in:
@@ -177,15 +177,15 @@ def main():
|
||||
|
||||
term = Terminal(stdscr, config)
|
||||
|
||||
if config['monochrome']:
|
||||
if config['monochrome'] or config['theme'] == 'monochrome':
|
||||
_logger.info('Using monochrome theme')
|
||||
theme = Theme(use_color=False)
|
||||
elif config['theme']:
|
||||
elif config['theme'] and config['theme'] != 'default':
|
||||
_logger.info('Loading theme: %s', config['theme'])
|
||||
theme = Theme.from_name(config['theme'])
|
||||
else:
|
||||
# Set to None to let the terminal figure out which default
|
||||
# theme to use depending on if colors are supported or not
|
||||
# Set to None to let the terminal figure out which theme
|
||||
# to use depending on if colors are supported or not
|
||||
theme = None
|
||||
term.set_theme(theme)
|
||||
|
||||
|
||||
16
rtv/theme.py
16
rtv/theme.py
@@ -54,7 +54,7 @@ class Theme(object):
|
||||
# can only use the 8 basic colors with the default color as the background
|
||||
DEFAULT_THEME = {
|
||||
'modifiers': {
|
||||
'Normal': (None, None, None),
|
||||
'Normal': (-1, -1, None),
|
||||
'Selected': (None, None, None),
|
||||
'SelectedCursor': (None, None, curses.A_REVERSE),
|
||||
},
|
||||
@@ -91,14 +91,14 @@ class Theme(object):
|
||||
'MultiredditName': (curses.COLOR_YELLOW, None, curses.A_BOLD),
|
||||
'MultiredditText': (None, None, None),
|
||||
'NeutralVote': (None, None, curses.A_BOLD),
|
||||
'NSFW': (curses.COLOR_RED, None, curses.A_BOLD),
|
||||
'NSFW': (curses.COLOR_RED, None, curses.A_BOLD | curses.A_REVERSE),
|
||||
'Saved': (curses.COLOR_GREEN, None, None),
|
||||
'Score': (None, None, None),
|
||||
'Separator': (None, None, curses.A_BOLD),
|
||||
'Stickied': (curses.COLOR_GREEN, None, None),
|
||||
'SubscriptionName': (curses.COLOR_YELLOW, None, curses.A_BOLD),
|
||||
'SubscriptionText': (None, None, None),
|
||||
'SubmissionAuthor': (curses.COLOR_GREEN, None, None),
|
||||
'SubmissionAuthor': (curses.COLOR_GREEN, None, curses.A_BOLD),
|
||||
'SubmissionFlair': (curses.COLOR_RED, None, None),
|
||||
'SubmissionSubreddit': (curses.COLOR_YELLOW, None, None),
|
||||
'SubmissionText': (None, None, None),
|
||||
@@ -130,6 +130,9 @@ class Theme(object):
|
||||
format as Theme.DEFAULT_THEME.
|
||||
"""
|
||||
|
||||
if source not in (None, 'built-in', 'preset', 'installed', 'custom'):
|
||||
raise ValueError('Invalid source')
|
||||
|
||||
if name is None and source is None:
|
||||
name = 'default' if use_color else 'monochrome'
|
||||
source = 'built-in'
|
||||
@@ -332,6 +335,12 @@ class Theme(object):
|
||||
line = ' {0:<20}[requires {1} colors]'
|
||||
print(line.format(theme.name, theme.required_colors))
|
||||
|
||||
print('\nBuilt-in:')
|
||||
built_in = [t for t in themes if t.source == 'built-in']
|
||||
for theme in built_in:
|
||||
line = ' {0:<20}[requires {1} colors]'
|
||||
print(line.format(theme.name, theme.required_colors))
|
||||
|
||||
if errors:
|
||||
print('\nWARNING: Some files encountered errors:')
|
||||
for (source, name), error in errors.items():
|
||||
@@ -496,7 +505,6 @@ class Theme(object):
|
||||
b = round(int(color[5:7], 16) / 51.0)
|
||||
n = 36 * r + 6 * g + b + 16
|
||||
return 'ansi_{0}'.format(n)
|
||||
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
[theme]
|
||||
;<element> = <foreground> <background> <attributes>
|
||||
Normal = ansi_244 ansi_234 -
|
||||
Selected = ansi_244 ansi_235 -
|
||||
SelectedCursor = ansi_244 ansi_235 bold+reverse
|
||||
Selected = - ansi_235 -
|
||||
SelectedCursor = - ansi_235 bold+reverse
|
||||
|
||||
TitleBar = ansi_37 - bold+reverse
|
||||
OrderBar = ansi_245 - bold
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
[theme]
|
||||
;<element> = <foreground> <background> <attributes>
|
||||
Normal = ansi_241 ansi_230 -
|
||||
Selected = ansi_241 ansi_254 -
|
||||
SelectedCursor = ansi_241 ansi_254 bold+reverse
|
||||
Selected = - ansi_254 -
|
||||
SelectedCursor = - ansi_254 bold+reverse
|
||||
|
||||
TitleBar = ansi_37 - bold+reverse
|
||||
OrderBar = ansi_245 - bold
|
||||
|
||||
Reference in New Issue
Block a user