From 718ccc56a2b1181ead8bb3827acf364c73da45ca Mon Sep 17 00:00:00 2001 From: Luxferre Date: Sun, 21 Dec 2025 14:29:42 +0200 Subject: [PATCH] pager sizing fix --- deck/pager.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/deck/pager.py b/deck/pager.py index 0aa5c3f..48ceb56 100644 --- a/deck/pager.py +++ b/deck/pager.py @@ -27,17 +27,20 @@ def reflow(text): out = [] for line in text.split('\n'): line = line.rstrip() - while len(line) > 0: - out.append(line[0:REAL_TERM_COLS]) - line = line[REAL_TERM_COLS:] + if len(line) == 0: # also handle effectively empty lines + out.append('') + else: + while len(line) > 0: + out.append(line[0:REAL_TERM_COLS]) + line = line[REAL_TERM_COLS:] return out def print_paged(text): """Reflow and print the text in a paginated manner""" lines = reflow(text) - ll = len(lines) - for i in range(0, ll, REAL_TERM_ROWS): - chunk = lines[i:i + REAL_TERM_ROWS] + while True: + chunk = lines[0:REAL_TERM_ROWS] for line in chunk: print(line) - if i + REAL_TERM_ROWS < ll: - input(CONT_MSG) + lines = lines[REAL_TERM_ROWS:] + if len(lines) > 0: input(CONT_MSG) + else: break