From ba2b7914f65515ae8543bb1da6cdab33e8be0d22 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Sat, 13 Jul 2024 10:35:36 +0200 Subject: [PATCH] small fixes --- file.txt | 14 +++++++++++++- writer/__main__.py | 11 ++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/file.txt b/file.txt index c362afb..5b5c304 100644 --- a/file.txt +++ b/file.txt @@ -1 +1,13 @@ -asdasdhello worlasnigasaafaaafaasddsfasddsadsasdsdaasdsasdadasdadsasdasdddadakasdfsfd \ No newline at end of file +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 diff --git a/writer/__main__.py b/writer/__main__.py index bb9e174..9e17be1 100644 --- a/writer/__main__.py +++ b/writer/__main__.py @@ -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