Make lines that run too close to the edge of the screen wrap properly
This commit is contained in:
parent
a1f504858c
commit
af025064f4
1 changed files with 16 additions and 4 deletions
|
@ -34,10 +34,22 @@ def slowWrite(window, text, pause = LETTER_PAUSE, fake_user = False, silent = Fa
|
||||||
"""
|
"""
|
||||||
if not fake_user and not silent:
|
if not fake_user and not silent:
|
||||||
addSound("beep")
|
addSound("beep")
|
||||||
for i in range(len(text)):
|
width = window.getmaxyx()[1]
|
||||||
window.addstr(text[i])
|
texts = {0: text}
|
||||||
window.refresh()
|
if len(text) > width:
|
||||||
curses.napms(pause)
|
while any(len(texts[ind]) > width for ind in texts.keys()):
|
||||||
|
i = 0;
|
||||||
|
for ind in texts.keys():
|
||||||
|
if len(texts[ind]) > width:
|
||||||
|
break
|
||||||
|
i += 1
|
||||||
|
texts[i+1] = f"{texts[i].split()[-1].strip()}{' '+texts[i+1].strip() if texts.get(i+1) else ''}\n"
|
||||||
|
texts[i] = ' '.join(texts[i].split()[:-1]).strip() + '\n'
|
||||||
|
for txt in texts.values():
|
||||||
|
for i in range(len(txt)):
|
||||||
|
window.addstr(txt[i])
|
||||||
|
window.refresh()
|
||||||
|
curses.napms(pause)
|
||||||
if fake_user and not silent:
|
if fake_user and not silent:
|
||||||
_playSound("keyenter", True)
|
_playSound("keyenter", True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue