From 25288728970368663a1343f73cf79453e4aa9968 Mon Sep 17 00:00:00 2001 From: Matteo Landi Date: Thu, 8 May 2025 17:01:04 +0200 Subject: [PATCH] First stab --- aider/args.py | 5 +++++ aider/io.py | 28 +++++++++++++++++----------- aider/main.py | 1 + aider/website/docs/config/dotenv.md | 3 +++ 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/aider/args.py b/aider/args.py index 08c9bde76..9e816f0ce 100644 --- a/aider/args.py +++ b/aider/args.py @@ -327,6 +327,11 @@ def get_parser(default_config_files, git_root): default="#00cc00", help="Set the color for user input (default: #00cc00)", ) + group.add_argument( + "--user-submitted-input-color", + default=None, + help="Set the color for user submitted input (default: #00cc00)", + ) group.add_argument( "--tool-output-color", default=None, diff --git a/aider/io.py b/aider/io.py index f28a1c86d..00df9ff3f 100644 --- a/aider/io.py +++ b/aider/io.py @@ -243,6 +243,7 @@ class InputOutput: input=None, output=None, user_input_color="blue", + user_submitted_input_color=None, tool_output_color=None, tool_error_color="red", tool_warning_color="#FFA500", @@ -281,6 +282,9 @@ class InputOutput: pretty = False self.user_input_color = ensure_hash_prefix(user_input_color) if pretty else None + self.user_submitted_input_color = ( + ensure_hash_prefix(user_submitted_input_color) if pretty else None + ) self.tool_output_color = ensure_hash_prefix(tool_output_color) if pretty else None self.tool_error_color = ensure_hash_prefix(tool_error_color) if pretty else None self.tool_warning_color = ensure_hash_prefix(tool_warning_color) if pretty else None @@ -343,6 +347,7 @@ class InputOutput: "output": self.output, "lexer": PygmentsLexer(MarkdownLexer), "editing_mode": self.editingmode, + "erase_when_done": True, } if self.editingmode == EditingMode.VI: session_kwargs["cursor"] = ModalCursorShapeConfig() @@ -369,6 +374,7 @@ class InputOutput: """Validate configured color strings and reset invalid ones.""" color_attributes = [ "user_input_color", + "user_submitted_input_color", "tool_output_color", "tool_error_color", "tool_warning_color", @@ -501,11 +507,11 @@ class InputOutput: raise def rule(self): - if self.pretty: - style = dict(style=self.user_input_color) if self.user_input_color else dict() - self.console.rule(**style) - else: - print() + if not self.pretty: + return "\n" + + columns = self.console.width + return "\n".join(["─" * columns, ""]) def interrupt_input(self): if self.prompt_session and self.prompt_session.app: @@ -523,18 +529,16 @@ class InputOutput: abs_read_only_fnames=None, edit_format=None, ): - self.rule() - # Ring the bell if needed self.ring_bell() rel_fnames = list(rel_fnames) - show = "" + show = self.rule() if rel_fnames: rel_read_only_fnames = [ get_rel_fname(fname, root) for fname in (abs_read_only_fnames or []) ] - show = self.format_files_for_input(rel_fnames, rel_read_only_fnames) + show += self.format_files_for_input(rel_fnames, rel_read_only_fnames) prompt_prefix = "" if edit_format: @@ -658,6 +662,7 @@ class InputOutput: complete_while_typing=True, prompt_continuation=get_continuation, ) + self.display_user_input(show + line) else: line = input(show) @@ -754,8 +759,8 @@ class InputOutput: log_file.write(content + "\n") def display_user_input(self, inp): - if self.pretty and self.user_input_color: - style = dict(style=self.user_input_color) + if self.pretty and self.user_submitted_input_color: + style = dict(style=self.user_submitted_input_color) else: style = dict() @@ -868,6 +873,7 @@ class InputOutput: style=style, complete_while_typing=False, ) + self.display_user_input(question + res) else: res = input(question) except EOFError: diff --git a/aider/main.py b/aider/main.py index ea344f0ba..8a666d37a 100644 --- a/aider/main.py +++ b/aider/main.py @@ -557,6 +557,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F input=input, output=output, user_input_color=args.user_input_color, + user_submitted_input_color=args.user_submitted_input_color, tool_output_color=args.tool_output_color, tool_warning_color=args.tool_warning_color, tool_error_color=args.tool_error_color, diff --git a/aider/website/docs/config/dotenv.md b/aider/website/docs/config/dotenv.md index 82ad974de..0856f40d1 100644 --- a/aider/website/docs/config/dotenv.md +++ b/aider/website/docs/config/dotenv.md @@ -202,6 +202,9 @@ cog.outl("```") ## Set the color for user input (default: #00cc00) #AIDER_USER_INPUT_COLOR=#00cc00 +## Set the color for user submitted input (default: None) +#AIDER_USER_SUBMITTED_INPUT_COLOR= + ## Set the color for tool output (default: None) #AIDER_TOOL_OUTPUT_COLOR=