From 49684f1af71133f22d6d85e00f68e64889a59f8e Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Thu, 11 Feb 2021 17:58:35 -0500 Subject: [PATCH] Update user interface Make horizontal lines go full length, and center headings --- lightcards/display.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lightcards/display.py b/lightcards/display.py index 11a7a91..de3ffe0 100644 --- a/lightcards/display.py +++ b/lightcards/display.py @@ -19,10 +19,10 @@ def panel_create(x, y): class Help: - def __init__(self, outer): + def __init__(self, outer, mlines=20, mcols=52): """Initialize help screen""" self.outer = outer - (self.win, self.panel) = panel_create(20, 52) + (self.win, self.panel) = panel_create(mlines, mcols) self.panel.top() self.panel.hide() self.win.clear() @@ -48,9 +48,12 @@ class Help: ] self.win.addstr( - 1, 1, "LIGHTCARDS HELP", curses.color_pair(1) + curses.A_BOLD + 1, + int(mcols / 2) - 8, + "LIGHTCARDS HELP", + curses.color_pair(1) + curses.A_BOLD, ) - self.win.hline(2, 1, curses.ACS_HLINE, 15) + self.win.hline(2, 1, curses.ACS_HLINE, mcols) for t in enumerate(text): self.win.addstr(t[0] + 3, 1, t[1]) @@ -74,17 +77,20 @@ class Help: class Menu: - def __init__(self, outer): + def __init__(self, outer, mlines=17, mcols=44): """Initialize the menu with content""" self.outer = outer - (self.win, self.panel) = panel_create(17, 44) + (self.win, self.panel) = panel_create(mlines, mcols) self.panel.top() self.panel.hide() self.win.addstr( - 1, 1, "LIGHTCARDS MENU", curses.color_pair(1) + curses.A_BOLD + 1, + int(mcols / 2) - 8, + "LIGHTCARDS MENU", + curses.color_pair(1) + curses.A_BOLD, ) - self.win.hline(2, 1, curses.ACS_HLINE, 15) + self.win.hline(2, 1, curses.ACS_HLINE, mcols) text = [ "[y]: reset stack to original state", "[a]: alphabetize stack", @@ -235,7 +241,8 @@ class Display: Display the statusbar at the bottom of the screen with progress, star status, and card side. """ - (mlines, _) = self.win.getmaxyx() + (mlines, mcols) = self.win.getmaxyx() + self.win.hline(mlines - 2, 0, 0, mcols) # Calculate percent done if len(self.stack) <= 1: @@ -316,10 +323,7 @@ class Display: ) # Add horizontal line - lin_width = header_width - if len(top) < header_width: - lin_width = len(top) - self.main_win.hline(1, 0, curses.ACS_HLINE, lin_width) + self.main_win.hline(1, 0, curses.ACS_HLINE, mcols) # Show current side self.main_win.addstr( @@ -333,7 +337,6 @@ class Display: self.update_panels() self.disp_bar() self.disp_sidebar() - self.win.hline(mlines - 2, 0, 0, mcols) def current_card(self): """Get current card object""" @@ -394,7 +397,6 @@ class Display: curses.color_pair(3) + curses.A_BOLD, ) self.win.vline(0, mcols - 20, 0, mlines - 2) - self.win.hline(1, left, 0, mlines) nstarred = self.nstarred() if mlines - 5 < len(self.nstarred()): -- 2.39.2