Added username to banner if logged in.
This commit is contained in:
11
rtv/page.py
11
rtv/page.py
@@ -99,9 +99,10 @@ class BasePage(object):
|
||||
MIN_HEIGHT = 10
|
||||
MIN_WIDTH = 20
|
||||
|
||||
def __init__(self, stdscr, content, **kwargs):
|
||||
def __init__(self, stdscr, reddit, content, **kwargs):
|
||||
|
||||
self.stdscr = stdscr
|
||||
self.reddit = reddit
|
||||
self.content = content
|
||||
self.nav = Navigator(self.content.get, **kwargs)
|
||||
|
||||
@@ -155,6 +156,14 @@ class BasePage(object):
|
||||
attr = curses.A_REVERSE | curses.A_BOLD | Color.CYAN
|
||||
self._header_window.bkgd(' ', attr)
|
||||
self._header_window.addnstr(0, 0, self.content.name, n_cols-1)
|
||||
|
||||
if self.reddit.user is not None:
|
||||
username = self.reddit.user.name
|
||||
s_col = (n_cols - len(username) - 1)
|
||||
# Only print the username if it fits in the empty space on the right
|
||||
if (s_col - 1) >= len(self.content.name):
|
||||
self._header_window.addnstr(0, s_col, username, (n_cols-s_col-1))
|
||||
|
||||
self._header_window.refresh()
|
||||
|
||||
def _draw_content(self):
|
||||
|
||||
Reference in New Issue
Block a user