X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=lightcards%2Fdisplay.py;h=aa5beed58c70c7b4a14a4b86ed9c8648ffde9eb1;hb=4e5a09ff518efbffe31ce064334cb1db1d42eae4;hp=06e8148833254b30e58a810b86f04bd5547e8bed;hpb=c0b68087aa5cc9a901c27179bd42eb6082b22e67;p=lightcards.git diff --git a/lightcards/display.py b/lightcards/display.py index 06e8148..aa5beed 100644 --- a/lightcards/display.py +++ b/lightcards/display.py @@ -6,6 +6,7 @@ import curses.panel from random import shuffle import sys import textwrap +import time from . import runner, progress @@ -177,9 +178,6 @@ class Menu: self.menu_print("Stars only!") else: self.menu_print("ERR: None are starred!", err=True) - elif key in ["h", "KEY_LEFT"]: - self.outer.obj.index = len(self.outer.stack) - 1 - self.outer.get_key() elif key == "r": self.outer.obj.index = 0 self.outer.get_key() @@ -219,6 +217,25 @@ class Display: self.get_key() + def check_size(self): + (mlines, mcols) = self.win.getmaxyx() + + while mlines < 24 or mcols < 60: + self.main_win.clear() + self.main_win.addstr( + 0, + 0, + textwrap.fill( + "Terminal too small! Min size 60x24", width=mcols + ), + ) + self.main_win.redrawwin() + self.main_win.refresh() + (mlines, mcols) = self.win.getmaxyx() + time.sleep(0.1) + else: + self.disp_card() + def update_panels(self): """Update panel and window contents""" curses.panel.update_panels() @@ -347,8 +364,8 @@ class Display: Display a card and wait for the input. Used as a general way of getting back into the card flow from a menu """ - self.disp_card() while True: + self.check_size() key = self.win.getkey() if key == "q": self.leave() @@ -390,6 +407,9 @@ 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,