Karana.KUtils.MultibodyTUI.terminal
===================================

.. py:module:: Karana.KUtils.MultibodyTUI.terminal

.. autoapi-nested-parse::

   Functions for controlling the text in the terminal.



Functions
---------

.. autoapisummary::

   Karana.KUtils.MultibodyTUI.terminal.bold
   Karana.KUtils.MultibodyTUI.terminal.invert
   Karana.KUtils.MultibodyTUI.terminal.critical
   Karana.KUtils.MultibodyTUI.terminal.error
   Karana.KUtils.MultibodyTUI.terminal.warn
   Karana.KUtils.MultibodyTUI.terminal.info
   Karana.KUtils.MultibodyTUI.terminal.tuiMode
   Karana.KUtils.MultibodyTUI.terminal.normalMode
   Karana.KUtils.MultibodyTUI.terminal.clearScreen
   Karana.KUtils.MultibodyTUI.terminal.printLines
   Karana.KUtils.MultibodyTUI.terminal.printWithPager
   Karana.KUtils.MultibodyTUI.terminal.pollKey


Module Contents
---------------

.. py:function:: bold(text: str) -> str

   Apply the bold effect.

   :param text: The given text
   :type text: str

   :returns: The bolded text
   :rtype: str


.. py:function:: invert(text: str) -> str

   Swap background and foreground colors.

   :param text: The given text
   :type text: str

   :returns: The inverted text
   :rtype: str


.. py:function:: critical(text: str) -> str

   Style the text for a critical error.

   :param text: The given text
   :type text: str

   :returns: The stylized text
   :rtype: str


.. py:function:: error(text: str) -> str

   Style the text for an error.

   :param text: The given text
   :type text: str

   :returns: The stylized text
   :rtype: str


.. py:function:: warn(text: str) -> str

   Style the text for a warning.

   :param text: The given text
   :type text: str

   :returns: The stylized text
   :rtype: str


.. py:function:: info(text: str) -> str

   Style the text for important info.

   :param text: The given text
   :type text: str

   :returns: The stylized text
   :rtype: str


.. py:function:: tuiMode(on_resume: collections.abc.Callable | None = None)

   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.

   :param on_resume: Optional callable triggered upon SIGCONT (e.g., when resuming from
                     Ctrl-Z).
   :type on_resume: collections.abc.Callable | None


.. py:function:: normalMode(on_resume: collections.abc.Callable | None = None)

   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.

   :param on_resume: Optional callable triggered upon SIGCONT (e.g., when resuming from
                     Ctrl-Z).
   :type on_resume: collections.abc.Callable | None


.. py:function:: clearScreen()

   Clear screen and move cursor to top-left.


.. py:function:: printLines(lines: list[str])

   Print the provided lines in the terminal.

   :param lines: The lines to print.
   :type lines: list[str]


.. py:function:: printWithPager(text: str)

   Display text in a pager, respecting the PAGER variable.

   :param text: The text to display in the pager.
   :type text: str


.. py:function:: pollKey(timeout: float = 0.1) -> str

   Poll for a pending key press.

   :param timeout: Amount of time in seconds to wait for a key press
   :type timeout: float

   :returns: The pressed key or the empty string if no key was pressed.
   :rtype: str


