Make lines that run too close to the edge of the screen wrap properly

This commit is contained in:
Firepup Sixfifty 2024-04-27 20:14:57 -05:00
parent a1f504858c
commit af025064f4
Signed by: Firepup650
GPG key ID: 7C92E2ABBBFAB9BA

View file

@ -34,8 +34,20 @@ def slowWrite(window, text, pause = LETTER_PAUSE, fake_user = False, silent = Fa
"""
if not fake_user and not silent:
addSound("beep")
for i in range(len(text)):
window.addstr(text[i])
width = window.getmaxyx()[1]
texts = {0: text}
if len(text) > width:
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: