Karana.KUtils.MultibodyTUI.terminal#
Functions for controlling the text in the terminal.
Functions#
|
Apply the bold effect. |
|
Swap background and foreground colors. |
|
Style the text for a critical error. |
|
Style the text for an error. |
|
Style the text for a warning. |
|
Style the text for important info. |
|
Context manager to configure the terminal for a TUI. |
|
Context manager to configure the terminal for regular input. |
Clear screen and move cursor to top-left. |
|
|
Print the provided lines in the terminal. |
|
Display text in a pager, respecting the PAGER variable. |
|
Poll for a pending key press. |
Module Contents#
- Karana.KUtils.MultibodyTUI.terminal.bold(text: str) str[source]#
Apply the bold effect.
- Parameters:
text (str) – The given text
- Returns:
The bolded text
- Return type:
str
- Karana.KUtils.MultibodyTUI.terminal.invert(text: str) str[source]#
Swap background and foreground colors.
- Parameters:
text (str) – The given text
- Returns:
The inverted text
- Return type:
str
- Karana.KUtils.MultibodyTUI.terminal.critical(text: str) str[source]#
Style the text for a critical error.
- Parameters:
text (str) – The given text
- Returns:
The stylized text
- Return type:
str
- Karana.KUtils.MultibodyTUI.terminal.error(text: str) str[source]#
Style the text for an error.
- Parameters:
text (str) – The given text
- Returns:
The stylized text
- Return type:
str
- Karana.KUtils.MultibodyTUI.terminal.warn(text: str) str[source]#
Style the text for a warning.
- Parameters:
text (str) – The given text
- Returns:
The stylized text
- Return type:
str
- Karana.KUtils.MultibodyTUI.terminal.info(text: str) str[source]#
Style the text for important info.
- Parameters:
text (str) – The given text
- Returns:
The stylized text
- Return type:
str
- Karana.KUtils.MultibodyTUI.terminal.tuiMode(on_resume: collections.abc.Callable | None = None)[source]#
Context manager to configure the terminal for a TUI.
This primarily handles setting cbreak mode for immediate key handling and restoring the previous mode upon exiting the context. Multiple tuiMode contexts may be nested.
- Parameters:
on_resume (collections.abc.Callable | None) – Optional callable triggered upon SIGCONT (eg when resuming from Ctrl-Z).
- Karana.KUtils.MultibodyTUI.terminal.normalMode(on_resume: collections.abc.Callable | None = None)[source]#
Context manager to configure the terminal for regular input.
This can be used to return the terminal to regular interaction. This is could be used for example to return to normal behavior when entering a Python REPL from within a TUI.
- Parameters:
on_resume (collections.abc.Callable | None) – Optional callable triggered upon SIGCONT (eg when resuming from Ctrl-Z).
- Karana.KUtils.MultibodyTUI.terminal.clearScreen()[source]#
Clear screen and move cursor to top-left.
- Karana.KUtils.MultibodyTUI.terminal.printLines(lines: list[str])[source]#
Print the provided lines in the terminal.
- Parameters:
lines (list[str]) – The lines to print.