# Path: esc/display.py
# def screen():
#     """
#     It seems that if we don't define this as a function, we won't be able to
#     access it with an import from another module because it won't have been
#     defined at that time.
#     """
#     return _SCREEN
# 
# def fetch_input(in_menu) -> int:
#     """
#     Get one character of input, the location of the window to fetch from
#     depending on whether we currently have a menu open (with a menu open, the
#     cursor sits in the status bar). The character is returned as an int for
#     compatibility with curses functions; use chr() to turn it into a string.
#     """
#     if in_menu:
#         return screen().getch_status()
#     else:
#         return screen().getch_stack()
# 
# Path: esc/oops.py
# class NotInMenuError(EscError):
#     """
#     Raised when a keypress is parsed as a menu option or a menu's children
#     are programmatically accessed by key, but the key doesn't refer to any
#     choice on the current menu. Describes the problem in a message that can
#     be printed to the status bar.
#     """
#     def __init__(self, access_key):
#         super().__init__()
#         specials = (' ', '\n', '\r', '\t')
#         if ord(access_key) > 256 or access_key in specials:
#             self.msg = "The key you pressed doesn't mean anything to esc here."
#         else:
#             self.msg = (f"There's no option '{curses.ascii.unctrl(access_key)}' "
#                         f"in this menu.")
# 
#     def __str__(self):
#         return self.msg
# 
# Path: esc/status.py
# class StatusState:
#     class Modality(Enum):
#     class SuccessCode(Enum):
#         READY = (' ', "Ready (<F1> for help)")
#         ENTERING_NUMBER = ('i', "Insert")
#         IN_MENU = ('m', "Expecting menu selection")
#         EXPECTING_REGISTER = ('r', "Expecting register identifier (any letter)")
#         EXPECTING_HELP = ('h', "Browsing help (select a command or menu)")
#         OK = auto()  # pylint: disable=invalid-name
#         ADVISORY = auto()
#         ERROR = auto()
#         def __init__(self, status_char, status_message):
#     def __init__(self):
#     def __repr__(self):
#     def status_char(self):
#     def status_message(self):
#     def _clear_errors(self):
#     def ready(self):
#     def entering_number(self):
#     def in_menu(self):
#     def expecting_register(self):
#     def expecting_help(self):
#     def advisory(self, msg):
#     def error(self, msg):
#     def mark_seen(self):
#     def push_state(self):
#     def pop_state(self):
#     def save_state(self):


import inspect
from . import builtin_stubs
from .display import screen, fetch_input
from .oops import NotInMenuError
from .status import status
    """
    Determine the status message to use to describe the command we're looking
    at.
    """
    # For anonymous operations (those whose description is None),
    # use the key to describe the command.
    description = command.description or command.key
    if command.is_menu:
        return f"Help: {description} (select a command or 'q' to return)"
    else:
        return f"Help: '{description}' (press any key to return)"


def get_help(operation_key, menu, ss, registry, recursing=False):
    """
    Display the on-line help page for the provided operation.
    """
    esc_command = builtin_help(operation_key, menu)
    if not esc_command:
        try:
            esc_command = menu.child(operation_key)
        except NotInMenuError as e:
            if not recursing:
                status.error(str(e))
            # When recursing, we get out of the menu by pressing a key
            # that doesn't exist.
            return

    screen().refresh_stack(ss)
    status.advisory(status_message(esc_command))

# Path: esc/display.py
# def screen():
#     """
#     It seems that if we don't define this as a function, we won't be able to
#     access it with an import from another module because it won't have been
#     defined at that time.
#     """
#     return _SCREEN
# 
# def fetch_input(in_menu) -> int:
#     """
#     Get one character of input, the location of the window to fetch from
#     depending on whether we currently have a menu open (with a menu open, the
#     cursor sits in the status bar). The character is returned as an int for
#     compatibility with curses functions; use chr() to turn it into a string.
#     """
#     if in_menu:
#         return screen().getch_status()
#     else:
#         return screen().getch_stack()
# 
# Path: esc/oops.py
# class NotInMenuError(EscError):
#     """
#     Raised when a keypress is parsed as a menu option or a menu's children
#     are programmatically accessed by key, but the key doesn't refer to any
#     choice on the current menu. Describes the problem in a message that can
#     be printed to the status bar.
#     """
#     def __init__(self, access_key):
#         super().__init__()
#         specials = (' ', '\n', '\r', '\t')
#         if ord(access_key) > 256 or access_key in specials:
#             self.msg = "The key you pressed doesn't mean anything to esc here."
#         else:
#             self.msg = (f"There's no option '{curses.ascii.unctrl(access_key)}' "
#                         f"in this menu.")
# 
#     def __str__(self):
#         return self.msg
# 
# Path: esc/status.py
# class StatusState:
#     class Modality(Enum):
#     class SuccessCode(Enum):
#         READY = (' ', "Ready (<F1> for help)")
#         ENTERING_NUMBER = ('i', "Insert")
#         IN_MENU = ('m', "Expecting menu selection")
#         EXPECTING_REGISTER = ('r', "Expecting register identifier (any letter)")
#         EXPECTING_HELP = ('h', "Browsing help (select a command or menu)")
#         OK = auto()  # pylint: disable=invalid-name
#         ADVISORY = auto()
#         ERROR = auto()
#         def __init__(self, status_char, status_message):
#     def __init__(self):
#     def __repr__(self):
#     def status_char(self):
#     def status_message(self):
#     def _clear_errors(self):
#     def ready(self):
#     def entering_number(self):
#     def in_menu(self):
#     def expecting_register(self):
#     def expecting_help(self):
#     def advisory(self, msg):
#     def error(self, msg):
#     def mark_seen(self):
#     def push_state(self):
#     def pop_state(self):
#     def save_state(self):


# Path: esc/helpme.py
import inspect
from . import builtin_stubs
from .display import screen, fetch_input
from .oops import NotInMenuError
from .status import status

    """
    Determine the status message to use to describe the command we're looking
    at.
    """
    # For anonymous operations (those whose description is None),
    # use the key to describe the command.
    description = command.description or command.key
    if command.is_menu:
        return f"Help: {description} (select a command or 'q' to return)"
    else:
        return f"Help: '{description}' (press any key to return)"


def get_help(operation_key, menu, ss, registry, recursing=False):
    """
    Display the on-line help page for the provided operation.
    """
    esc_command = builtin_help(operation_key, menu)
    if not esc_command:
        try:
            esc_command = menu.child(operation_key)
        except NotInMenuError as e:
            if not recursing:
                status.error(str(e))
            # When recursing, we get out of the menu by pressing a key
            # that doesn't exist.
            return

    screen().refresh_stack(ss)
    status.advisory(status_message(esc_command))

    screen().refresh_status()