Reverting a change to the order of how Selected is applied to themes

This commit is contained in:
Michael Lazar
2017-12-09 21:06:29 -05:00
parent 9dd05d2fb2
commit 38c3695603
7 changed files with 43 additions and 40 deletions

View File

@@ -54,9 +54,9 @@ class Theme(object):
# can only use the 8 basic colors with the default color as the background # can only use the 8 basic colors with the default color as the background
DEFAULT_THEME = { DEFAULT_THEME = {
'modifiers': { 'modifiers': {
'Normal': (-1, -1, None), 'Normal': (-1, -1, curses.A_NORMAL),
'Selected': (None, None, None), 'Selected': (-1, -1, curses.A_NORMAL),
'SelectedCursor': (None, None, curses.A_REVERSE), 'SelectedCursor': (-1, -1, curses.A_REVERSE),
}, },
'page': { 'page': {
'TitleBar': (curses.COLOR_CYAN, None, curses.A_BOLD | curses.A_REVERSE), 'TitleBar': (curses.COLOR_CYAN, None, curses.A_BOLD | curses.A_REVERSE),
@@ -160,6 +160,18 @@ class Theme(object):
elements[key] = (None, None, None) elements[key] = (None, None, None)
self._set_fallback(elements, 'Normal', (-1, -1, curses.A_NORMAL)) 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 # Fill in the ``None`` values for all of the elements with normal text
for name in self.DEFAULT_THEME['normal']: for name in self.DEFAULT_THEME['normal']:
@@ -169,19 +181,6 @@ class Theme(object):
for name in self.DEFAULT_THEME['page']: for name in self.DEFAULT_THEME['page']:
self._set_fallback(elements, name, 'Normal') 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 self.elements = elements
if self.use_color: if self.use_color:

View File

@@ -1,8 +1,8 @@
[theme] [theme]
;<element> = <foreground> <background> <attributes> ;<element> = <foreground> <background> <attributes>
Normal = default default - Normal = default default normal
Selected = - - - Selected = default default normal
SelectedCursor = - - reverse SelectedCursor = default default reverse
TitleBar = cyan - bold+reverse TitleBar = cyan - bold+reverse
OrderBar = yellow - bold OrderBar = yellow - bold

View File

@@ -23,9 +23,9 @@
[theme] [theme]
;<element> = <foreground> <background> <attributes> ;<element> = <foreground> <background> <attributes>
Normal = ansi_252 ansi_234 - Normal = ansi_252 ansi_234 normal
Selected = - ansi_236 - Selected = ansi_252 ansi_236 normal
SelectedCursor = - - bold+reverse SelectedCursor = ansi_252 ansi_234 bold+reverse
TitleBar = ansi_81 - bold+reverse TitleBar = ansi_81 - bold+reverse
OrderBar = ansi_244 ansi_235 - OrderBar = ansi_244 ansi_235 -

View File

@@ -21,9 +21,9 @@
[theme] [theme]
;<element> = <foreground> <background> <attributes> ;<element> = <foreground> <background> <attributes>
Normal = ansi_238 ansi_255 - Normal = ansi_238 ansi_255 normal
Selected = - ansi_254 - Selected = ansi_238 ansi_254 normal
SelectedCursor = - - bold+reverse SelectedCursor = ansi_238 ansi_255 bold+reverse
TitleBar = ansi_24 - bold+reverse TitleBar = ansi_24 - bold+reverse
OrderBar = ansi_25 - bold OrderBar = ansi_25 - bold

View File

@@ -19,9 +19,9 @@
[theme] [theme]
;<element> = <foreground> <background> <attributes> ;<element> = <foreground> <background> <attributes>
Normal = ansi_244 ansi_234 - Normal = ansi_244 ansi_234 normal
Selected = - ansi_235 - Selected = ansi_244 ansi_235 normal
SelectedCursor = - ansi_235 bold+reverse SelectedCursor = ansi_244 ansi_235 bold+reverse
TitleBar = ansi_37 - bold+reverse TitleBar = ansi_37 - bold+reverse
OrderBar = ansi_245 - bold OrderBar = ansi_245 - bold
@@ -34,10 +34,10 @@ NoticeError = ansi_160 - bold
NoticeSuccess = ansi_64 - bold NoticeSuccess = ansi_64 - bold
CursorBlock = ansi_240 - - CursorBlock = ansi_240 - -
CursorBar1 = ansi_125 - bold CursorBar1 = ansi_125 - -
CursorBar2 = ansi_160 - bold CursorBar2 = ansi_160 - -
CursorBar3 = ansi_61 - bold CursorBar3 = ansi_61 - -
CursorBar4 = ansi_37 - bold CursorBar4 = ansi_37 - -
CommentAuthor = ansi_33 - bold CommentAuthor = ansi_33 - bold
CommentAuthorSelf = ansi_64 - bold CommentAuthorSelf = ansi_64 - bold

View File

@@ -19,9 +19,9 @@
[theme] [theme]
;<element> = <foreground> <background> <attributes> ;<element> = <foreground> <background> <attributes>
Normal = ansi_241 ansi_230 - Normal = ansi_241 ansi_230 normal
Selected = - ansi_254 - Selected = ansi_241 ansi_254 normal
SelectedCursor = - ansi_254 bold+reverse SelectedCursor = ansi_241 ansi_254 bold+reverse
TitleBar = ansi_37 - bold+reverse TitleBar = ansi_37 - bold+reverse
OrderBar = ansi_245 - bold OrderBar = ansi_245 - bold
@@ -34,10 +34,10 @@ NoticeError = ansi_160 - bold
NoticeSuccess = ansi_64 - bold NoticeSuccess = ansi_64 - bold
CursorBlock = ansi_245 - - CursorBlock = ansi_245 - -
CursorBar1 = ansi_125 - bold CursorBar1 = ansi_125 - -
CursorBar2 = ansi_160 - bold CursorBar2 = ansi_160 - -
CursorBar3 = ansi_61 - bold CursorBar3 = ansi_61 - -
CursorBar4 = ansi_37 - bold CursorBar4 = ansi_37 - -
CommentAuthor = ansi_33 - bold CommentAuthor = ansi_33 - bold
CommentAuthorSelf = ansi_64 - bold CommentAuthorSelf = ansi_64 - bold

View File

@@ -102,7 +102,11 @@ def test_theme_element_selected_attributes():
# the ones defined in "Selected". Because "Selected" defines # the ones defined in "Selected". Because "Selected" defines
# a foreground and a background color, they will override the # a foreground and a background color, they will override the
# ones that "Link" had defined. # 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 '@Normal' not in theme.elements
assert '@Selected' not in theme.elements assert '@Selected' not in theme.elements
assert '@TitleBar' not in theme.elements assert '@TitleBar' not in theme.elements