small fixes

This commit is contained in:
Minecon724 2024-07-13 10:35:36 +02:00
parent 547a8fcab2
commit ba2b7914f6
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
2 changed files with 21 additions and 4 deletions

View file

@ -1 +1,13 @@
asdasdhello worlasnigasaafaaafaasddsfasddsadsasdsdaasdsasdadasdadsasdasdddadakasdfsfd
lorem ipsujm dolor sit amet ealfd jfjfa ioeaao e la skdf aakajkaj adsf
never gonna give you up
never gonna let you down
never gonna run around
and desert
___
..........----...../ \....
/\
||
||
desert

View file

@ -129,8 +129,9 @@ def move_up(y: int, x: int, line_pos: int, cur_line: int, lines: list[str], ncol
if cur_line > 0:
cur_line -= 1
if line_pos > 0:
line_pos = 0
line_len = len(lines[cur_line])
if line_pos > line_len:
line_pos = line_len
else:
return None
@ -202,6 +203,8 @@ def main(lines: list[str]):
if mv is None:
rprint(KEY_BELL)
else:
if line_pos == 0:
del lines[cur_line]
y, x, line_pos, cur_line = mv
move(y, x)
rprint(' ')
@ -240,7 +243,9 @@ if __name__ == "__main__":
if exists:
with open('file.txt', 'w') as file:
file.writelines(lines)
if lines[-1] == '':
del lines[-1]
file.writelines([l + '\n' for l in lines])
"""OLD CODE