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:
Paul Gauthier 2023-05-09 09:03:45 -07:00
parent ef7e63a728
commit 6ba8b7d41e

View file

@ -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:
while True:
try:
if multiline_input:
line = input(". ")
line = prompt(". ")
else:
line = input("> ")
line = prompt("> ")
except EOFError:
return
if line.strip() == "{" and not multiline_input:
multiline_input = True
continue