@@ -53,6 +53,16 @@ class ChoiceInput(Generic[_T]):
53
53
considered the default.
54
54
:param mouse_support: Enable mouse support.
55
55
: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).
56
66
"""
57
67
58
68
def __init__ (
@@ -66,7 +76,7 @@ def __init__(
66
76
symbol : str = ">" ,
67
77
show_frame : FilterOrBool = False ,
68
78
enable_suspend : FilterOrBool = False ,
69
- enable_abort : FilterOrBool = True ,
79
+ enable_interrupt : FilterOrBool = True ,
70
80
interrupt_exception : type [BaseException ] = KeyboardInterrupt ,
71
81
) -> None :
72
82
if style is None :
@@ -81,7 +91,7 @@ def __init__(
81
91
self .show_frame = show_frame
82
92
self .enable_suspend = enable_suspend
83
93
self .interrupt_exception = interrupt_exception
84
- self .enable_abort = enable_abort
94
+ self .enable_interrupt = enable_interrupt
85
95
86
96
def _create_application (self ) -> Application [_T ]:
87
97
radio_list = RadioList (
@@ -139,11 +149,11 @@ def _accept_input(event: E) -> None:
139
149
event .app .exit (result = radio_list .current_value , style = "class:accepted" )
140
150
141
151
@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 )()
144
154
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 )
147
157
def _keyboard_interrupt (event : E ) -> None :
148
158
"Abort when Control-C has been pressed."
149
159
event .app .exit (exception = self .interrupt_exception (), style = "class:aborting" )
@@ -185,7 +195,7 @@ def choice(
185
195
symbol : str = ">" ,
186
196
show_frame : bool = False ,
187
197
enable_suspend : FilterOrBool = False ,
188
- enable_abort : FilterOrBool = True ,
198
+ enable_interrupt : FilterOrBool = True ,
189
199
interrupt_exception : type [BaseException ] = KeyboardInterrupt ,
190
200
) -> _T :
191
201
"""
@@ -220,6 +230,6 @@ def choice(
220
230
symbol = symbol ,
221
231
show_frame = show_frame ,
222
232
enable_suspend = enable_suspend ,
223
- enable_abort = enable_abort ,
233
+ enable_interrupt = enable_abort ,
224
234
interrupt_exception = interrupt_exception ,
225
235
).prompt ()
0 commit comments