Merge branch 'master' into vimb_browser

This commit is contained in:
Michael Lazar
2017-12-30 18:59:20 -05:00
19 changed files with 240 additions and 174 deletions

View File

@@ -20,12 +20,13 @@ TEMPLATES = os.path.join(PACKAGE, 'templates')
DEFAULT_CONFIG = os.path.join(TEMPLATES, 'rtv.cfg')
DEFAULT_MAILCAP = os.path.join(TEMPLATES, 'mailcap')
DEFAULT_THEMES = os.path.join(PACKAGE, 'themes')
XDG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.join(HOME, '.config'))
CONFIG = os.path.join(XDG_HOME, 'rtv', 'rtv.cfg')
XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.join(HOME, '.config'))
XDG_DATA_HOME = os.getenv('XDG_DATA_HOME', os.path.join(HOME, '.local', 'share'))
CONFIG = os.path.join(XDG_CONFIG_HOME, 'rtv', 'rtv.cfg')
MAILCAP = os.path.join(HOME, '.mailcap')
TOKEN = os.path.join(XDG_HOME, 'rtv', 'refresh-token')
HISTORY = os.path.join(XDG_HOME, 'rtv', 'history.log')
THEMES = os.path.join(XDG_HOME, 'rtv', 'themes')
TOKEN = os.path.join(XDG_DATA_HOME, 'rtv', 'refresh-token')
HISTORY = os.path.join(XDG_DATA_HOME, 'rtv', 'history.log')
THEMES = os.path.join(XDG_CONFIG_HOME, 'rtv', 'themes')
def build_parser():

View File

@@ -303,17 +303,20 @@ class SubredditPage(Page):
offset = 0 if not inverted else -(data['n_rows'] - n_rows)
n_title = len(data['split_title'])
for row, text in enumerate(data['split_title'], start=offset):
if data['url_full'] in self.config.history:
attr = self.term.attr('SubmissionTitleSeen')
else:
attr = self.term.attr('SubmissionTitle')
for row, text in enumerate(data['split_title'], start=offset):
if row in valid_rows:
self.term.add_line(win, text, row, 1, attr)
row = n_title + offset
if data['url_full'] in self.config.history:
attr = self.term.attr('LinkSeen')
else:
attr = self.term.attr('Link')
if row in valid_rows:
if data['url_full'] in self.config.history:
attr = self.term.attr('LinkSeen')
else:
attr = self.term.attr('Link')
self.term.add_line(win, '{url}'.format(**data), row, 1, attr)
row = n_title + offset + 1

View File

@@ -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),
@@ -103,6 +103,7 @@ class Theme(object):
'SubmissionSubreddit': (curses.COLOR_YELLOW, None, None),
'SubmissionText': (None, None, None),
'SubmissionTitle': (None, None, curses.A_BOLD),
'SubmissionTitleSeen': (None, None, None),
'Upvote': (curses.COLOR_GREEN, None, curses.A_BOLD),
'Link': (curses.COLOR_BLUE, None, curses.A_UNDERLINE),
'LinkSeen': (curses.COLOR_MAGENTA, None, curses.A_UNDERLINE),
@@ -160,6 +161,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 +182,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:

View File

@@ -1,8 +1,8 @@
[theme]
;<element> = <foreground> <background> <attributes>
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
@@ -44,6 +44,7 @@ SubmissionFlair = red - -
SubmissionSubreddit = yellow - -
SubmissionText = - - -
SubmissionTitle = - - bold
SubmissionTitleSeen = - - -
Upvote = green - bold
Link = blue - underline
LinkSeen = magenta - underline

View File

@@ -23,9 +23,9 @@
[theme]
;<element> = <foreground> <background> <attributes>
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 -
@@ -67,6 +67,7 @@ SubmissionFlair = ansi_197 - -
SubmissionSubreddit = ansi_222 - -
SubmissionText = - - -
SubmissionTitle = - - bold
SubmissionTitleSeen = - - -
Upvote = ansi_154 - bold
Link = ansi_67 - underline
LinkSeen = ansi_141 - underline

View File

@@ -21,9 +21,9 @@
[theme]
;<element> = <foreground> <background> <attributes>
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
@@ -65,6 +65,7 @@ SubmissionFlair = ansi_162 - bold
SubmissionSubreddit = ansi_166 - bold
SubmissionText = - - -
SubmissionTitle = - - bold
SubmissionTitleSeen = - - -
Upvote = ansi_28 - bold
Link = ansi_24 - underline
LinkSeen = ansi_91 - underline

View File

@@ -19,9 +19,9 @@
[theme]
;<element> = <foreground> <background> <attributes>
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
@@ -63,6 +63,7 @@ SubmissionFlair = ansi_160 - -
SubmissionSubreddit = ansi_166 - -
SubmissionText = - - -
SubmissionTitle = ansi_245 - bold
SubmissionTitleSeen = - - -
Upvote = ansi_64 - bold
Link = ansi_33 - underline
LinkSeen = ansi_61 - underline

View File

@@ -19,9 +19,9 @@
[theme]
;<element> = <foreground> <background> <attributes>
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
@@ -63,6 +63,7 @@ SubmissionFlair = ansi_160 - bold
SubmissionSubreddit = ansi_166 - bold
SubmissionText = - - -
SubmissionTitle = ansi_240 - bold
SubmissionTitleSeen = - - -
Upvote = ansi_64 - bold
Link = ansi_33 - underline
LinkSeen = ansi_61 - underline