]> git.armaanb.net Git - lightcards.git/blobdiff - lightcards/display.py
Update status bar
[lightcards.git] / lightcards / display.py
index 42a01f220d2e57228f097925cda50bea07bb2a14..349d77abbb9417c9b363ea6943c59cf2166ae78e 100755 (executable)
@@ -16,18 +16,20 @@ def disp_card(stdscr, stack, headers, obj):
     stdscr.addstr("\n" + str(stack[obj.getIdx()][obj.getSide()]))
 
     (mlines, mcols) = stdscr.getmaxyx()
-    mlines -= 1
-    mcols -= 5
-
     try:
-        stdscr.insch(mlines, mcols, str(obj.getIdx() + 1))
-        stdscr.insch(mlines, mcols+1, '-')
-        if obj.getSide() == 0:
-            stdscr.insch(mlines, mcols+2, '1')
-        else:
-            stdscr.insch(mlines, mcols+2, '2')
-        stdscr.insch(mlines, mcols+3, '/')
-        stdscr.insch(mlines, mcols+4, str(len(stack)))
+        stdscr.insstr(mlines - 1, 1,
+                      "[" +
+                      stack[obj.getIdx()].getStar() +
+                      "] [" +
+                      str(round(obj.getIdx() / (len(stack) - 1) * 100)).zfill(3) +
+                      "% (" +
+                      str(obj.getIdx() + 1) +
+                      "/" +
+                      str(len(stack)) +
+                      ")]" +
+                      " [" +
+                      headers[obj.getSide()] +
+                      "]")
     except Exception:
         pass
 
@@ -53,5 +55,8 @@ def get_key(stdscr, stack, headers):
             elif key in ["j", "k", "KEY_UP", "KEY_DOWN"]:
                 idx.flip()
                 disp_card(stdscr, stack, headers, idx)
+            elif key in ["i", "/"]:
+                stack[idx.getIdx()].toggleStar()
+                disp_card(stdscr, stack, headers, idx)
         except Exception:
             pass