From 865040acf9337c062e662d06bf3ea6d22877a738 Mon Sep 17 00:00:00 2001 From: Michael Lazar Date: Thu, 7 Dec 2017 21:58:12 -0500 Subject: [PATCH] Fixing edge case with terminals that dont support colors --- rtv/terminal.py | 11 ++++++----- rtv/theme.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/rtv/terminal.py b/rtv/terminal.py index f2dc9b4..08febfe 100644 --- a/rtv/terminal.py +++ b/rtv/terminal.py @@ -878,25 +878,26 @@ class Terminal(object): """ terminal_colors = curses.COLORS if curses.has_colors() else 0 + default_theme = Theme(use_color=bool(terminal_colors)) if theme is None: - theme = Theme(use_color=bool(terminal_colors)) + theme = default_theme elif theme.required_color_pairs > curses.COLOR_PAIRS: _logger.warning( - 'Theme %s requires %s color pairs, but TERM %s only ' + 'Theme `%s` requires %s color pairs, but $TERM=%s only ' 'supports %s color pairs, switching to default theme', theme.name, theme.required_color_pairs, self._term, curses.COLOR_PAIRS) - theme = Theme() + theme = default_theme elif theme.required_colors > terminal_colors: _logger.warning( - 'Theme %s requires %s colors, but TERM %s only ' + 'Theme `%s` requires %s colors, but $TERM=%s only ' 'supports %s colors, switching to default theme', theme.name, theme.required_colors, self._term, curses.COLORS) - theme = Theme() + theme = default_theme theme.bind_curses() self.theme = theme diff --git a/rtv/theme.py b/rtv/theme.py index f206563..173aea1 100644 --- a/rtv/theme.py +++ b/rtv/theme.py @@ -2,11 +2,11 @@ import os import codecs import curses import logging -import configparser from collections import OrderedDict from contextlib import contextmanager import six +from six.moves import configparser from .config import THEMES, DEFAULT_THEMES from .exceptions import ConfigError