+ curses.curs_set(0) # Hide cursor
+ curses.use_default_colors() # Allow transparency
+ curses.init_pair(1, curses.COLOR_CYAN, -1)
+ curses.init_pair(2, curses.COLOR_RED, -1)
+ curses.init_pair(3, curses.COLOR_YELLOW, -1)
+
+ (self.main_win, self.main_panel) = panel_create(mlines, mcols)
+ self.menu_obj = Menu(self)
+ self.help_obj = Help(self)
+
+ self.get_key()
+
+ def update_panels(self):
+ """Update panel and window contents"""
+ curses.panel.update_panels()
+ self.win.refresh()
+
+ def leave(self):
+ """Pickle stack before quitting"""
+ if self.obj.index + 1 == len(self.stack):
+ self.obj.index = 0
+
+ progress.dump(self.stack, runner.get_orig()[1])
+ sys.exit(0)
+
+ def nstarred(self):
+ """Get total number of starred cards"""
+ return [card for card in self.stack if card.starred]
+
+ def disp_bar(self):
+ """
+ Display the statusbar at the bottom of the screen with progress, star
+ status, and card side.
+ """
+ (mlines, _) = self.win.getmaxyx()
+
+ # Calculate percent done
+ if len(self.stack) <= 1:
+ percent = "100"
+ else:
+ percent = str(
+ round(self.obj.index / (len(self.stack) - 1) * 100)
+ ).zfill(2)
+
+ # Print yellow if starred
+ if self.current_card().starred:
+ star_color = curses.color_pair(3)
+ else:
+ star_color = curses.color_pair(1)
+
+ # Create bar component
+ bar_start = "["
+ bar_middle = self.current_card().printStar()
+ bar_end = (
+ f"] [{len(self.nstarred())}/{str(len(self.stack))} starred] "
+ f"[{percent}% ("
+ f"{str(self.obj.index).zfill(len(str(len(self.stack))))}"
+ f"/{str(len(self.stack))})] ["
+ f"{self.headers[self.current_card().side]} ("
+ f"{str(int(self.current_card().side) + 1)})]"
+ )
+
+ # Put it all togethor
+ self.win.addstr(mlines - 1, 0, bar_start, curses.color_pair(1))
+ self.win.addstr(mlines - 1, len(bar_start), bar_middle, star_color)
+ self.win.addstr(
+ mlines - 1,
+ len(bar_start + bar_middle),
+ bar_end,
+ curses.color_pair(1),
+ )
+
+ def wrap_width(self):
+ """Calculate the width at which the body text should wrap"""
+ (_, mcols) = self.win.getmaxyx()
+ wrap_width = mcols - 20
+ if wrap_width > 80: