o
    P“hæô  ã                   @   sÌ  d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlmZ ddlmZmZmZmZmZmZmZ ddlmZmZmZ ddlmZ ddlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& dd	l'm(Z(m)Z)m*Z* ej+dd
… dk r†ej,Z-dZ.e	 /¡ dkr›dZ0ddl1Z2ddl3m4Z4 n3dZ0ddl2Z2zddl5Z5ddl6Z6ddl7Z7W n e8yÍ   dZ9dj:e	 /¡ d ;e9¡dZ<e
 =e<¡ dZ.Y nw da>G dd„ de?ƒZ@G dd„ de Add¡ƒZBdS )zAModule containing :class:`Terminal`, the primary API entry point.é    Né   )ÚCOLOR_DISTANCE_ALGORITHMS)ÚDEFAULT_ESCDELAYÚ
_time_leftÚ_read_untilÚresolve_sequenceÚget_keyboard_codesÚget_leading_prefixesÚget_keyboard_sequences)ÚTermcapÚSequenceÚSequenceTextWrapper)ÚRGB_256TABLE)	ÚCOLORSÚCOMPOUNDABLESÚFormattingStringÚNullCallableStringÚParameterizingStringÚFormattingOtherStringÚsplit_compoundÚresolve_attributeÚresolve_capability)ÚCAPABILITY_DATABASEÚCAPABILITIES_ADDITIVESÚCAPABILITIES_RAW_MIXINé   )é   r   TÚWindows)Úget_console_input_encodingF)ÚsetrawÚcbreakÚkbhitÚheightÚwidthzÏOne or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform '{platform}'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: {tty_methods}.z, )ÚplatformÚtty_methodsc                   @   s4  e Zd ZdZi dd“dd“dd“dd	“d
d“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd “d!d"“d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2œ¥Zd²d5d6„Zd7d8„ Zd9d:„ Zd;d<„ Zd=d>„ Z	d?d@„ Z
dAdB„ ZedCdD„ ƒZedEdF„ ƒZedGdH„ ƒZedIdJ„ ƒZedKdL„ ƒZedMdN„ ƒZedOdP„ ƒZedQdR„ ƒZdSdT„ ZdUdV„ Zejd³dWdX„ƒZd´dYdZ„Zd´d[d\„Zd´d]d^„Zejd_d`„ ƒZejdadb„ ƒZdcdd„ Z dedf„ Z!edgdh„ ƒZ"edidj„ ƒZ#edkdl„ ƒZ$edmdn„ ƒZ%edodp„ ƒZ&dqdr„ Z'edsdt„ ƒZ(dudv„ Z)dwdx„ Z*dydz„ Z+ed{d|„ ƒZ,dµd~d„Z-ed€d„ ƒZ.ed‚dƒ„ ƒZ/e/j0d„dƒ„ ƒZ/ed…d†„ ƒZ1e1j0d‡d†„ ƒZ1edˆd‰„ ƒZ2edŠd‹„ ƒZ3d¶ddŽ„Z4d¶dd„Z5d¶d‘d’„Z6d´d“d”„Z7d•d–„ Z8d´d—d˜„Z9d´d™dš„Z:d´d›dœ„Z;ddž„ Z<d·d d¡„Z=d´d¢d£„Z>d¤d¥„ Z?d¦d§„ Z@d´d¨d©„ZAejdªd«„ ƒZBejd¬d­„ ƒZCejd®d¯„ ƒZDd3eEfd°d±„ZFd3S )¸ÚTerminala‚  
    An abstraction for color, style, positioning, and input in the terminal.

    This keeps the endless calls to ``tigetstr()`` and ``tparm()`` out of your code, acts
    intelligently when somebody pipes your output to a non-terminal, and abstracts over the
    complexity of unbuffered keyboard input. It uses the terminfo database to remain portable across
    terminal types.
    ÚsaveÚscÚrestoreÚrcÚ	clear_eolÚelÚ	clear_bolÚel1Ú	clear_eosÚedÚenter_fullscreenÚsmcupÚexit_fullscreenÚrmcupÚmoveÚcupÚmove_yxÚmove_xÚhpaÚmove_yÚvpaÚhide_cursorÚcivisÚnormal_cursorÚcnormÚreset_colorsÚopÚnormalÚsgr0ÚreverseÚrevÚitalicÚsitmÚritmÚsshmÚrshmÚsmsoÚrmsoÚssubmÚrsubmÚssupmÚrsupmÚsmulÚrmulÚu6Úu7Úu8Úu9)Ú	no_italicÚshadowÚ	no_shadowÚstandoutÚno_standoutÚ	subscriptÚno_subscriptÚsuperscriptÚno_superscriptÚ	underlineÚno_underlineÚcursor_reportÚcursor_requestÚterminal_answerbackÚterminal_enquireNFc              
   C   sf  d|||f g| _ d| _d| _|| _d| _d| _d| _|  ¡  tr0| jdur0|p-t	 
| j¡| _n|p:tj dd¡p:d| _d| _|du rM| jrM| j  d¡ n|sR| jrUd| _| jr¥z
t	 | j| j¡ W n+ t	jy } zd | j|¡}t |¡ | j  |¡ d| _d| _W Y d}~nd}~ww tdu s—| jtkr›| jan
t d	| jtf ¡ |  ¡  |  ¡  |  ¡  dS )
a©  
        Initialize the terminal.

        :arg str kind: A terminal string as taken by :func:`curses.setupterm`.
            Defaults to the value of the ``TERM`` environment variable.

            .. note:: Terminals within a single process must share a common
                ``kind``. See :obj:`_CUR_TERM`.

        :arg file stream: A file-like object representing the Terminal output.
            Defaults to the original value of :obj:`sys.__stdout__`, like
            :func:`curses.initscr` does.

            If ``stream`` is not a tty, empty Unicode strings are returned for
            all capability values, so things like piping your program output to
            a pipe or file does not emit terminal sequences.

        :arg bool force_styling: Whether to force the emission of capabilities
            even if :obj:`sys.__stdout__` does not seem to be connected to a
            terminal. If you want to force styling to not happen, use
            ``force_styling=None``.

            This comes in handy if users are trying to pipe your output through
            something like ``less -r`` or build systems which support decoding
            of terminal sequences.
        z0parameters: kind=%r, stream=%r, force_styling=%rNTFÚTERMÚdumbzforce_styling is Nonez$Failed to setupterm(kind={0!r}): {1}zÃA terminal of kind "%s" has been requested; due to an internal python curses bug, terminal capabilities for a terminal of kind "%s" will continue to be returned for the remainder of this process.)ÚerrorsÚ_normalÚ_line_bufferedÚ_streamÚ_keyboard_fdÚ_init_descriptorÚ	_is_a_ttyÚ_Terminal__init__streamsÚ
IS_WINDOWSÚcursesÚget_termÚ_kindÚosÚenvironÚgetÚ_does_stylingÚis_a_ttyÚappendÚdoes_stylingÚ	setuptermÚerrorÚformatÚwarningsÚwarnÚ	_CUR_TERMÚ#_Terminal__init__color_capabilitiesÚ_Terminal__init__capabilitiesÚ_Terminal__init__keycodes)ÚselfÚkindÚstreamÚforce_stylingÚerrÚmsg© rŠ   úK/var/www/html/env_mimamsha/lib/python3.10/site-packages/blessed/terminal.pyÚ__init__|   sP   ÿ

€ûÿýÿzTerminal.__init__c              
   C   sª  d }| j d u rtj| _ t| j dƒs| j d¡ n>t| j jƒs%| j d¡ n1z| j  ¡ }W n tyF } z| j d| ¡ W Y d }~nd }~ww t	 
|¡| _| jsV| j d¡ | j tjtjfv r¡ztj ¡ | _W n ttfyƒ } z| j d| ¡ W Y d }~n(d }~ww | js‘| j d¡ d | _nt	 
| j¡s | j d¡ d | _n| j d	¡ || _|d u rÓz	tj ¡ | _W d S  tyÒ } z| j d
| ¡ W Y d }~d S d }~ww d S )NÚfilenozstream has no fileno methodzstream.fileno is not callablez5Unable to determine output stream file descriptor: %szstream not a TTYz4Unable to determine input stream file descriptor: %szOutput stream is not a TTYzInput stream is not a TTYz%Output stream is not a default streamz2Unable to determine __stdout__ file descriptor: %s)rk   ÚsysÚ
__stdout__Úhasattrrh   ry   Úcallabler   Ú
ValueErrorrt   Úisattyrn   Ú
__stderr__Ú	__stdin__rl   ÚAttributeErrorrx   rm   )r„   Ú	stream_fdrˆ   rŠ   rŠ   r‹   Ú__init__streamsÏ   sP   
€ý€ÿ€€ÿýzTerminal.__init__streamsc                 C   sN   d| _ | jsd| _d S tstj d¡dv rd| _d S tdt 	d¡p"dƒ| _d S )NÚcie2000r   Ú	COLORTERM)Ú	truecolorÚ24bité   Úcolorséÿÿÿÿ)
Ú_color_distance_algorithmrz   Únumber_of_colorsrp   rt   ru   rv   Úmaxrq   Útigetnum©r„   rŠ   rŠ   r‹   Ú__init__color_capabilities  s   

z#Terminal.__init__color_capabilitiesc                 C   s$   t t| ƒƒt@ D ]}t| |ƒ qd S ©N)ÚsetÚdirr   Údelattr)r„   Úcached_color_caprŠ   rŠ   r‹   Ú__clear_color_capabilities
  s   ÿz#Terminal.__clear_color_capabilitiesc                 C   s  t  ¡ | _t ¡ D ]\}\}}t|||ƒ| j|< q	t ¡ D ]/\}\}}| jr<t| |ƒ}|r<tj	|||fi |¤Ž| j|< qt
 |¡}|rLt|||ƒ| j|< qt d dd„ | j ¡ D ƒ¡¡| _t d dd„ | j ¡ D ƒ¡d ¡| _t d dd„ | j ¡ D ƒ¡d ¡| _d S )Nú|c                 s   ó    | ]\}}|j V  qd S r¦   )Úpattern©Ú.0ÚnameÚcaprŠ   rŠ   r‹   Ú	<genexpr>'  ó   € z0Terminal.__init__capabilities.<locals>.<genexpr>c                 s   r­   r¦   )Únamed_patternr¯   rŠ   rŠ   r‹   r³   +  s   € 

ÿz|(?P<MISMATCH>.)c                 s   s     | ]\}}d   |j¡V  qdS )z({0})N)r}   r®   r¯   rŠ   rŠ   r‹   r³   .  s   € 
ÿz|(.))ÚcollectionsÚOrderedDictÚcapsr   Úitemsr   r   rz   ÚgetattrÚbuildr   rv   ÚreÚcompileÚjoinÚcaps_compiledÚ_caps_compiled_anyÚ_caps_unnamed_any)r„   r±   Ú	attributer®   Úkwdsr²   rŠ   rŠ   r‹   Ú__init__capabilities  s<   

ÿÿ
€ÿÿþÿþzTerminal.__init__capabilitiesc              
   C   sâ   t ƒ | _| j ¡ D ]
\}}t| ||ƒ q	t| ƒ| _t| jƒ| _t 	¡ | _
| jd urotr6tƒ p3t ¡ p3d| _nt ¡ p;d| _zt | j¡ƒ | _W d S  tyn } zt d |¡¡ d| _t | j¡ƒ | _W Y d }~d S d }~ww d S )NzUTF-8z3LookupError: {0}, defaulting to UTF-8 for keyboard.)r   Ú	_keycodesr¹   Úsetattrr
   Ú_keymapr	   Ú_keymap_prefixesr¶   ÚdequeÚ_keyboard_bufrl   rp   r   ÚlocaleÚgetpreferredencodingÚ	_encodingÚcodecsÚgetincrementaldecoderÚ_keyboard_decoderÚLookupErrorr~   r   r}   )r„   Úkey_codeÚkey_namerˆ   rŠ   rŠ   r‹   Ú__init__keycodes2  s.   


ÿÿ€üôzTerminal.__init__keycodesc                 C   s&   | j stƒ S t| |ƒ}t| ||ƒ |S )ay  
        Return a terminal capability as Unicode string.

        For example, ``term.bold`` is a unicode string that may be prepended
        to text to set the video attribute for bold, which should also be
        terminated with the pairing :attr:`normal`. This capability
        returns a callable, so you can use ``term.bold("hi")`` which
        results in the joining of ``(term.bold, "hi", term.normal)``.

        Compound formatters may also be used. For example::

            >>> term.bold_blink_red_on_green("merry x-mas!")

        For a parameterized capability such as ``move`` (or ``cup``), pass the
        parameters as positional arguments::

            >>> term.move(line, column)

        See the manual page `terminfo(5)
        <https://invisible-island.net/ncurses/man/terminfo.5.html>`_ for a
        complete list of capabilities and their arguments.
        )rw   r   r   rÆ   )r„   ÚattrÚvalrŠ   rŠ   r‹   Ú__getattr__V  s
   
zTerminal.__getattr__c                 C   ó   | j S )zl
        Read-only property: Terminal kind determined on class initialization.

        :rtype: str
        )rs   r¤   rŠ   rŠ   r‹   r…   x  ó   zTerminal.kindc                 C   rØ   )zk
        Read-only property: Whether this class instance may emit sequences.

        :rtype: bool
        )rw   r¤   rŠ   rŠ   r‹   rz     rÙ   zTerminal.does_stylingc                 C   rØ   )zc
        Read-only property: Whether :attr:`~.stream` is a terminal.

        :rtype: bool
        )rn   r¤   rŠ   rŠ   r‹   rx   Š  rÙ   zTerminal.is_a_ttyc                 C   ó
   |   ¡ jS )zg
        Read-only property: Height of the terminal (in number of lines).

        :rtype: int
        )Ú_height_and_widthÚws_rowr¤   rŠ   rŠ   r‹   r"   “  ó   
zTerminal.heightc                 C   rÚ   )zh
        Read-only property: Width of the terminal (in number of columns).

        :rtype: int
        )rÛ   Úws_colr¤   rŠ   rŠ   r‹   r#   œ  rÝ   zTerminal.widthc                 C   rÚ   )z]
        Read-only property: Height ofthe terminal (in pixels).

        :rtype: int
        )rÛ   Ú	ws_ypixelr¤   rŠ   rŠ   r‹   Úpixel_height¥  rÝ   zTerminal.pixel_heightc                 C   rÚ   )zY
        Read-only property: Width of terminal (in pixels).

        :rtype: int
        )rÛ   Ú	ws_xpixelr¤   rŠ   rŠ   r‹   Úpixel_width®  rÝ   zTerminal.pixel_widthc                 C   s8   t rt | tjtj¡}tt tj	|¡Ž S tdddddS )aÛ  
        Return named tuple describing size of the terminal by ``fd``.

        If the given platform does not have modules :mod:`termios`,
        :mod:`fcntl`, or :mod:`tty`, window size of 80 columns by 25
        rows is always returned.

        :arg int fd: file descriptor queries for its window size.
        :raises IOError: the file descriptor ``fd`` is not a terminal.
        :rtype: WINSZ
        :returns: named tuple describing size of the terminal

        WINSZ is a :class:`collections.namedtuple` instance, whose structure
        directly maps to the return value of the :const:`termios.TIOCGWINSZ`
        ioctl return value. The return parameters are:

            - ``ws_row``: width of terminal by its number of character cells.
            - ``ws_col``: height of terminal by its number of character cells.
            - ``ws_xpixel``: width of terminal by pixels (not accurate).
            - ``ws_ypixel``: height of terminal by pixels (not accurate).
        é   éP   r   ©rÜ   rÞ   rá   rß   )
ÚHAS_TTYÚfcntlÚioctlÚtermiosÚ
TIOCGWINSZÚWINSZÚ_BUFÚstructÚunpackÚ_FMT)ÚfdÚdatarŠ   rŠ   r‹   Ú_winsize·  s   zTerminal._winsizec                 C   sp   | j tjfD ]}z|dur|  |¡W   S W q ttttfy#   Y qw tt	t
 dd¡ƒt	t
 dd¡ƒdddS )a~  
        Return a tuple of (terminal height, terminal width).

        If :attr:`stream` or :obj:`sys.__stdout__` is not a tty or does not
        support :func:`fcntl.ioctl` of :const:`termios.TIOCGWINSZ`, a window
        size of 80 columns by 25 rows is returned for any values not
        represented by environment variables ``LINES`` and ``COLUMNS``, which
        is the default text mode of IBM PC compatibles.

        :rtype: WINSZ
        :returns: Named tuple specifying the terminal size

        WINSZ is a :class:`collections.namedtuple` instance, whose structure
        directly maps to the return value of the :const:`termios.TIOCGWINSZ`
        ioctl return value. The return parameters are:

            - ``ws_row``: height of terminal by its number of cell rows.
            - ``ws_col``: width of terminal by its number of cell columns.
            - ``ws_xpixel``: width of terminal by pixels (not accurate).
            - ``ws_ypixel``: height of terminal by pixels (not accurate).

            .. note:: the peculiar (height, width, width, height) order, which
               matches the return order of TIOCGWINSZ!
        NÚLINESÚ25ÚCOLUMNSÚ80rå   )rm   rŽ   r   rò   ÚIOErrorÚOSErrorr’   Ú	TypeErrorrë   Úintrt   Úgetenv)r„   rð   rŠ   rŠ   r‹   rÛ   Ô  s   ÿÿýzTerminal._height_and_widthc                 C   s¨   d}zD| j r|  ¡ }| ¡  | j |¡ | j ¡  t| ||d\}}|r4|d| ¡ … || ¡ d…  }|  	|¡ W |durE| 
ddd¡ |S |durS| 
ddd¡ w w )au  
        Sends a query string to the terminal and waits for a response.

        :arg str query_str: Query string written to output
        :arg str response_re: Regular expression matching query response
        :arg float timeout: Return after time elapsed in seconds
        :return: re.match object for response_re or None if not found
        :rtype: re.Match
        N)Útermr®   Útimeout)rj   r    Ú	__enter__r†   ÚwriteÚflushr   ÚstartÚendÚungetchÚ__exit__)r„   Ú	query_strÚresponse_rerý   ÚctxÚmatchrñ   rŠ   rŠ   r‹   Ú_query_responseù  s(   

þ ýÿzTerminal._query_responsec              	   c   s¶    | j  | j¡ |dur|dur| j  |  ||¡¡ n|dur)| j  |  |¡¡ n|dur6| j  |  |¡¡ z| j  ¡  dV  W | j  | j¡ | j  ¡  dS | j  | j¡ | j  ¡  w )a’  
        Context manager for temporarily moving the cursor.

        :arg int x: horizontal position, from left, *0*, to right edge of screen, *self.width - 1*.
        :arg int y: vertical position, from top, *0*, to bottom of screen, *self.height - 1*.
        :return: a context manager.
        :rtype: Iterator

        Move the cursor to a certain position on entry, do any kind of I/O, and upon exit
        let you print stuff there, then return the cursor to its original position:


        .. code-block:: python

            term = Terminal()
            with term.location(y=0, x=0):
                for row_num in range(term.height-1):
                    print('Row #{row_num}')
            print(term.clear_eol + 'Back to original location.')

        Specify ``x`` to move to a certain column, ``y`` to move to a certain
        row, both, or neither. If you specify neither, only the saving and
        restoration of cursor position will happen. This can be useful if you
        simply want to restore your place after doing some manual cursor
        movement.

        Calls cannot be nested: only one should be entered at a time.

        .. note:: The argument order *(x, y)* differs from the return value order *(y, x)*
            of :meth:`get_location`, or argument order *(y, x)* of :meth:`move`. This is
            for API Compaibility with the blessings library, sorry for the trouble!
        N)r†   rÿ   r'   r5   r8   r:   r   r)   ©r„   ÚxÚyrŠ   rŠ   r‹   Úlocation%  s   €&
ÿzTerminal.locationc                 C   sp   t | | jd jƒp
d}|  | jpd| jd j|¡}|r6dd„ | ¡ D ƒ\}}d|v r2|d8 }|d8 }||fS dS )	aÑ  
        Return tuple (row, column) of cursor position.

        :arg float timeout: Return after time elapsed in seconds with value ``(-1, -1)`` indicating
            that the remote end did not respond.
        :rtype: tuple
        :returns: cursor position as tuple in form of ``(y, x)``.  When a timeout is specified,
            always ensure the return value is checked for ``(-1, -1)``.

        The location of the cursor is determined by emitting the ``u7`` terminal capability, or
        VT100 `Query Cursor Position
        <https://www2.ccs.neu.edu/research/gpc/VonaUtils/vona/terminal/vtansi.htm#status>`_
        when such capability is undefined, which elicits a response from a reply string described by
        capability ``u6``, or again VT100's definition of ``\x1b[%i%d;%dR`` when undefined.

        The ``(y, x)`` return value matches the parameter order of the :meth:`move_yx` capability.
        The following sequence should cause the cursor to not move at all::

            >>> term = Terminal()
            >>> term.move_yx(*term.get_location()))

        And the following should assert True with a terminal:

            >>> term = Terminal()
            >>> given_y, given_x = 10, 20
            >>> with term.location(y=given_y, x=given_x):
            ...     result_y, result_x = term.get_location()
            ...
            >>> assert given_x == result_x, (given_x, result_x)
            >>> assert given_y == result_y, (given_y, result_y)
        rb   z
[%i%d;%dRz[6nc                 s   s    | ]}t |ƒV  qd S r¦   ©rú   ©r°   rÖ   rŠ   rŠ   r‹   r³   ’  s   € z(Terminal.get_location.<locals>.<genexpr>z%ir   )rŸ   rŸ   )rº   r¸   rÂ   r	  rT   Úre_compiledÚgroups)r„   rý   Úresponse_strr  ÚrowÚcolrŠ   rŠ   r‹   Úget_locationZ  s   1ÿ	zTerminal.get_locationc                 C   ó2   |   dt d¡|¡}|rtdd„ | ¡ D ƒƒS dS )aN  
        Return tuple (r, g, b) of foreground color.

        :arg float timeout: Return after time elapsed in seconds with value ``(-1, -1, -1)``
            indicating that the remote end did not respond.
        :rtype: tuple
        :returns: foreground color as tuple in form of ``(r, g, b)``.  When a timeout is specified,
            always ensure the return value is checked for ``(-1, -1, -1)``.

        The foreground color is determined by emitting an `OSC 10 color query
        <https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands>`_.
        z]10;?z6]10;rgb:([0-9a-fA-F]+)/([0-9a-fA-F]+)/([0-9a-fA-F]+)c                 s   ó    | ]}t |d ƒV  qdS ©é   Nr  r  rŠ   rŠ   r‹   r³   ¸  r´   z'Terminal.get_fgcolor.<locals>.<genexpr>©rŸ   rŸ   rŸ   ©r	  r¼   r½   Útupler  ©r„   rý   r  rŠ   rŠ   r‹   Úget_fgcolor¥  ó   ýzTerminal.get_fgcolorc                 C   r  )aN  
        Return tuple (r, g, b) of background color.

        :arg float timeout: Return after time elapsed in seconds with value ``(-1, -1, -1)``
            indicating that the remote end did not respond.
        :rtype: tuple
        :returns: background color as tuple in form of ``(r, g, b)``.  When a timeout is specified,
            always ensure the return value is checked for ``(-1, -1, -1)``.

        The background color is determined by emitting an `OSC 11 color query
        <https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands>`_.
        z]11;?z6]11;rgb:([0-9a-fA-F]+)/([0-9a-fA-F]+)/([0-9a-fA-F]+)c                 s   r  r  r  r  rŠ   rŠ   r‹   r³   Í  r´   z'Terminal.get_bgcolor.<locals>.<genexpr>r  r  r  rŠ   rŠ   r‹   Úget_bgcolorº  r  zTerminal.get_bgcolorc              	   c   óZ    | j  | j¡ | j  ¡  zdV  W | j  | j¡ | j  ¡  dS | j  | j¡ | j  ¡  w )aZ  
        Context manager that switches to secondary screen, restoring on exit.

        Under the hood, this switches between the primary screen buffer and
        the secondary one. The primary one is saved on entry and restored on
        exit.  Likewise, the secondary contents are also stable and are
        faithfully restored on the next entry::

            with term.fullscreen():
                main()

        .. note:: There is only one primary and one secondary screen buffer.
           :meth:`fullscreen` calls cannot be nested, only one should be
           entered at a time.
        N)r†   rÿ   r1   r   r3   r¤   rŠ   rŠ   r‹   Ú
fullscreenÏ  s   €
ÿzTerminal.fullscreenc              	   c   r!  )a  
        Context manager that hides the cursor, setting visibility on exit.

            with term.hidden_cursor():
                main()

        .. note:: :meth:`hidden_cursor` calls cannot be nested: only one
            should be entered at a time.
        N)r†   rÿ   r<   r   r>   r¤   rŠ   rŠ   r‹   Úhidden_cursorè  s   €
ÿzTerminal.hidden_cursorc                 C   s   |   ||¡S )až  
        A callable string that moves the cursor to the given ``(x, y)`` screen coordinates.

        :arg int x: horizontal position, from left, *0*, to right edge of screen, *self.width - 1*.
        :arg int y: vertical position, from top, *0*, to bottom of screen, *self.height - 1*.
        :rtype: ParameterizingString
        :returns: Callable string that moves the cursor to the given coordinates
        ©r5   r
  rŠ   rŠ   r‹   Úmove_xyû  s   zTerminal.move_xyc                 C   s   |   ||¡S )až  
        A callable string that moves the cursor to the given ``(y, x)`` screen coordinates.

        :arg int y: vertical position, from top, *0*, to bottom of screen, *self.height - 1*.
        :arg int x: horizontal position, from left, *0*, to right edge of screen, *self.width - 1*.
        :rtype: ParameterizingString
        :returns: Callable string that moves the cursor to the given coordinates
        r$  )r„   r  r  rŠ   rŠ   r‹   r7   
  ó   	zTerminal.move_yxc                 C   ó   t | jt| jƒƒS )zBMove cursor 1 cells to the left, or callable string for n>1 cells.)r   Úcub1r   Úcubr¤   rŠ   rŠ   r‹   Ú	move_left  ó   zTerminal.move_leftc                 C   r'  )zKMove cursor 1 or more cells to the right, or callable string for n>1 cells.)r   Úcuf1r   Úcufr¤   rŠ   rŠ   r‹   Ú
move_right  r+  zTerminal.move_rightc                 C   r'  )zFMove cursor 1 or more cells upwards, or callable string for n>1 cells.)r   Úcuu1r   Úcuur¤   rŠ   rŠ   r‹   Úmove_up  r+  zTerminal.move_upc                 C   r'  )zHMove cursor 1 or more cells downwards, or callable string for n>1 cells.)r   Úcud1r   Úcudr¤   rŠ   rŠ   r‹   Ú	move_down$  r+  zTerminal.move_downc                 C   ó   | j rt| j| jdƒS tƒ S )a  
        A callable string that sets the foreground color.

        :rtype: ParameterizingString

        The capability is unparameterized until called and passed a number, at which point it
        returns another string which represents a specific color change. This second string can
        further be called to color a piece of text and set everything back to normal afterward.

        This should not be used directly, but rather a specific color by name or
        :meth:`~.Terminal.color_rgb` value.
        Úcolor)rz   r   Ú_foreground_colorrB   r   r¤   rŠ   rŠ   r‹   r6  )  s   zTerminal.colorc                 C   óD   | j dkrd |||¡}t|| jƒS |  |||¡}t|  |¡| jƒS )aá  
        Provides callable formatting string to set foreground color to the specified RGB color.

        :arg int red: RGB value of Red.
        :arg int green: RGB value of Green.
        :arg int blue: RGB value of Blue.
        :rtype: FormattingString
        :returns: Callable string that sets the foreground color

        If the terminal does not support RGB color, the nearest supported
        color will be determined using :py:attr:`color_distance_algorithm`.
        r   z[38;2;{0};{1};{2}m)r¡   r}   r   rB   Úrgb_downconvertr7  ©r„   ÚredÚgreenÚblueÚfmt_attrÚ	color_idxrŠ   rŠ   r‹   Ú	color_rgb<  s
   
zTerminal.color_rgbc                 C   r5  )zm
        A callable capability that sets the background color.

        :rtype: ParameterizingString
        Úon_color)rz   r   Ú_background_colorrB   r   r¤   rŠ   rŠ   r‹   rA  R  s   zTerminal.on_colorc                 C   r8  )aá  
        Provides callable formatting string to set background color to the specified RGB color.

        :arg int red: RGB value of Red.
        :arg int green: RGB value of Green.
        :arg int blue: RGB value of Blue.
        :rtype: FormattingString
        :returns: Callable string that sets the foreground color

        If the terminal does not support RGB color, the nearest supported
        color will be determined using :py:attr:`color_distance_algorithm`.
        r   z[48;2;{0};{1};{2}m)r¡   r}   r   rB   r9  rB  r:  rŠ   rŠ   r‹   Úon_color_rgb^  s
   
zTerminal.on_color_rgbc                 C   s*   t |ƒ}tdd„ |D ƒƒrt| |ƒS tƒ S )aö  
        Provides callable formatting string to set color and other text formatting options.

        :arg str value: Sugary, ordinary, or compound formatted terminal capability,
            such as "red_on_white", "normal", "red", or "bold_on_black".
        :rtype: :class:`FormattingString` or :class:`NullCallableString`
        :returns: Callable string that sets color and other text formatting options

        Calling ``term.formatter('bold_on_red')`` is equivalent to ``term.bold_on_red``, but a
        string that is not a valid text formatter will return a :class:`NullCallableString`.
        This is intended to allow validation of text formatters without the possibility of
        inadvertently returning another terminal capability.
        c                 s   s     | ]}|t v p|tv V  qd S r¦   )r   r   )r°   ÚfmtrŠ   rŠ   r‹   r³   ‚  s   € z%Terminal.formatter.<locals>.<genexpr>)r   Úallrº   r   )r„   ÚvalueÚ
