input_placeholders.py 1.09 KB
Newer Older
1 2 3 4 5 6 7 8
"""
Classes used to replace the input in some tabs or special situations,
but which are not inputs.
"""

import logging
log = logging.getLogger(__name__)

Link Mauve's avatar
Link Mauve committed
9
from poezio.windows.base_wins import Win
10
from poezio.theming import get_theme, to_curses_attr
11

12 13
from typing import Optional

14 15 16 17 18 19 20

class HelpText(Win):
    """
    A Window just displaying a read-only message.
    Usually used to replace an Input when the tab is in
    command mode.
    """
mathieui's avatar
mathieui committed
21

22 23
    __slots__ = ('txt')

24
    def __init__(self, text: str = '') -> None:
25
        Win.__init__(self)
26
        self.txt = text  # type: str
27

28
    def refresh(self, txt: Optional[str] = None) -> None:
29
        log.debug('Refresh: %s', self.__class__.__name__)
30
        if txt is not None:
31
            self.txt = txt
32
        self._win.erase()
mathieui's avatar
mathieui committed
33 34
        self.addstr(0, 0, self.txt[:self.width - 1],
                    to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
35 36
        self.finish_line(get_theme().COLOR_INFORMATION_BAR)
        self._refresh()
37

38
    def do_command(self, key, raw: bool = False) -> bool:
39 40
        return False

41
    def on_delete(self) -> None:
42
        return