@@ -53,6 +53,16 @@ class ChoiceInput(Generic[_T]):
5353 considered the default.
5454 :param mouse_support: Enable mouse support.
5555 :param style: :class:`.Style` instance for the color scheme.
56+ :param symbol: Symbol to be displayed in front of the selected choice.
57+ :param show_frame: `bool` or
58+ :class:`~prompt_toolkit.filters.Filter`. When True, surround the input
59+ with a frame.
60+ :param enable_interrupt: `bool` or
61+ :class:`~prompt_toolkit.filters.Filter`. When True, raise
62+ the ``interrupt_exception`` (``KeyboardInterrupt`` by default) when
63+ control-c has been pressed.
64+ :param interrupt_exception: The exception type that will be raised when
65+ there is a keyboard interrupt (control-c keypress).
5666 """
5767
5868 def __init__ (
@@ -66,7 +76,7 @@ def __init__(
6676 symbol : str = ">" ,
6777 show_frame : FilterOrBool = False ,
6878 enable_suspend : FilterOrBool = False ,
69- enable_abort : FilterOrBool = True ,
79+ enable_interrupt : FilterOrBool = True ,
7080 interrupt_exception : type [BaseException ] = KeyboardInterrupt ,
7181 ) -> None :
7282 if style is None :
@@ -81,7 +91,7 @@ def __init__(
8191 self .show_frame = show_frame
8292 self .enable_suspend = enable_suspend
8393 self .interrupt_exception = interrupt_exception
84- self .enable_abort = enable_abort
94+ self .enable_interrupt = enable_interrupt
8595
8696 def _create_application (self ) -> Application [_T ]:
8797 radio_list = RadioList (
@@ -139,11 +149,11 @@ def _accept_input(event: E) -> None:
139149 event .app .exit (result = radio_list .current_value , style = "class:accepted" )
140150
141151 @Condition
142- def enable_abort () -> bool :
143- return to_filter (self .enable_abort )()
152+ def enable_interrupt () -> bool :
153+ return to_filter (self .enable_interrupt )()
144154
145- @kb .add ("c-c" , filter = enable_abort )
146- @kb .add ("<sigint>" , filter = enable_abort )
155+ @kb .add ("c-c" , filter = enable_interrupt )
156+ @kb .add ("<sigint>" , filter = enable_interrupt )
147157 def _keyboard_interrupt (event : E ) -> None :
148158 "Abort when Control-C has been pressed."
149159 event .app .exit (exception = self .interrupt_exception (), style = "class:aborting" )
@@ -185,7 +195,7 @@ def choice(
185195 symbol : str = ">" ,
186196 show_frame : bool = False ,
187197 enable_suspend : FilterOrBool = False ,
188- enable_abort : FilterOrBool = True ,
198+ enable_interrupt : FilterOrBool = True ,
189199 interrupt_exception : type [BaseException ] = KeyboardInterrupt ,
190200) -> _T :
191201 """
@@ -220,6 +230,6 @@ def choice(
220230 symbol = symbol ,
221231 show_frame = show_frame ,
222232 enable_suspend = enable_suspend ,
223- enable_abort = enable_abort ,
233+ enable_interrupt = enable_abort ,
224234 interrupt_exception = interrupt_exception ,
225235 ).prompt ()
0 commit comments