formattersrŠ   rŠ   r‹   Ú	formatterr  s   
zTerminal.formatterc           
      C   s`   t | j }d}d}ttƒD ] \}}|||||fƒ}	|du s!|	|k r%|	}|}|| jkr- |S q|S )a:  
        Translate an RGB color to a color code of the terminal's color depth.

        :arg int red: RGB value of Red (0-255).
        :arg int green: RGB value of Green (0-255).
        :arg int blue: RGB value of Blue (0-255).
        :rtype: int
        :returns: Color code of downconverted RGB color
        é   N)r   Úcolor_distance_algorithmÚ	enumerater   r¡   )
r„   r;  r<  r=  Úfn_distancer?  Úshortest_distanceÚ	cmp_depthÚcmp_rgbÚcmp_distancerŠ   rŠ   r‹   r9  ‡  s   

þzTerminal.rgb_downconvertc                 C   s   | j r| j S t| dƒ| _ | j S )a0  
        A capability that resets all video attributes.

        :rtype: str

        ``normal`` is an alias for ``sgr0`` or ``exit_attribute_mode``. Any
        styling attributes previously applied, such as foreground or
        background colors, reverse video, or bold are reset to defaults.
        rB   )ri   r   r¤   rŠ   rŠ   r‹   rB   £  s   zTerminal.normalÚ c                 C   sl   t |ƒdk sJ t |ƒ|fƒ‚|r(t t|ƒƒdk s"J t t|ƒƒ|fƒ‚d |¡}nd}| js/|S d |||¡S )aŒ  
        Display ``text`` that when touched or clicked, navigates to ``url``.

        Optional ``url_id`` may be specified, so that non-adjacent cells can reference a single
        target, all cells painted with the same "id" will highlight on hover, rather than any
        individual one, as described in "Hovering and underlining the id parameter" of gist
        https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda.

        :param str url: Hyperlink URL.
        :param str text: Clickable text.
        :param str url_id: Optional 'id'.
        :rtype: str
        :returns: String of ``text`` as a hyperlink to ``url``.
        iÐ  éú   zid={0}rQ  z]8;{0};{1}\{2}]8;;\)ÚlenÚstrr}   rz   )r„   ÚurlÚtextÚurl_idÚparamsrŠ   rŠ   r‹   Úlink³  s   $
ÿzTerminal.linkc                 C   rØ   )a  
        Read-only property: stream the terminal outputs to.

        This is a convenience attribute. It is used internally for implied
        writes performed by context managers :meth:`~.hidden_cursor`,
        :meth:`~.fullscreen`, :meth:`~.location`, and :meth:`~.keypad`.
        )rk   r¤   rŠ   rŠ   r‹   r†   Í  s   	zTerminal.streamc                 C   rØ   )a<  
        Number of colors supported by terminal.

        Common return values are 0, 8, 16, 256, or 1 << 24.

        This may be used to test whether the terminal supports colors, and at what depth, if that's
        a concern.

        If this property is assigned a value of 88, the value 16 will be saved. This is due to the
        the rarity of 88 color support and the inconsistency of behavior between implementations.

        Assigning this property to a value other than 0, 4, 8, 16, 88, 256, or 1 << 24 will raise an
        :py:exc:`AssertionError`.
        )Ú_number_of_colorsr¤   rŠ   rŠ   r‹   r¡   Ø  s   zTerminal.number_of_colorsc                 C   s*   |dv sJ ‚|dkrdn|| _ |  ¡  d S )N)r   é   é   r  éX   é   r   r]  r  )rZ  Ú#_Terminal__clear_color_capabilities©r„   rF  rŠ   rŠ   r‹   r¡   ê  s   c                 C   rØ   )zÜ
        Color distance algorithm used by :meth:`rgb_downconvert`.

        The slowest, but most accurate, 'cie2000', is default. Other available options are 'rgb',
        'rgb-weighted', 'cie76', and 'cie94'.
        )r    r¤   rŠ   rŠ   r‹   rJ  ò  s   z!Terminal.color_distance_algorithmc                 C   s   |t v sJ ‚|| _|  ¡  d S r¦   )r   r    r_  r`  rŠ   rŠ   r‹   rJ  ü  s   c                 C   ó   | j p| jS )aA  
        Convenience capability to support :attr:`~.on_color`.

        Prefers returning sequence for capability ``setaf``, "Set foreground color to #1, using ANSI
        escape". If the given terminal does not support such sequence, fallback to returning
        attribute ``setf``, "Set foreground color #1".
        )ÚsetafÚsetfr¤   rŠ   rŠ   r‹   r7    r&  zTerminal._foreground_colorc                 C   ra  )aA  
        Convenience capability to support :attr:`~.on_color`.

        Prefers returning sequence for capability ``setab``, "Set background color to #1, using ANSI
        escape". If the given terminal does not support such sequence, fallback to returning
        attribute ``setb``, "Set background color #1".
        )ÚsetabÚsetbr¤   rŠ   rŠ   r‹   rB    r&  zTerminal._background_colorú c                 C   ó    |du r| j }t|| ƒ ||¡S )a˜  
        Left-align ``text``, which may contain terminal sequences.

        :arg str text: String to be aligned
        :arg int width: Total width to fill with aligned text. If
            unspecified, the whole width of the terminal is filled.
        :arg str fillchar: String for padding the right of ``text``
        :rtype: str
        :returns: String of ``text``, left-aligned by ``width``.
        N)r#   r   Úljust©r„   rV  r#   ÚfillcharrŠ   rŠ   r‹   rh    s   zTerminal.ljustc                 C   rg  )a—  
        Right-align ``text``, which may contain terminal sequences.

        :arg str text: String to be aligned
        :arg int width: Total width to fill with aligned text. If
            unspecified, the whole width of the terminal is used.
        :arg str fillchar: String for padding the left of ``text``
        :rtype: str
        :returns: String of ``text``, right-aligned by ``width``.
        N)r#   r   Úrjustri  rŠ   rŠ   r‹   rk  )  ó   zTerminal.rjustc                 C   rg  )a•  
        Center ``text``, which may contain terminal sequences.

        :arg str text: String to be centered
        :arg int width: Total width in which to center text. If
            unspecified, the whole width of the terminal is used.
        :arg str fillchar: String for padding the left and right of ``text``
        :rtype: str
        :returns: String of ``text``, centered by ``width``
        N)r#   r   Úcenterri  rŠ   rŠ   r‹   rm  8  rl  zTerminal.centerc                 C   s   |du r| j }t|| ƒ |¡S )az  
        Truncate ``text`` to maximum ``width`` printable characters, retaining terminal sequences.

        :arg str text: Text to truncate
        :arg int width: The maximum width to truncate it to
        :rtype: str
        :returns: ``text`` truncated to at most ``width`` printable characters

        >>> term.truncate(u'xyz\x1b[0;3m', 2)
        u'xy\x1b[0;3m'
        N)r#   r   Útruncate)r„   rV  r#   rŠ   rŠ   r‹   rn  G  s   zTerminal.truncatec                 C   ó   t || ƒ ¡ S )u¤  
        Return printable length of a string containing sequences.

        :arg str text: String to measure. May contain terminal sequences.
        :rtype: int
        :returns: The number of terminal character cells the string will occupy
            when printed

        Wide characters that consume 2 character cells are supported:

        >>> term = Terminal()
        >>> term.length(term.clear + term.red(u'ã‚³ãƒ³ãƒ‹ãƒãƒ'))
        10

        .. note:: Sequences such as 'clear', which is considered as a
            "movement sequence" because it would move the cursor to
            (y, x)(0, 0), are evaluated as a printable length of
            *0*.
        )r   Úlength©r„   rV  rŠ   rŠ   r‹   rp  W  s   zTerminal.lengthc                 C   ó   t || ƒ |¡S )zë
        Return ``text`` without sequences and leading or trailing whitespace.

        :rtype: str
        :returns: Text with leading and trailing whitespace removed

        >>> term.strip(u' \x1b[0;3m xyz ')
        u'xyz'
        )r   Ústrip©r„   rV  ÚcharsrŠ   rŠ   r‹   rs  m  ó   
zTerminal.stripc                 C   rr  )zö
        Return ``text`` without terminal sequences or trailing whitespace.

        :rtype: str
        :returns: Text with terminal sequences and trailing whitespace removed

        >>> term.rstrip(u' \x1b[0;3m xyz ')
        u'  xyz'
        )r   Úrstriprt  rŠ   rŠ   r‹   rw  y  rv  zTerminal.rstripc                 C   rr  )zó
        Return ``text`` without terminal sequences or leading whitespace.

        :rtype: str
        :returns: Text with terminal sequences and leading whitespace removed

        >>> term.lstrip(u' \x1b[0;3m xyz ')
        u'xyz '
        )r   Úlstriprt  rŠ   rŠ   r‹   rx  …  rv  zTerminal.lstripc                 C   ro  )aÜ  
        Return ``text`` stripped of only its terminal sequences.

        :rtype: str
        :returns: Text with terminal sequences removed

        >>> term.strip_seqs(u'\x1b[0;3mxyz')
        u'xyz'
        >>> term.strip_seqs(term.cuf(5) + term.red(u'test'))
        u'     test'

        .. note:: Non-destructive sequences that adjust horizontal distance
            (such as ``\b`` or ``term.cuf(5)``) are replaced by destructive
            space or erasing.
        )r   Ú
