From 86eaf8495475ffb986efcd7fbf11ada2835c88e4 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Fri, 12 Feb 2021 09:14:21 -0500 Subject: [PATCH] Reduce number of screen refreshes --- lightcards/display.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lightcards/display.py b/lightcards/display.py index 5dc354e..6f572ad 100644 --- a/lightcards/display.py +++ b/lightcards/display.py @@ -26,7 +26,6 @@ class Help: (self.win, self.panel) = panel_create(mlines, mcols) self.panel.top() self.panel.hide() - self.win.clear() text = [ "Welcome to runner. Here are some keybindings", @@ -204,7 +203,6 @@ class Display: def run(self, stdscr): """Set important options that require stdscr before starting""" self.win = stdscr - (mlines, mcols) = self.win.getmaxyx() curses.curs_set(0) # Hide cursor curses.use_default_colors() # Allow transparency curses.init_pair(1, curses.COLOR_CYAN, -1) @@ -229,7 +227,6 @@ class Display: "Terminal too small! Min size 60x24", width=mcols ), ) - self.win.redrawwin() self.win.refresh() (mlines, mcols) = self.win.getmaxyx() time.sleep(0.1) @@ -239,7 +236,7 @@ class Display: def update_panels(self): """Update panel and window contents""" curses.panel.update_panels() - self.win.refresh() + curses.doupdate() def leave(self): """Pickle stack before quitting""" @@ -311,9 +308,10 @@ class Display: Shows a header, a horizontal line, and the contents of the current side. """ - (mlines, mcols) = self.win.getmaxyx() + (_, mcols) = self.win.getmaxyx() self.main_panel.bottom() self.win.clear() + # If on the back of the card, show the content of the front side in # the header num_done = str(self.obj.index + 1).zfill(len(str(len(self.stack)))) @@ -328,6 +326,7 @@ class Display: + str(self.current_card().front) + '"' ) + header_width = mcols if mcols > 80: header_width = 80 @@ -407,9 +406,6 @@ class Display: (mlines, mcols) = self.win.getmaxyx() left = mcols - 19 - for i in range(20): - self.win.addch(0, mcols - 20 + i, " ") - self.win.addstr( 0, mcols - 16, -- 2.39.2