Skip to content

Commit 3767d50

Browse files
shaunabananajonathanslenders
authored andcommitted
Expose raw parameter from prompt-toolkit to allow escape sequences to print normally.
1 parent c22b59d commit 3767d50

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ptpython/repl.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ def embed(
525525
title: str | None = ...,
526526
startup_paths: Sequence[str | Path] | None = ...,
527527
patch_stdout: bool = ...,
528+
patch_stdout_raw: bool = ...,
528529
return_asyncio_coroutine: Literal[False] = ...,
529530
) -> None: ...
530531

@@ -539,6 +540,7 @@ def embed(
539540
title: str | None = ...,
540541
startup_paths: Sequence[str | Path] | None = ...,
541542
patch_stdout: bool = ...,
543+
patch_stdout_raw: bool = ...,
542544
return_asyncio_coroutine: Literal[True] = ...,
543545
) -> Coroutine[Any, Any, None]: ...
544546

@@ -552,6 +554,7 @@ def embed(
552554
title: str | None = None,
553555
startup_paths: Sequence[str | Path] | None = None,
554556
patch_stdout: bool = False,
557+
patch_stdout_raw: bool = False,
555558
return_asyncio_coroutine: bool = False,
556559
) -> None | Coroutine[Any, Any, None]:
557560
"""
@@ -567,6 +570,7 @@ def embed(
567570
:param title: Title to be displayed in the terminal titlebar. (None or string.)
568571
:param patch_stdout: When true, patch `sys.stdout` so that background
569572
threads that are printing will print nicely above the prompt.
573+
:param patch_stdout_raw: When true, patch_stdout will not escape/remove vt100 terminal escape sequences.
570574
"""
571575
# Default globals/locals
572576
if globals is None:
@@ -602,7 +606,7 @@ def get_locals() -> dict[str, Any]:
602606

603607
# Start repl.
604608
patch_context: ContextManager[None] = (
605-
patch_stdout_context() if patch_stdout else DummyContext()
609+
patch_stdout_context(raw=patch_stdout_raw) if patch_stdout else DummyContext()
606610
)
607611

608612
if return_asyncio_coroutine:

0 commit comments

Comments
 (0)