pager sizing fix

This commit is contained in:
Luxferre
2025-12-21 14:29:42 +02:00
parent 8131297b88
commit 718ccc56a2
+11 -8
View File
@@ -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