Source code for thurible.menu

"""
menu
~~~~

An object for displaying a text area in a terminal.
"""
from dataclasses import dataclass
from typing import Optional

from blessed import Terminal
from blessed.keyboard import Keystroke

from thurible.panel import Scroll, Title
from thurible.util import Box


# Utility classes.
@dataclass
class Option:
    """A command or menu option.

    :param name: The name of the option.
    :param hotkey: (Optional.) A hotkey that can be used to invoke
        the option.
    :returns: A :class:`thurible.Option` object.
    :rtype: thurible.Option
    :usage:
        To create a menu option "spam" with the hotkey of "s":

        .. testcode::

            import thurible

            option = thurible.Option('spam', hotkey='s')
    """
    name: str
    hotkey: Optional[str] = None


# General classes.