]> git.armaanb.net Git - lightcards.git/blobdiff - lightcards/display.py
Follow XDG_CACHE_HOME
[lightcards.git] / lightcards / display.py
index 8023ff37338fe273f00345cafe0591696fb189b8..f93b0fa58921f1aa881e97a11d6d2db1d24cf737 100644 (file)
@@ -9,7 +9,7 @@ import sys
 import textwrap
 import time
 
-from . import runner, progress, parse, config
+from . import runner, progress, parse
 
 
 def panel_create(x, y):
@@ -50,14 +50,14 @@ class Quit:
         (mlines, mcols) = self.outer.win.getmaxyx()
         self.win.mvwin(int(mlines / 2) - 3, int(mcols / 2) - 10)
         self.panel.show()
-
-        while True:
-            key = self.win.getkey()
-            if key == "y":
-                break
-            elif key == "n":
-                self.panel.hide()
-                self.outer.get_key()
+        if self.outer.config["confirm_quit"]:
+            while True:
+                key = self.win.getkey()
+                if key == "y":
+                    break
+                elif key == "n":
+                    self.panel.hide()
+                    self.outer.get_key()
 
 
 class Help:
@@ -151,6 +151,10 @@ class Menu:
 
         self.win.box()
 
+    def clear_msg(self):
+        for i in range(42):
+            self.win.addch(15, i + 1, " ")
+
     def menu_print(self, string, err=False):
         """Print messages on the menu screen"""
         if err:
@@ -220,8 +224,7 @@ class Menu:
         Display a menu offering multiple options on how to manipulate the deck
         and to continue
         """
-        for i in range(42):
-            self.win.addch(14, i + 1, " ")
+        self.clear_msg()
 
         (mlines, mcols) = self.outer.win.getmaxyx()
         self.win.mvwin(int(mlines / 2) - 8, int(mcols / 2) - 22)
@@ -231,22 +234,22 @@ class Menu:
 
 
 class Display:
-    def __init__(self, stack, headers, obj, view, args):
+    def __init__(self, stack, headers, obj, view, args, conf):
         self.stack = stack
         self.headers = headers
         self.obj = obj
         self.view = view
         self.input_file = args.inp[0]
-        self.config = config.read_file(args.config)
+        self.config = conf
 
     def run(self, stdscr):
         """Set important options that require stdscr before starting"""
         self.win = stdscr
         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)
+        curses.init_pair(1, self.config["highlight_color"], -1)
+        curses.init_pair(2, self.config["error_color"], -1)
+        curses.init_pair(3, self.config["starred_color"], -1)
 
         self.main_panel = curses.panel.new_panel(self.win)
         self.menu_obj = Menu(self)
@@ -351,10 +354,11 @@ class Display:
                 - 1
             )
         ):
-            # TODO: Use the variying width unicode block characters to make a
-            # super accurate bar
             self.win.addch(
-                height + 1, i + len(progress), "ยป", curses.color_pair(1)
+                height + 1,
+                i + len(progress),
+                self.config["progress_char"],
+                curses.color_pair(1),
             )
 
     def wrap_width(self):
@@ -477,7 +481,8 @@ class Display:
                 self.disp_card()
             elif key in self.config["card_next"]:
                 if self.obj.index + 1 == len(self.stack):
-                    self.menu_obj.disp()
+                    if self.config["show_menu_at_end"]:
+                        self.menu_obj.disp()
                 else:
                     self.obj.forward(self.stack)
                     self.current_card().side = 0