Nicer header for curses

pull/102/head
Ivan Habunek 2019-04-23 13:53:06 +02:00
rodzic b9743ba268
commit 912e7c8bc4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: CDBD63C43A30BB95
1 zmienionych plików z 10 dodań i 5 usunięć

Wyświetl plik

@ -48,13 +48,18 @@ class Color:
class HeaderWindow: class HeaderWindow:
def __init__(self, stdscr, height, width, y, x): def __init__(self, stdscr, height, width, y, x):
self.window = stdscr.subwin(height, width, y, x) self.window = stdscr.subwin(height, width, y, x)
self.window.bkgdset(' ', Color.WHITE_ON_BLUE)
self.height = height self.height = height
self.width = width self.width = width
def draw(self): def draw(self, user):
username = "{}@{}".format(user.username, user.instance)
self.window.erase() self.window.erase()
self.window.addstr(0, 1, "toot - your Mastodon command line interface", Color.YELLOW) self.window.addstr(" toot", curses.A_BOLD)
self.window.addstr(1, 1, "https://github.com/ihabunek/toot") self.window.addstr(" | ")
self.window.addstr(username)
self.window.addstr(" | ")
self.window.refresh() self.window.refresh()
@ -500,7 +505,7 @@ class TimelineApp:
if screen_width < 60: if screen_width < 60:
raise ConsoleError("Terminal screen is too narrow, toot curses requires at least 60 columns to display properly.") raise ConsoleError("Terminal screen is too narrow, toot curses requires at least 60 columns to display properly.")
header_height = 2 header_height = 1
footer_height = 2 footer_height = 2
footer_top = screen_height - footer_height footer_top = screen_height - footer_height
@ -700,7 +705,7 @@ class TimelineApp:
def full_redraw(self): def full_redraw(self):
"""Perform a full redraw of the UI.""" """Perform a full redraw of the UI."""
self.header.draw() self.header.draw(self.user)
self.draw_footer_status() self.draw_footer_status()
self.left.draw_statuses(self.statuses, self.selected) self.left.draw_statuses(self.statuses, self.selected)