Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/prompt_toolkit/application/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ def _restore_sigint_from_ctypes() -> Generator[None, None, None]:
have_ctypes_signal = False
else:
# GraalPy has the functions, but they don't work
have_ctypes_signal = sys.implementation.name != 'graalpy'
have_ctypes_signal = sys.implementation.name != "graalpy"

if have_ctypes_signal:
# PyOS_sighandler_t PyOS_getsig(int i)
Expand Down
15 changes: 13 additions & 2 deletions src/prompt_toolkit/shortcuts/choice_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
to_filter,
)
from prompt_toolkit.formatted_text import AnyFormattedText
from prompt_toolkit.key_binding.key_bindings import KeyBindings
from prompt_toolkit.key_binding.key_bindings import (
DynamicKeyBindings,
KeyBindings,
KeyBindingsBase,
merge_key_bindings,
)
from prompt_toolkit.key_binding.key_processor import KeyPressEvent
from prompt_toolkit.layout import (
AnyContainer,
Expand Down Expand Up @@ -96,6 +101,7 @@ def __init__(
enable_suspend: FilterOrBool = False,
enable_interrupt: FilterOrBool = True,
interrupt_exception: type[BaseException] = KeyboardInterrupt,
key_bindings: KeyBindingsBase | None = None,
) -> None:
if style is None:
style = create_default_choice_input_style()
Expand All @@ -111,6 +117,7 @@ def __init__(
self.interrupt_exception = interrupt_exception
self.enable_interrupt = enable_interrupt
self.bottom_toolbar = bottom_toolbar
self.key_bindings = key_bindings

def _create_application(self) -> Application[_T]:
radio_list = RadioList(
Expand Down Expand Up @@ -225,7 +232,9 @@ def _suspend(event: E) -> None:
layout=layout,
full_screen=False,
mouse_support=self.mouse_support,
key_bindings=kb,
key_bindings=merge_key_bindings(
[kb, DynamicKeyBindings(lambda: self.key_bindings)]
),
style=self.style,
)

Expand All @@ -249,6 +258,7 @@ def choice(
enable_suspend: FilterOrBool = False,
enable_interrupt: FilterOrBool = True,
interrupt_exception: type[BaseException] = KeyboardInterrupt,
key_bindings: KeyBindingsBase | None = None,
) -> _T:
"""
Choice selection prompt. Ask the user to choose among a set of options.
Expand Down Expand Up @@ -297,4 +307,5 @@ def choice(
enable_suspend=enable_suspend,
enable_interrupt=enable_interrupt,
interrupt_exception=interrupt_exception,
key_bindings=key_bindings,
).prompt()
3 changes: 3 additions & 0 deletions src/prompt_toolkit/shortcuts/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,7 @@ async def prompt_async(
enable_open_in_editor: FilterOrBool | None = None,
tempfile_suffix: str | Callable[[], str] | None = None,
tempfile: str | Callable[[], str] | None = None,
show_frame: FilterOrBool = False,
# Following arguments are specific to the current `prompt()` call.
default: str | Document = "",
accept_default: bool = False,
Expand Down Expand Up @@ -1233,6 +1234,8 @@ async def prompt_async(
self.tempfile_suffix = tempfile_suffix
if tempfile is not None:
self.tempfile = tempfile
if show_frame is not None:
self.show_frame = show_frame

self._add_pre_run_callables(pre_run, accept_default)
self.default_buffer.reset(
Expand Down