mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 18:54:59 +00:00
refactor: centralize style creation logic by introducing _get_style method in InputOutput class
This commit is contained in:
parent
7e4e6782d1
commit
2c084d65d9
1 changed files with 34 additions and 33 deletions
67
aider/io.py
67
aider/io.py
|
@ -251,6 +251,16 @@ class InputOutput:
|
||||||
else:
|
else:
|
||||||
self.console = Console(force_terminal=False, no_color=True) # non-pretty
|
self.console = Console(force_terminal=False, no_color=True) # non-pretty
|
||||||
|
|
||||||
|
def _get_style(self, style_dict=None):
|
||||||
|
if self.pretty and self.user_input_color:
|
||||||
|
if style_dict is None:
|
||||||
|
style_dict = {"": self.user_input_color}
|
||||||
|
else:
|
||||||
|
style_dict.setdefault("", self.user_input_color)
|
||||||
|
return Style.from_dict(style_dict)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def read_image(self, filename):
|
def read_image(self, filename):
|
||||||
try:
|
try:
|
||||||
with open(str(filename), "rb") as image_file:
|
with open(str(filename), "rb") as image_file:
|
||||||
|
@ -328,22 +338,17 @@ class InputOutput:
|
||||||
inp = ""
|
inp = ""
|
||||||
multiline_input = False
|
multiline_input = False
|
||||||
|
|
||||||
if self.user_input_color and self.pretty:
|
style_dict = {
|
||||||
style = Style.from_dict(
|
"pygments.literal.string": f"bold italic {self.user_input_color}",
|
||||||
{
|
"completion-menu": (
|
||||||
"": self.user_input_color,
|
f"bg:{self.completion_menu_bg_color} {self.completion_menu_color}"
|
||||||
"pygments.literal.string": f"bold italic {self.user_input_color}",
|
),
|
||||||
"completion-menu": (
|
"completion-menu.completion.current": (
|
||||||
f"bg:{self.completion_menu_bg_color} {self.completion_menu_color}"
|
f"bg:{self.completion_menu_current_bg_color} "
|
||||||
),
|
f"{self.completion_menu_current_color}"
|
||||||
"completion-menu.completion.current": (
|
),
|
||||||
f"bg:{self.completion_menu_current_bg_color} "
|
}
|
||||||
f"{self.completion_menu_current_color}"
|
style = self._get_style(style_dict)
|
||||||
),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
style = None
|
|
||||||
|
|
||||||
completer_instance = ThreadedCompleter(
|
completer_instance = ThreadedCompleter(
|
||||||
AutoCompleter(
|
AutoCompleter(
|
||||||
|
@ -483,19 +488,18 @@ class InputOutput:
|
||||||
else:
|
else:
|
||||||
self.tool_output(subject, bold=True)
|
self.tool_output(subject, bold=True)
|
||||||
|
|
||||||
if self.pretty and self.user_input_color:
|
style_dict = {
|
||||||
style = {
|
"completion-menu": (
|
||||||
"": self.user_input_color,
|
f"bg:{self.completion_menu_bg_color} {self.completion_menu_color}"
|
||||||
"completion-menu": (
|
),
|
||||||
f"bg:{self.completion_menu_bg_color} {self.completion_menu_color}"
|
"completion-menu.completion.current": (
|
||||||
),
|
f"bg:{self.completion_menu_current_bg_color} "
|
||||||
"completion-menu.completion.current": (
|
f"{self.completion_menu_current_color}"
|
||||||
f"bg:{self.completion_menu_current_bg_color} "
|
),
|
||||||
f"{self.completion_menu_current_color}"
|
}
|
||||||
),
|
style = self._get_style(style_dict)
|
||||||
}
|
if style is None:
|
||||||
else:
|
style = {}
|
||||||
style = dict()
|
|
||||||
|
|
||||||
def is_valid_response(text):
|
def is_valid_response(text):
|
||||||
if not text:
|
if not text:
|
||||||
|
@ -558,10 +562,7 @@ class InputOutput:
|
||||||
self.tool_output()
|
self.tool_output()
|
||||||
self.tool_output(subject, bold=True)
|
self.tool_output(subject, bold=True)
|
||||||
|
|
||||||
if self.pretty and self.user_input_color:
|
style = self._get_style()
|
||||||
style = Style.from_dict({"": self.user_input_color})
|
|
||||||
else:
|
|
||||||
style = None
|
|
||||||
|
|
||||||
if self.yes is True:
|
if self.yes is True:
|
||||||
res = "yes"
|
res = "yes"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue