Skip to content

Commit 907e114

Browse files
cleanup.
1 parent 900e5d7 commit 907e114

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/prompt_toolkit/shortcuts/choice_input.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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()

src/prompt_toolkit/shortcuts/prompt.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ class PromptSession(Generic[_T]):
320320
yet. Unlike the `default` parameter, this won't be returned as part of
321321
the output ever. This can be formatted text or a callable that returns
322322
formatted text.
323+
:param show_frame: `bool` or
324+
:class:`~prompt_toolkit.filters.Filter`. When True, surround the input
325+
with a frame.
323326
:param refresh_interval: (number; in seconds) When given, refresh the UI
324327
every so many seconds.
325328
:param input: `Input` object. (Note that the preferred way to change the

0 commit comments

Comments
 (0)