small fixes
This commit is contained in:
parent
547a8fcab2
commit
ba2b7914f6
2 changed files with 21 additions and 4 deletions
14
file.txt
14
file.txt
|
@ -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
|
||||||
|
|
|
@ -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:
|
if cur_line > 0:
|
||||||
cur_line -= 1
|
cur_line -= 1
|
||||||
if line_pos > 0:
|
line_len = len(lines[cur_line])
|
||||||
line_pos = 0
|
if line_pos > line_len:
|
||||||
|
line_pos = line_len
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -202,6 +203,8 @@ def main(lines: list[str]):
|
||||||
if mv is None:
|
if mv is None:
|
||||||
rprint(KEY_BELL)
|
rprint(KEY_BELL)
|
||||||
else:
|
else:
|
||||||
|
if line_pos == 0:
|
||||||
|
del lines[cur_line]
|
||||||
y, x, line_pos, cur_line = mv
|
y, x, line_pos, cur_line = mv
|
||||||
move(y, x)
|
move(y, x)
|
||||||
rprint(' ')
|
rprint(' ')
|
||||||
|
@ -240,7 +243,9 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
if exists:
|
if exists:
|
||||||
with open('file.txt', 'w') as file:
|
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
|
"""OLD CODE
|
||||||
|
|
Loading…
Reference in a new issue