strip_seqsrq  rŠ   rŠ   r‹   ry  ‘  s   zTerminal.strip_seqsr   c                 C   sl   | j }g }tt ||¡ƒD ]&\}}| | ¡ ¡ |r3||kr3|| ¡ d… }|r0|d  |7  <  |S q|S )a™  
        Return ``text`` split by individual character elements and sequences.

        :arg str text: String containing sequences
        :arg int maxsplit: When maxsplit is nonzero, at most maxsplit splits
            occur, and the remainder of the string is returned as the final element
            of the list (same meaning is argument for :func:`re.split`).
        :rtype: list[str]
        :returns: List of sequences and individual characters

        >>> term.split_seqs(term.underline(u'xyz'))
        ['\x1b[4m', 'x', 'y', 'z', '\x1b(B', '\x1b[m']

        >>> term.split_seqs(term.underline(u'xyz'), 1)
        ['\x1b[4m', r'xyz\x1b(B\x1b[m']
        NrŸ   )rÁ   rK  r¼   Úfinditerry   Úgroupr  )r„   rV  Úmaxsplitr®   ÚresultÚidxr  Ú	remainingrŠ   rŠ   r‹   Ú
split_seqs£  s   € zTerminal.split_seqsc                 K   s\   |du r| j n|}td|| dœ|¤Ž}g }| ¡ D ]}| | ¡ r(t| |¡ƒnd¡ q|S )a¡  
        Text-wrap a string, returning a list of wrapped lines.

        :arg str text: Unlike :func:`textwrap.wrap`, ``text`` may contain
            terminal sequences, such as colors, bold, or underline. By
            default, tabs in ``text`` are expanded by
            :func:`string.expandtabs`.
        :arg int width: Unlike :func:`textwrap.wrap`, ``width`` will
            default to the width of the attached terminal.
        :arg \**kwargs: See :py:class:`textwrap.TextWrapper`
        :rtype: list
        :returns: List of wrapped lines

        See :class:`textwrap.TextWrapper` for keyword arguments that can
        customize wrapping behaviour.
        N)r#   rü   ©rQ  rŠ   )r#   r   Ú
splitlinesÚextendrs  ÚiterÚwrap)r„   rV  r#   ÚkwargsÚwrapperÚlinesÚlinerŠ   rŠ   r‹   r…  ¿  s   "zTerminal.wrapc                 C   s,   | j dusJ ‚t | j d¡}| jj|ddS )aa  
        Read, decode, and return the next byte from the keyboard stream.

        :rtype: unicode
        :returns: a single unicode character, or ``u''`` if a multi-byte
            sequence has not yet been fully received.

        This method name and behavior mimics curses ``getch(void)``, and
        it supports :meth:`inkey`, reading only one byte from
        the keyboard string at a time. This method should always return
        without blocking if called after :meth:`kbhit` has returned True.

        Implementors of alternate input stream methods should override
        this method.
        Nr   F)Úfinal)rl   rt   ÚreadrÐ   Údecode)r„   ÚbyterŠ   rŠ   r‹   ÚgetchØ  s   zTerminal.getchc                 C   s   | j  |¡ dS )z–
        Buffer input data to be discovered by next call to :meth:`~.inkey`.

        :arg str text: String to be buffered as keyboard input.
        N)rÊ   Ú
extendleftrq  rŠ   rŠ   r‹   r  ì  s   zTerminal.ungetchc                 C   sž   t   ¡ }dg}| jdur| jgng }trDzt |g g |¡\}}}W n ty@   |dur>|t   ¡ | 8 }|dkr:Y qg }Y nY nw nts| jdu rKdS ||kS )a"  
        Return whether a keypress has been detected on the keyboard.

        This method is used by :meth:`inkey` to determine if a byte may
        be read using :meth:`getch` without blocking.  The standard
        implementation simply uses the :func:`select.select` call on stdin.

        :arg float timeout: When ``timeout`` is 0, this call is
            non-blocking, otherwise blocking indefinitely until keypress
            is detected when None (default). When ``timeout`` is a
            positive number, returns after ``timeout`` seconds have
            elapsed (float).
        :rtype: bool
        :returns: True if a keypress is awaiting to be read on the keyboard
            attached to this terminal.  When input is not a terminal, False is
            always returned.
        Nr   F)Útimerl   ræ   ÚselectÚInterruptedError)r„   rý   ÚstimeÚready_rÚcheck_rÚ_rŠ   rŠ   r‹   r!   ô  s$   ùòæzTerminal.kbhitc                 c   ó‚    t r<| jdur<t | j¡}| j}t | jtj¡ zd| _dV  W t | jtj	|¡ || _dS t | jtj	|¡ || _w dV  dS )a0  
        Allow each keystroke to be read immediately after it is pressed.

        This is a context manager for :func:`tty.setcbreak`.

        This context manager activates 'rare' mode, the opposite of 'cooked'
        mode: On entry, :func:`tty.setcbreak` mode is activated disabling
        line-buffering of keyboard input and turning off automatic echo of
        input as output.

        .. note:: You must explicitly print any user input you would like
            displayed.  If you provide any kind of editing, you must handle
            backspace and other line-editing control functions in this mode
            as well!

        **Normally**, characters received from the keyboard cannot be read
        by Python until the *Return* key is pressed. Also known as *cooked* or
        *canonical input* mode, it allows the tty driver to provide
        line-editing before shuttling the input to your program and is the
        (implicit) default terminal mode set by most unix shells before
        executing programs.

        Technically, this context manager sets the :mod:`termios` attributes
        of the terminal attached to :obj:`sys.__stdin__`.

        .. note:: :func:`tty.setcbreak` sets ``VMIN = 1`` and ``VTIME = 0``,
            see http://www.unixwiz.net/techtips/termios-vmin-vtime.html
        NF)
