From 38c369560390565c6dcd79b520e93d8ee202ef85 Mon Sep 17 00:00:00 2001 From: Michael Lazar Date: Sat, 9 Dec 2017 21:06:29 -0500 Subject: [PATCH] Reverting a change to the order of how Selected is applied to themes --- rtv/theme.py | 31 +++++++++++++++---------------- rtv/themes/default.cfg.example | 6 +++--- rtv/themes/molokai.cfg | 6 +++--- rtv/themes/papercolor.cfg | 6 +++--- rtv/themes/solarized-dark.cfg | 14 +++++++------- rtv/themes/solarized-light.cfg | 14 +++++++------- tests/test_theme.py | 6 +++++- 7 files changed, 43 insertions(+), 40 deletions(-) diff --git a/rtv/theme.py b/rtv/theme.py index 173aea1..966224f 100644 --- a/rtv/theme.py +++ b/rtv/theme.py @@ -54,9 +54,9 @@ class Theme(object): # can only use the 8 basic colors with the default color as the background DEFAULT_THEME = { 'modifiers': { - 'Normal': (-1, -1, None), - 'Selected': (None, None, None), - 'SelectedCursor': (None, None, curses.A_REVERSE), + 'Normal': (-1, -1, curses.A_NORMAL), + 'Selected': (-1, -1, curses.A_NORMAL), + 'SelectedCursor': (-1, -1, curses.A_REVERSE), }, 'page': { 'TitleBar': (curses.COLOR_CYAN, None, curses.A_BOLD | curses.A_REVERSE), @@ -160,6 +160,18 @@ class Theme(object): elements[key] = (None, None, None) self._set_fallback(elements, 'Normal', (-1, -1, curses.A_NORMAL)) + self._set_fallback(elements, 'Selected', 'Normal') + self._set_fallback(elements, 'SelectedCursor', 'Normal') + + # Create the "Selected" versions of elements, which are prefixed with + # the @ symbol. For example, "@CommentText" represents how comment + # text is formatted when it is highlighted by the cursor. + for name in self.DEFAULT_THEME['normal']: + dest = '@{0}'.format(name) + self._set_fallback(elements, name, 'Selected', dest) + for name in self.DEFAULT_THEME['cursor']: + dest = '@{0}'.format(name) + self._set_fallback(elements, name, 'SelectedCursor', dest) # Fill in the ``None`` values for all of the elements with normal text for name in self.DEFAULT_THEME['normal']: @@ -169,19 +181,6 @@ class Theme(object): for name in self.DEFAULT_THEME['page']: self._set_fallback(elements, name, 'Normal') - # Create the "Selected" versions of elements, which are prefixed with - # the @ symbol. For example, "@CommentText" represents how comment - # text is formatted when it is highlighted by the cursor. - for name in self.DEFAULT_THEME['normal']: - dest = '@{0}'.format(name) - self._set_fallback(elements, 'Selected', name, dest) - for name in self.DEFAULT_THEME['cursor']: - dest = '@{0}'.format(name) - self._set_fallback(elements, 'SelectedCursor', name, dest) - - self._set_fallback(elements, 'Selected', 'Normal') - self._set_fallback(elements, 'SelectedCursor', 'Normal') - self.elements = elements if self.use_color: diff --git a/rtv/themes/default.cfg.example b/rtv/themes/default.cfg.example index 5773510..b8045cb 100644 --- a/rtv/themes/default.cfg.example +++ b/rtv/themes/default.cfg.example @@ -1,8 +1,8 @@ [theme] ; = -Normal = default default - -Selected = - - - -SelectedCursor = - - reverse +Normal = default default normal +Selected = default default normal +SelectedCursor = default default reverse TitleBar = cyan - bold+reverse OrderBar = yellow - bold diff --git a/rtv/themes/molokai.cfg b/rtv/themes/molokai.cfg index 0806d75..9a97f6f 100644 --- a/rtv/themes/molokai.cfg +++ b/rtv/themes/molokai.cfg @@ -23,9 +23,9 @@ [theme] ; = -Normal = ansi_252 ansi_234 - -Selected = - ansi_236 - -SelectedCursor = - - bold+reverse +Normal = ansi_252 ansi_234 normal +Selected = ansi_252 ansi_236 normal +SelectedCursor = ansi_252 ansi_234 bold+reverse TitleBar = ansi_81 - bold+reverse OrderBar = ansi_244 ansi_235 - diff --git a/rtv/themes/papercolor.cfg b/rtv/themes/papercolor.cfg index 4c68793..57cc666 100644 --- a/rtv/themes/papercolor.cfg +++ b/rtv/themes/papercolor.cfg @@ -21,9 +21,9 @@ [theme] ; = -Normal = ansi_238 ansi_255 - -Selected = - ansi_254 - -SelectedCursor = - - bold+reverse +Normal = ansi_238 ansi_255 normal +Selected = ansi_238 ansi_254 normal +SelectedCursor = ansi_238 ansi_255 bold+reverse TitleBar = ansi_24 - bold+reverse OrderBar = ansi_25 - bold diff --git a/rtv/themes/solarized-dark.cfg b/rtv/themes/solarized-dark.cfg index c75d149..bd666a9 100644 --- a/rtv/themes/solarized-dark.cfg +++ b/rtv/themes/solarized-dark.cfg @@ -19,9 +19,9 @@ [theme] ; = -Normal = ansi_244 ansi_234 - -Selected = - ansi_235 - -SelectedCursor = - ansi_235 bold+reverse +Normal = ansi_244 ansi_234 normal +Selected = ansi_244 ansi_235 normal +SelectedCursor = ansi_244 ansi_235 bold+reverse TitleBar = ansi_37 - bold+reverse OrderBar = ansi_245 - bold @@ -34,10 +34,10 @@ NoticeError = ansi_160 - bold NoticeSuccess = ansi_64 - bold CursorBlock = ansi_240 - - -CursorBar1 = ansi_125 - bold -CursorBar2 = ansi_160 - bold -CursorBar3 = ansi_61 - bold -CursorBar4 = ansi_37 - bold +CursorBar1 = ansi_125 - - +CursorBar2 = ansi_160 - - +CursorBar3 = ansi_61 - - +CursorBar4 = ansi_37 - - CommentAuthor = ansi_33 - bold CommentAuthorSelf = ansi_64 - bold diff --git a/rtv/themes/solarized-light.cfg b/rtv/themes/solarized-light.cfg index 668a47b..1492220 100644 --- a/rtv/themes/solarized-light.cfg +++ b/rtv/themes/solarized-light.cfg @@ -19,9 +19,9 @@ [theme] ; = -Normal = ansi_241 ansi_230 - -Selected = - ansi_254 - -SelectedCursor = - ansi_254 bold+reverse +Normal = ansi_241 ansi_230 normal +Selected = ansi_241 ansi_254 normal +SelectedCursor = ansi_241 ansi_254 bold+reverse TitleBar = ansi_37 - bold+reverse OrderBar = ansi_245 - bold @@ -34,10 +34,10 @@ NoticeError = ansi_160 - bold NoticeSuccess = ansi_64 - bold CursorBlock = ansi_245 - - -CursorBar1 = ansi_125 - bold -CursorBar2 = ansi_160 - bold -CursorBar3 = ansi_61 - bold -CursorBar4 = ansi_37 - bold +CursorBar1 = ansi_125 - - +CursorBar2 = ansi_160 - - +CursorBar3 = ansi_61 - - +CursorBar4 = ansi_37 - - CommentAuthor = ansi_33 - bold CommentAuthorSelf = ansi_64 - bold diff --git a/tests/test_theme.py b/tests/test_theme.py index 94cd3c4..1c59b7e 100644 --- a/tests/test_theme.py +++ b/tests/test_theme.py @@ -102,7 +102,11 @@ def test_theme_element_selected_attributes(): # the ones defined in "Selected". Because "Selected" defines # a foreground and a background color, they will override the # ones that "Link" had defined. - assert theme.elements['@Link'] == (2, 3, curses.A_REVERSE) + # assert theme.elements['@Link'] == (2, 3, curses.A_REVERSE) + + # I can't remember why the above rule was implemented, so I reverted it + assert theme.elements['@Link'] == (5, 3, curses.A_REVERSE) + assert '@Normal' not in theme.elements assert '@Selected' not in theme.elements assert '@TitleBar' not in theme.elements