1
0
Fork 0

Merging upstream version 3.0.25.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-09 18:31:41 +01:00
parent 8e41bc821f
commit 7159687519
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
26 changed files with 770 additions and 530 deletions

View file

@ -2,26 +2,26 @@
"""
Example of embedding a Python REPL, and setting a custom prompt.
"""
from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.formatted_text import HTML, AnyFormattedText
from ptpython.prompt_style import PromptStyle
from ptpython.repl import embed
def configure(repl):
def configure(repl) -> None:
# Probably, the best is to add a new PromptStyle to `all_prompt_styles` and
# activate it. This way, the other styles are still selectable from the
# menu.
class CustomPrompt(PromptStyle):
def in_prompt(self):
def in_prompt(self) -> AnyFormattedText:
return HTML("<ansigreen>Input[%s]</ansigreen>: ") % (
repl.current_statement_index,
)
def in2_prompt(self, width):
def in2_prompt(self, width: int) -> AnyFormattedText:
return "...: ".rjust(width)
def out_prompt(self):
def out_prompt(self) -> AnyFormattedText:
return HTML("<ansired>Result[%s]</ansired>: ") % (
repl.current_statement_index,
)
@ -30,7 +30,7 @@ def configure(repl):
repl.prompt_style = "custom"
def main():
def main() -> None:
embed(globals(), locals(), configure=configure)