pager sizing fix
This commit is contained in:
+11
-8
@@ -27,17 +27,20 @@ def reflow(text):
|
|||||||
out = []
|
out = []
|
||||||
for line in text.split('\n'):
|
for line in text.split('\n'):
|
||||||
line = line.rstrip()
|
line = line.rstrip()
|
||||||
while len(line) > 0:
|
if len(line) == 0: # also handle effectively empty lines
|
||||||
out.append(line[0:REAL_TERM_COLS])
|
out.append('')
|
||||||
line = line[REAL_TERM_COLS:]
|
else:
|
||||||
|
while len(line) > 0:
|
||||||
|
out.append(line[0:REAL_TERM_COLS])
|
||||||
|
line = line[REAL_TERM_COLS:]
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def print_paged(text):
|
def print_paged(text):
|
||||||
"""Reflow and print the text in a paginated manner"""
|
"""Reflow and print the text in a paginated manner"""
|
||||||
lines = reflow(text)
|
lines = reflow(text)
|
||||||
ll = len(lines)
|
while True:
|
||||||
for i in range(0, ll, REAL_TERM_ROWS):
|
chunk = lines[0:REAL_TERM_ROWS]
|
||||||
chunk = lines[i:i + REAL_TERM_ROWS]
|
|
||||||
for line in chunk: print(line)
|
for line in chunk: print(line)
|
||||||
if i + REAL_TERM_ROWS < ll:
|
lines = lines[REAL_TERM_ROWS:]
|
||||||
input(CONT_MSG)
|
if len(lines) > 0: input(CONT_MSG)
|
||||||
|
else: break
|
||||||
|
|||||||
Reference in New Issue
Block a user