ræ   rl   ré   Ú	tcgetattrrj   ÚttyÚ	setcbreakÚTCSANOWÚ	tcsetattrÚ	TCSAFLUSH©r„   Ú	save_modeÚsave_line_bufferedrŠ   rŠ   r‹   r    (  s&   €þ
ýþ
zTerminal.cbreakc                 c   r—  )aÿ  
        A context manager for :func:`tty.setraw`.

        Although both :meth:`cbreak` and :meth:`raw` modes allow each keystroke
        to be read immediately after it is pressed, Raw mode disables
        processing of input and output.

        In cbreak mode, special input characters such as ``^C`` or ``^S`` are
        interpreted by the terminal driver and excluded from the stdin stream.
        In raw mode these values are received by the :meth:`inkey` method.

        Because output processing is not done, the newline ``'\n'`` is not
        enough, you must also print carriage return to ensure that the cursor
        is returned to the first column::

            with term.raw():
                print("printing in raw mode", end="\r\n")
        NF)
ræ   rl   ré   r˜  rj   r™  r   r›  rœ  r  rž  rŠ   rŠ   r‹   ÚrawX  s&   €þ
ýþ
zTerminal.rawc              	   c   sZ    z| j  | j¡ | j  ¡  dV  W | j  | j¡ | j  ¡  dS | j  | j¡ | j  ¡  w )a¡  
        Context manager that enables directional keypad input.

        On entrying, this puts the terminal into "keyboard_transmit" mode by
        emitting the keypad_xmit (smkx) capability. On exit, it emits
        keypad_local (rmkx).

        On an IBM-PC keyboard with numeric keypad of terminal-type *xterm*,
        with numlock off, the lower-left diagonal key transmits sequence
        ``\\x1b[F``, translated to :class:`~.Terminal` attribute
        ``KEY_END``.

        However, upon entering :meth:`keypad`, ``\\x1b[OF`` is transmitted,
        translating to ``KEY_LL`` (lower-left key), allowing you to determine
        diagonal direction keys.
        N)r†   rÿ   Úsmkxr   Úrmkxr¤   rŠ   rŠ   r‹   Úkeypad}  s   €
ÿzTerminal.keypadc                 C   s<  t   ¡ }d}| jr|| j ¡ 7 }| js	| jddr%||  ¡ 7 }| jddst|| j| jƒ}|sQ| jt||ƒdrQ||  ¡ 7 }t|| j| jƒ}|sQ| jt||ƒds8|j	| j
kr‘t   ¡ }|j	| j
kr‘|| jv r‘| jt||ƒdr‘||  ¡ 7 }t|| j| jƒ}|j	| j
kr‘|| jv r‘| jt||ƒdso|  |t|ƒd… ¡ |S )a­  
        Read and return the next keyboard event within given timeout.

        Generally, this should be used inside the :meth:`raw` context manager.

        :arg float timeout: Number of seconds to wait for a keystroke before
            returning.  When ``None`` (default), this method may block
            indefinitely.
        :arg float esc_delay: Time in seconds to block after Escape key
           is received to await another key sequence beginning with
           escape such as *KEY_LEFT*, sequence ``'\x1b[D'``], before returning a
           :class:`~.Keystroke` instance for ``KEY_ESCAPE``.

           Users may override the default value of ``esc_delay`` in seconds,
           using environment value of ``ESCDELAY`` as milliseconds, see
           `ncurses(3)`_ section labeled *ESCDELAY* for details.  Setting
           the value as an argument to this function will override any
           such preference.
        :rtype: :class:`~.Keystroke`.
        :returns: :class:`~.Keystroke`, which may be empty (``u''``) if
           ``timeout`` is specified and keystroke is not received.

        .. note:: When used without the context manager :meth:`cbreak`, or
            :meth:`raw`, :obj:`sys.__stdin__` remains line-buffered, and this
            function will block until the return key is pressed!

        .. note:: On Windows, a 10 ms sleep is added to the key press detection loop to reduce CPU
            load. Due to the behavior of :py:func:`time.sleep` on Windows, this will actually
            result in a 15.6 ms delay when using the default `time resolution
            <https://docs.microsoft.com/en-us/windows/win32/api/timeapi/nf-timeapi-timebeginperiod>`_.
            Decreasing the time resolution will reduce this to 10 ms, while increasing it, which
            is rarely done, will have a perceptable impact on the behavior.

        _`ncurses(3)`: https://www.man7.org/linux/man-pages/man3/ncurses.3x.html
        rQ  r   )rý   N)r  rÊ   Úpopr!   rŽ  r   rÇ   rÅ   r   ÚcodeÚ
KEY_ESCAPErÈ   r  rS  )r„   rý   Ú	esc_delayr“  ÚucsÚksÚesctimerŠ   rŠ   r‹   Úinkey—  s6   $ÿÿþ
ÿü
ÿzTerminal.inkey)NNF)NNr¦   r  )Nrf  )r   )GÚ__name__Ú
__module__Ú__qualname__Ú__doc__Ú_sugarrŒ   ro   r   r_  r‚   rƒ   r×   Úpropertyr…   rz   rx   r"   r#   rà   râ   Ústaticmethodrò   rÛ   r	  Ú
contextlibÚcontextmanagerr  r  r  r   r"  r#  r%  r7   r*  r.  r1  r4  r6  r@  rA  rC  rH  r9  rB   rY  r†   r¡   ÚsetterrJ  r7  rB  rh  rk  rm  rn  rp  rs  rw  rx  ry  r€  r…  rŽ  r  r!   r    r¡  r¤  r   r¬  rŠ   rŠ   rŠ   r‹   r&   K   s   ÿþýüûúùø	÷
öõôóòñðïà
#S2	$$"







%,
4
K















	














4
/
$
r&   c                   @   s"   e Zd ZdZdZde e¡ ZdS )rë   aF  
    Structure represents return value of :const:`termios.TIOCGWINSZ`.

    .. py:attribute:: ws_row

        rows, in characters

    .. py:attribute:: ws_col

        columns, in characters

    .. py:attribute:: ws_xpixel

        horizontal size, pixels

    .. py:attribute:: ws_ypixel

        vertical size, pixels
    Úhhhhú N)r­  r®  r¯  r°  rï   rí   Úcalcsizerì   rŠ   rŠ   rŠ   r‹   rë   ç  s    rë   rå   )Cr°  rt   r¼   rŽ   r  rÎ   rË   r‘  rí   r$   r~   r´  r¶   r6  r   Úkeyboardr   r   r   r   r   r	   r
   Ú	sequencesr   r   r   Ú
colorspacer   rG  r   r   r   r   r   r   r   r   r   Ú_capabilitiesr   r   r   Úversion_infor|   r’  ræ   Úsystemrp   Újinxedrq   Újinxed.win32r   rç   ré   r™  ÚImportErrorÚ_TTY_METHODSr}   r¾   Ú_MSG_NOSUPPORTr   r€   Úobjectr&   Ú
namedtuplerë   rŠ   rŠ   rŠ   r‹   Ú<module>   sp   $,	ûÿ
ö           '