diff --git a/src/prompt_toolkit/application/application.py b/src/prompt_toolkit/application/application.py index dfd440731..f27ada1a0 100644 --- a/src/prompt_toolkit/application/application.py +++ b/src/prompt_toolkit/application/application.py @@ -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) diff --git a/src/prompt_toolkit/shortcuts/choice_input.py b/src/prompt_toolkit/shortcuts/choice_input.py index d691df6db..95ffd0b5b 100644 --- a/src/prompt_toolkit/shortcuts/choice_input.py +++ b/src/prompt_toolkit/shortcuts/choice_input.py @@ -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, @@ -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() @@ -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( @@ -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, ) @@ -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. @@ -297,4 +307,5 @@ def choice( enable_suspend=enable_suspend, enable_interrupt=enable_interrupt, interrupt_exception=interrupt_exception, + key_bindings=key_bindings, ).prompt() diff --git a/src/prompt_toolkit/shortcuts/prompt.py b/src/prompt_toolkit/shortcuts/prompt.py index 18233e13b..68cfeb9aa 100644 --- a/src/prompt_toolkit/shortcuts/prompt.py +++ b/src/prompt_toolkit/shortcuts/prompt.py @@ -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, @@ -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(