Skip to content
Open
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
12 changes: 6 additions & 6 deletions InquirerPy/base/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ def __init__(
self._raise_kbi = not os.getenv(
"INQUIRERPY_NO_RAISE_KBI", not raise_keyboard_interrupt
)
self._is_rasing_kbi = Condition(lambda: self._raise_kbi)
self._is_raising_kbi = Condition(lambda: self._raise_kbi)

self._kb_maps = {
"answer": [{"key": Keys.Enter}],
"interrupt": [
{"key": "c-c", "filter": self._is_rasing_kbi},
{"key": "c-d", "filter": ~self._is_rasing_kbi},
{"key": "c-c", "filter": self._is_raising_kbi},
{"key": "c-d", "filter": ~self._is_raising_kbi},
],
"skip": [{"key": "c-z"}, {"key": "c-c", "filter": ~self._is_rasing_kbi}],
"skip": [{"key": "c-z"}, {"key": "c-c", "filter": ~self._is_raising_kbi}],
}
self._kb_func_lookup = {
"answer": [{"func": self._handle_enter}],
Expand Down Expand Up @@ -205,7 +205,7 @@ def register_kb(
"""Keybinding registration decorator.

This decorator wraps around the :meth:`prompt_toolkit.key_binding.KeyBindings.add` with
added feature to process `alt` realted keybindings.
added feature to process `alt` related keybindings.

By default, `prompt_toolkit` doesn't process `alt` related keybindings,
it requires `alt-ANY` to `escape` + `ANY`.
Expand All @@ -215,7 +215,7 @@ def register_kb(
filter: :class:`~prompt_toolkit.filter.Condition` to indicate if this keybinding should be active.

Returns:
A decorator that should be applied to the function thats intended to be active when the keys
A decorator that should be applied to the function that's intended to be active when the keys
are pressed.

Examples:
Expand Down
2 changes: 1 addition & 1 deletion InquirerPy/containers/spinner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SPINNERS(NamedTuple):
See Also:
https://github.com/pavdmyt/yaspin/blob/master/yaspin/data/spinners.json

This only contains some basic ones thats ready to use. For more patterns, checkout the
This only contains some basic ones that's ready to use. For more patterns, checkout the
URL above.

Examples:
Expand Down
4 changes: 2 additions & 2 deletions InquirerPy/containers/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ValidationWindow(ConditionalContainer):
"""Conditional `prompt_toolkit` :class:`~prompt_toolkit.layout.Window` that displays error.

Args:
invalid_message: Error message to display when error occured.
invalid_message: Error message to display when error occurred.
filter: Condition to display the error window.
"""

Expand All @@ -31,7 +31,7 @@ class ValidationFloat(Float):
""":class:`~prompt_toolkit.layout.Float` wrapper around :class:`.ValidationWindow`.

Args:
invalid_message: Error message to display when error occured.
invalid_message: Error message to display when error occurred.
filter: Condition to display the error window.
left: Distance to left.
right: Distance to right.
Expand Down
2 changes: 1 addition & 1 deletion InquirerPy/prompts/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class CheckboxPrompt(ListPrompt):
cycle: Return to top item if hit bottom during navigation or vice versa.
wrap_lines: Soft wrap question lines when question exceeds the terminal width.
raise_keyboard_interrupt: Raise the :class:`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
will be `None` and the question is skiped.
will be `None` and the question is skipped.
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
Expand Down
2 changes: 1 addition & 1 deletion InquirerPy/prompts/confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ConfirmPrompt(BaseSimplePrompt):
reject_letter: Letter used to reject the prompt. A keybinding will be created for this letter.
Default is `n` and pressing `n` will answer the prompt with value `False`.
raise_keyboard_interrupt: Raise the :class:`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
will be `None` and the question is skiped.
will be `None` and the question is skipped.
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
Expand Down
4 changes: 2 additions & 2 deletions InquirerPy/prompts/expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class ExpandPrompt(ListPrompt):

A wrapper class around :class:`~prompt_toolkit.application.Application`.

Contains a list of chocies binded to a shortcut letter.
Contains a list of choices binded to a shortcut letter.
The prompt can be expanded using `h` key.

Args:
Expand Down Expand Up @@ -257,7 +257,7 @@ class ExpandPrompt(ListPrompt):
cycle: Return to top item if hit bottom during navigation or vice versa.
wrap_lines: Soft wrap question lines when question exceeds the terminal width.
raise_keyboard_interrupt: Raise the :class:`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
will be `None` and the question is skiped.
will be `None` and the question is skipped.
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
Expand Down
2 changes: 1 addition & 1 deletion InquirerPy/prompts/filepath.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class FilePathPrompt(InputPrompt):
only_directories: Only complete directories.
only_files: Only complete files.
raise_keyboard_interrupt: Raise the :class:`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
will be `None` and the question is skiped.
will be `None` and the question is skipped.
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
Expand Down
20 changes: 10 additions & 10 deletions InquirerPy/prompts/fuzzy.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
class InquirerPyFuzzyControl(InquirerPyUIListControl):
"""An :class:`~prompt_toolkit.layout.UIControl` class that displays a list of choices.

This only displays the chocies. The actual input buffer will be handled by a separate
This only displays the chices. The actual input buffer will be handled by a separate
:class:`~prompt_toolkit.layout.BufferControl`.

Reference the parameter definition in :class:`.FuzzyPrompt`.
Expand Down Expand Up @@ -277,7 +277,7 @@ class FuzzyPrompt(BaseListPrompt):
Refer to :ref:`pages/kb:Keybindings` documentation for more details.
default: Set the default value in the search buffer.
Different than other list type prompts, the `default` parameter tries to replicate what fzf does and
add the value in `default` to search buffer so it starts searching immediatelly.
add the value in `default` to search buffer so it starts searching immediately.
Refer to :ref:`pages/dynamic:default` documentation for more details.
qmark: Question mark symbol. Custom symbol that will be displayed infront of the question before its answered.
amark: Answer mark symbol. Custom symbol that will be displayed infront of the question after its answered.
Expand Down Expand Up @@ -316,7 +316,7 @@ class FuzzyPrompt(BaseListPrompt):
cycle: Return to top item if hit bottom during navigation or vice versa.
wrap_lines: Soft wrap question lines when question exceeds the terminal width.
raise_keyboard_interrupt: Raise the :class:`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
will be `None` and the question is skiped.
will be `None` and the question is skipped.
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
Expand Down Expand Up @@ -406,7 +406,7 @@ def __init__(
else cast(Callable, default)(self._result)
)
self._height_offset += 1 # search input
self._dimmension_height, self._dimmension_max_height = calculate_height(
self._dimension_height, self._dimension_max_height = calculate_height(
height, max_height, height_offset=self.height_offset
)

Expand All @@ -415,7 +415,7 @@ def __init__(
pointer=pointer,
marker=marker,
current_text=self._get_current_text,
max_lines=self._dimmension_max_height,
max_lines=self._dimension_max_height,
session_result=session_result,
multiselect=multiselect,
marker_pl=marker_pl,
Expand All @@ -435,14 +435,14 @@ def __init__(
),
)

choice_height_dimmension = lambda: Dimension(
max=self._dimmension_max_height,
preferred=self._dimmension_height,
choice_height_dimension = lambda: Dimension(
max=self._dimension_max_height,
preferred=self._dimension_height,
min=self.content_control._height if self.content_control._height > 0 else 1,
)
self.choice_window = Window(
content=self.content_control,
height=choice_height_dimmension,
height=choice_height_dimension,
dont_extend_height=True,
)

Expand Down Expand Up @@ -640,7 +640,7 @@ def _handle_enter(self, event: "KeyPressEvent") -> None:
highlighted choice and return the value in a list.
Otherwise, return all TAB choices as a list.

In normal scenario, reutrn the current highlighted choice.
In normal scenario, return the current highlighted choice.

If current UI contains no choice due to filter, return None.
"""
Expand Down
4 changes: 2 additions & 2 deletions InquirerPy/prompts/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class InputPrompt(BaseSimplePrompt):
Refer to :ref:`pages/prompts/input:Auto Completion` documentation for more details.
multicolumn_complete: Change the auto-completion UI to a multi column display.
multiline: Enable multiline edit. While multiline edit is active, pressing `enter` won't complete the answer.
and will create a new line. Use `esc` followd by `enter` to complete the question.
and will create a new line. Use `esc` followed by `enter` to complete the question.
validate: Add validation to user input.
Refer to :ref:`pages/validator:Validator` documentation for more details.
invalid_message: Error message to display when user input is invalid.
Expand All @@ -67,7 +67,7 @@ class InputPrompt(BaseSimplePrompt):
Refer to :ref:`pages/kb:Keybindings` for more details.
wrap_lines: Soft wrap question lines when question exceeds the terminal width.
raise_keyboard_interrupt: Raise the :class:`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
will be `None` and the question is skiped.
will be `None` and the question is skipped.
is_password: Used internally for :class:`~InquirerPy.prompts.secret.SecretPrompt`.
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
Expand Down
10 changes: 5 additions & 5 deletions InquirerPy/prompts/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class ListPrompt(BaseListPrompt):
cycle: Return to top item if hit bottom during navigation or vice versa.
wrap_lines: Soft wrap question lines when question exceeds the terminal width.
raise_keyboard_interrupt: Raise the :class:`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
will be `None` and the question is skiped.
will be `None` and the question is skipped.
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
Expand Down Expand Up @@ -225,14 +225,14 @@ def __init__(
session_result=session_result,
)
self._show_cursor = show_cursor
self._dimmension_height, self._dimmension_max_height = calculate_height(
self._dimension_height, self._dimension_max_height = calculate_height(
height, max_height, height_offset=self.height_offset
)
main_content_window = Window(
content=self.content_control,
height=Dimension(
max=self._dimmension_max_height,
preferred=self._dimmension_height,
max=self._dimension_max_height,
preferred=self._dimension_height,
),
dont_extend_height=True,
)
Expand Down Expand Up @@ -303,7 +303,7 @@ def _handle_toggle_all(self, _, value: Optional[bool] = None) -> None:
"""Toggle all choice `enabled` status.

Args:
value: Sepcify a value to toggle.
value: Specify a value to toggle.
"""
if not self._multiselect:
return
Expand Down
2 changes: 1 addition & 1 deletion InquirerPy/prompts/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class NumberPrompt(BaseComplexPrompt):
Refer to :ref:`pages/kb:Keybindings` for more details.
wrap_lines: Soft wrap question lines when question exceeds the terminal width.
raise_keyboard_interrupt: Raise the :class:`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
will be `None` and the question is skiped.
will be `None` and the question is skipped.
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
Expand Down
2 changes: 1 addition & 1 deletion InquirerPy/prompts/rawlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class RawlistPrompt(ListPrompt):
cycle: Return to top item if hit bottom during navigation or vice versa.
wrap_lines: Soft wrap question lines when question exceeds the terminal width.
raise_keyboard_interrupt: Raise the :class:`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
will be `None` and the question is skiped.
will be `None` and the question is skipped.
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
Expand Down
2 changes: 1 addition & 1 deletion InquirerPy/prompts/secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SecretPrompt(InputPrompt):
Refer to :ref:`pages/kb:Keybindings` for more details.
wrap_lines: Soft wrap question lines when question exceeds the terminal width.
raise_keyboard_interrupt: Raise the :class:`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
will be `None` and the question is skiped.
will be `None` and the question is skipped.
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
Expand Down
2 changes: 1 addition & 1 deletion InquirerPy/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def prompt(
vi_mode: Use vim keybindings for the prompt instead of the default emacs keybindings.
Refer to :ref:`pages/kb:Keybindings` for more info.
raise_keyboard_interrupt: Raise the :class:`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
will be `None` and the question is skiped.
will be `None` and the question is skipped.
keybindings: List of custom :ref:`pages/kb:Keybindings` to apply. Refer to documentation for more info.
style_override: Override all default styles. When providing any style customisation, all default styles are removed when this is True.

Expand Down
26 changes: 13 additions & 13 deletions InquirerPy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,35 +205,35 @@ def calculate_height(
_, term_lines = shutil.get_terminal_size()
term_lines = term_lines
if not height:
dimmension_height = None
dimension_height = None
else:
if isinstance(height, str):
height = height.replace("%", "")
height = int(height)
dimmension_height = (
dimension_height = (
math.floor(term_lines * (height / 100)) - height_offset
)
else:
dimmension_height = height
dimension_height = height

if not max_height:
max_height = "70%" if not height else "100%"
if isinstance(max_height, str):
max_height = max_height.replace("%", "")
max_height = int(max_height)
dimmension_max_height = (
dimension_max_height = (
math.floor(term_lines * (max_height / 100)) - height_offset
)
else:
dimmension_max_height = max_height

if dimmension_height and dimmension_height > dimmension_max_height:
dimmension_height = dimmension_max_height
if dimmension_height and dimmension_height <= 0:
dimmension_height = 1
if dimmension_max_height <= 0:
dimmension_max_height = 1
return dimmension_height, dimmension_max_height
dimension_max_height = max_height

if dimension_height and dimension_height > dimension_max_height:
dimension_height = dimension_max_height
if dimension_height and dimension_height <= 0:
dimension_height = 1
if dimension_max_height <= 0:
dimension_max_height = 1
return dimension_height, dimension_max_height

except ValueError:
raise InvalidArgument(
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ as a list is not ideal in a lot of scenarios. Use `transformer` parameter to cus
## How can I do unittest when using `InquirerPy`?

```{tip}
Since `InquirerPy` module itself is tested, there's no need to mock any futher/deeper than the API entrypoint (`prompt` and `inquirer`).
Since `InquirerPy` module itself is tested, there's no need to mock any further/deeper than the API entrypoint (`prompt` and `inquirer`).
```

For {ref}`index:Classic Syntax (PyInquirer)` user, it would be just a direct mock on the {ref}`pages/prompt:prompt` function.
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/kb.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ for more information about limitations and other advanced topics.
#### filter

Each keybinding also takes another **optional** key called `filter` which can be used to determine if certain keys should be enabled/disabled.
The `filter` key can be either a boolean or a `prompt_toolkit` [Conditon](https://python-prompt-toolkit.readthedocs.io/en/master/pages/advanced_topics/filters.html#filters).
The `filter` key can be either a boolean or a `prompt_toolkit` [Condition](https://python-prompt-toolkit.readthedocs.io/en/master/pages/advanced_topics/filters.html#filters).

**bool**

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ for their specific options/parameters.
- mandatory (`bool`): Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
- mandatory_message (`str`): Error message to show when user attempts to skip mandatory prompt.
- raise_keyboard_interrupt (`bool`): Raise the {class}`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
will be `None` and the question is skiped.
will be `None` and the question is skipped.

## Asynchronous execution

Expand Down
Loading