From c9afe870b65de0bbfb51a8461216b5cde9b284fb Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Sun, 31 Jan 2021 17:30:31 -0500 Subject: [PATCH] Clean up bar implementation --- lightcards/display.py | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/lightcards/display.py b/lightcards/display.py index 3f55a56..5257c47 100755 --- a/lightcards/display.py +++ b/lightcards/display.py @@ -38,28 +38,24 @@ class Display(): len(self.stack) * 100)).zfill(3) # Print yellow if starred - self.win.addstr(mlines - 1, 0, "[", curses.color_pair(1)) if self.stack[self.obj.getIdx()].getStar(): - self.win.addstr(self.stack[self.obj.getIdx()].printStar(), - curses.color_pair(3)) + star_color = curses.color_pair(3) else: - self.win.addstr(self.stack[self.obj.getIdx()].printStar(), - curses.color_pair(1)) - - # Put all the info together - self.win.addstr("] [" + - percent + - "% (" + - str(self.obj.getIdx() + - 1).zfill(len(str(len(self.stack)))) + - "/" + - str(len(self.stack)) + - ")]" + - " [" + - self.headers[self.obj.getSide()] + - " (" + - str(self.obj.getSide() + 1) + - ")]", curses.color_pair(1)) + star_color = curses.color_pair(1) + + # Create bar component + bar_start = "[" + bar_middle = self.stack[self.obj.getIdx()].printStar() + bar_end= "] [" + percent + "% (" + \ + str(self.obj.getIdx() + 1).zfill(len(str(len(self.stack)))) + \ + "/" + str(len(self.stack)) + ")] [" + \ + self.headers[self.obj.getSide()] + " (" + \ + str(self.obj.getSide() + 1) + ")]" + + # Put it all togethor + self.win.addstr(mlines - 1, 0, bar_start, curses.color_pair(1)) + self.win.addstr(bar_middle, star_color) + self.win.insstr(bar_end, curses.color_pair(1)) def menu_print(self, string, err=False): self.win.clear() -- 2.39.2