]> git.armaanb.net Git - lightcards.git/blobdiff - lightcards/display.py
Set index to 0 before saving if at end of set
[lightcards.git] / lightcards / display.py
index 9ed12e2e41548b29f8e5526ddd0702222caaf828..b4076e57a5e8ac20a6d262c43c2d467d93f75421 100644 (file)
@@ -24,6 +24,9 @@ class Display():
         self.get_key()
 
     def leave(self):
+        if self.obj.getIdx() == len(self.stack):
+            self.obj.setIdx(0)
+
         progress.dump((self.obj, self.stack, self.headers), self.stack)
         sys.exit(0)
 
@@ -32,7 +35,7 @@ class Display():
         Display the statusbar at the bottom of the screen with progress, star
         status, and card side.
         """
-        (mlines, mcols) = self.win.getmaxyx()
+        (mlines, _) = self.win.getmaxyx()
 
         # Calculate percent done
         if len(self.stack) <= 1:
@@ -62,7 +65,6 @@ class Display():
         self.win.insstr(bar_end, curses.color_pair(1))
 
     def menu_print(self, string, err=False):
-        (mlines, mcols) = self.win.getmaxyx()
         self.win.clear()
         if err:
             color = curses.color_pair(2)
@@ -151,7 +153,7 @@ class Display():
             self.menu_grab()
 
     def wrap_width(self):
-        (mlines, mcols) = self.win.getmaxyx()
+        (_, mcols) = self.win.getmaxyx()
         wrap_width = mcols
         if mcols > 80:
             wrap_width = 80
@@ -164,7 +166,7 @@ class Display():
         side.
         """
         self.win.clear()
-        (mlines, mcols) = self.win.getmaxyx()
+        (_, mcols) = self.win.getmaxyx()
         if self.obj.getIdx() == len(self.stack):
             self.disp_menu(quit=True)
         else: