From 8c88d0fca84f9d0616b93faa4a2416ae33149d7e Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 9 May 2023 09:48:17 -0700 Subject: [PATCH] cleaned up filehistory --- coder.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/coder.py b/coder.py index 7ea42eca8..b35f4e9c0 100755 --- a/coder.py +++ b/coder.py @@ -9,7 +9,7 @@ from prompt_toolkit.completion import Completer, Completion from prompt_toolkit.history import FileHistory from rich.console import Console from rich.prompt import Confirm, Prompt -from colorama import Fore, Style +from colorama import Style from rich.live import Live from rich.text import Text from rich.markdown import Markdown @@ -46,17 +46,14 @@ class FileContentCompleter(Completer): if word.startswith(last_word): yield Completion(word, start_position=-len(last_word)) + class Coder: fnames = dict() last_modified = 0 repo = None + def __init__(self, main_model, files, pretty, history_file=".coder.history"): self.history_file = history_file - try: - #readline.read_history_file(self.history_file) - pass - except FileNotFoundError: - pass if pretty: self.console = Console() @@ -150,18 +147,19 @@ class Coder: inp = "" multiline_input = False - if self.pretty: - print(Fore.GREEN, end="\r") - else: - print() while True: try: completer_instance = FileContentCompleter(self.fnames) if multiline_input: - line = prompt(". ", completer=completer_instance, history=FileHistory(self.history_file)) + show = ". " else: - line = prompt("> ", completer=completer_instance, history=FileHistory(self.history_file)) + show = "> " + line = prompt( + show, + completer=completer_instance, + history=FileHistory(self.history_file), + ) except EOFError: return if line.strip() == "{" and not multiline_input: @@ -175,12 +173,7 @@ class Coder: inp = line break - if self.pretty: - print(Style.RESET_ALL) - else: - print() - - #readline.write_history_file(self.history_file) + print() return inp def get_last_modified(self):