mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
WIP: Add prompt_toolkit style and use it in prompt.
This commit is contained in:
parent
240d1fa727
commit
85fb17710f
1 changed files with 17 additions and 14 deletions
31
coder.py
31
coder.py
|
@ -7,9 +7,11 @@ import traceback
|
||||||
from prompt_toolkit import prompt
|
from prompt_toolkit import prompt
|
||||||
from prompt_toolkit.completion import Completer, Completion
|
from prompt_toolkit.completion import Completer, Completion
|
||||||
from prompt_toolkit.history import FileHistory
|
from prompt_toolkit.history import FileHistory
|
||||||
|
from prompt_toolkit.styles import Style
|
||||||
|
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.prompt import Confirm, Prompt
|
from rich.prompt import Confirm, Prompt
|
||||||
from colorama import Style
|
|
||||||
from rich.live import Live
|
from rich.live import Live
|
||||||
from rich.text import Text
|
from rich.text import Text
|
||||||
from rich.markdown import Markdown
|
from rich.markdown import Markdown
|
||||||
|
@ -148,18 +150,22 @@ class Coder:
|
||||||
inp = ""
|
inp = ""
|
||||||
multiline_input = False
|
multiline_input = False
|
||||||
|
|
||||||
|
style = Style.from_dict({'': 'green'})
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
completer_instance = FileContentCompleter(self.fnames)
|
||||||
|
if multiline_input:
|
||||||
|
show = ". "
|
||||||
|
else:
|
||||||
|
show = "> "
|
||||||
|
|
||||||
try:
|
try:
|
||||||
completer_instance = FileContentCompleter(self.fnames)
|
line = prompt(
|
||||||
if multiline_input:
|
show,
|
||||||
show = ". "
|
completer=completer_instance,
|
||||||
else:
|
history=FileHistory(self.history_file),
|
||||||
show = "> "
|
style=style,
|
||||||
line = prompt(
|
)
|
||||||
show,
|
|
||||||
completer=completer_instance,
|
|
||||||
history=FileHistory(self.history_file),
|
|
||||||
)
|
|
||||||
except EOFError:
|
except EOFError:
|
||||||
return
|
return
|
||||||
if line.strip() == "{" and not multiline_input:
|
if line.strip() == "{" and not multiline_input:
|
||||||
|
@ -209,9 +215,6 @@ class Coder:
|
||||||
break
|
break
|
||||||
self.console.print("[bold red]^C again to quit")
|
self.console.print("[bold red]^C again to quit")
|
||||||
|
|
||||||
if self.pretty:
|
|
||||||
print(Style.RESET_ALL)
|
|
||||||
|
|
||||||
def run_loop(self):
|
def run_loop(self):
|
||||||
inp = self.get_input()
|
inp = self.get_input()
|
||||||
if inp is None:
|
if inp is None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue