mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
Switch get_input()
to use prompt_toolkit
for input`.
# Context: USER: switch get_input() to use prompt_toolkit for input ASSISTANT: To switch `get_input()` to use `prompt_toolkit` for input, you'll need to install the `prompt_toolkit` library and replace the current input method with the `prompt_toolkit`'s `prompt` function. Here's how to make the change: 1. Install `prompt_toolkit` by adding it to your project's requirements or running `pip install prompt_toolkit`. 2. Import `prompt` from `prompt_toolkit` at the beginning of the `coder.py` file. 3. Replace the current input method in the `get_input()` function with the `prompt` function from `prompt_toolkit`. Here are the changes to the `coder.py` file: ```python coder.py <<<<<<< ORIGINAL import sys import re import readline import traceback ======= import sys import re import traceback from prompt_toolkit import prompt >>>>>>> UPDATED ``` ```python coder.py <<<<<<< ORIGINAL while True: try: if multiline_input: line = input(". ") else: line = input("> ") except EOFError: return ======= while True: try: if multiline_input: line = prompt(". ") else: line = prompt("> ") except EOFError: return >>>>>>> UPDATED ``` These changes will replace the standard `input()` function with the `prompt_toolkit`'s `prompt` function in the `get_input()` method.
This commit is contained in:
parent
ef7e63a728
commit
6ba8b7d41e
1 changed files with 10 additions and 11 deletions
19
coder.py
19
coder.py
|
@ -3,8 +3,8 @@
|
|||
|
||||
import sys
|
||||
import re
|
||||
import readline
|
||||
import traceback
|
||||
from prompt_toolkit import prompt
|
||||
from rich.console import Console
|
||||
from rich.prompt import Confirm, Prompt
|
||||
from colorama import Fore, Style
|
||||
|
@ -135,15 +135,14 @@ class Coder:
|
|||
else:
|
||||
print()
|
||||
|
||||
while True:
|
||||
try:
|
||||
if multiline_input:
|
||||
line = input(". ")
|
||||
else:
|
||||
line = input("> ")
|
||||
except EOFError:
|
||||
return
|
||||
|
||||
while True:
|
||||
try:
|
||||
if multiline_input:
|
||||
line = prompt(". ")
|
||||
else:
|
||||
line = prompt("> ")
|
||||
except EOFError:
|
||||
return
|
||||
if line.strip() == "{" and not multiline_input:
|
||||
multiline_input = True
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue