]> git.armaanb.net Git - lightcards.git/commitdiff
Clean up bar implementation
authorArmaan Bhojwani <me@armaanb.net>
Sun, 31 Jan 2021 22:30:31 +0000 (17:30 -0500)
committerArmaan Bhojwani <me@armaanb.net>
Sun, 31 Jan 2021 22:30:31 +0000 (17:30 -0500)
lightcards/display.py

index 3f55a56c225c66ce9a71a687343dfa775c921ab8..5257c47f66237a8e334e5d06fb4a709a1ab1e5b9 100755 (executable)
@@ -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()