Added username to banner if logged in.

This commit is contained in:
Michael Lazar
2015-03-09 00:11:09 -07:00
parent 820e30b6a6
commit b0053643f7
3 changed files with 12 additions and 4 deletions

View File

@@ -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):