From bc173e90c815981fb6c5e8e10e7ee39439076b43 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Sat, 30 Jan 2021 18:34:58 -0500 Subject: [PATCH] Add label for current side --- lightcards/display.py | 18 +++++++++++------- lightcards/lightcards.py | 6 +++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lightcards/display.py b/lightcards/display.py index 988270b..10f2f4d 100755 --- a/lightcards/display.py +++ b/lightcards/display.py @@ -31,13 +31,17 @@ class Status(): return self.index -def disp_card(stdscr, stack, obj): +def disp_card(stdscr, stack, headers, obj): stdscr.clear() - stdscr.addstr(str(stack[obj.getIdx()][obj.getSide()])) + side_title = headers[obj.getSide()] + stdscr.addstr(side_title + "\n") + for i in range(len(side_title)): + stdscr.addstr("=") + stdscr.addstr("\n" + str(stack[obj.getIdx()][obj.getSide()])) -def get_key(stdscr, stack): +def get_key(stdscr, stack, headers): idx = Status() - disp_card(stdscr, stack, idx) + disp_card(stdscr, stack, headers, idx) while True: key = stdscr.getkey() @@ -47,13 +51,13 @@ def get_key(stdscr, stack): if key == "j": idx.forward(stack) idx.setSide(0) - disp_card(stdscr, stack, idx) + disp_card(stdscr, stack, headers, idx) if key == "k": idx.back() idx.setSide(0) - disp_card(stdscr, stack, idx) + disp_card(stdscr, stack, headers, idx) if key == "l" or key == "h": idx.flip() - disp_card(stdscr, stack, idx) + disp_card(stdscr, stack, headers, idx) except Exception: pass diff --git a/lightcards/lightcards.py b/lightcards/lightcards.py index 968f86c..23f94df 100755 --- a/lightcards/lightcards.py +++ b/lightcards/lightcards.py @@ -20,8 +20,8 @@ def parse_args(): return parser.parse_args() -def show(stack): - wrapper(display.get_key, stack) +def show(stack, headers): + wrapper(display.get_key, stack, headers) def main(): @@ -32,7 +32,7 @@ def main(): headers = parse.parse_html(parse.md2html(args.inp[0]))[0] stack = parse.parse_html(parse.md2html(args.inp[0]))[1] - show(stack) + show(stack, headers) if __name__ == "__main__": -- 2.39.2