
    (phXH                     v   S r SSKrSSKrSSKrSSKrSSKJr  SSKJrJ	r	  \R                  " 5       S:X  a  SSKrSSKJr  O
SSKrSSKJr   " S S\5      rS	 rS
 rS rS rS rS rS rS rSr\" \" 5       R9                  5       5      r\ H  r\S-  r\\" 5       S\-   '   M     / \	" S5      \R@                  4P\	" S5      \R@                  4P\	" S5      \RB                  4P\	" S5      \"4P\	" S5      \RF                  4P\	" S5      \RB                  4PS\RH                  4PS\RJ                  4PS\RL                  4PS\RN                  4PS\RP                  4PS\RR                  4PS \RT                  4PS!\RV                  4PS"\RX                  4PS#\RZ                  4PS$\RX                  4PS%\R\                  4PS&\R^                  4PS'\R@                  4PS(\04PS)\14PS*\24PS+\34PS,\44PS-\54PS.\64PS/\74PS0\84PS1\94PS2\:4PS3\;4PS4\<4PS5\=4PS6\>4PS7\?4PS8\@4PS9\R                  4PS:\R                  4PS;\R                  4PS<\R                  4PS=\R^                  4PS>\R\                  4PS?\RZ                  4PS@\RX                  4PSA\RH                  4PSB\RJ                  4PSC\RL                  4PSD\RN                  4PSE\RX                  4PSF\RZ                  4PSG\R                  4PSH\R                  4PSI\R                  4PSJ\R                  4P7rISK\R                  4SL\R                  4SM\R^                  4SN\R\                  4SO\RF                  4SP\RP                  4SQ\RR                  4SR\R                  4SS\R                  4ST\R                  4SU\R                  44rNSVqOSW rP\P" 5         SXrQg)Yz*Sub-module providing 'keyboard awareness'.    N)OrderedDict)TextTypeunicode_chrWindows)_capability_namesc                   z    \ rS rSrSrS
S jr\S 5       rS r\	R                  \l        \S 5       r
\S 5       rS	rg)	Keystroke   a  
A unicode-derived class for describing a single keystroke.

A class instance describes a single keystroke received on input,
which may contain multiple characters as a multibyte sequence,
which is indicated by properties :attr:`is_sequence` returning
``True``.

When the string is a known sequence, :attr:`code` matches terminal
class attributes for comparison, such as ``term.KEY_LEFT``.

The string-name of the sequence, such as ``u'KEY_LEFT'`` is accessed
by property :attr:`name`, and is used by the :meth:`__repr__` method
to display a human-readable form of the Keystroke this class
instance represents. It may otherwise by joined, split, or evaluated
just as as any other unicode string.
Nc                 J    [         R                  " X5      nX4l        X$l        U$ )zClass constructor.)r   __new___name_code)clsucscodenamenews        C/var/www/html/venv/lib/python3.13/site-packages/blessed/keyboard.pyr   Keystroke.__new__+   s!    s(		
    c                     U R                   SL$ )z9Whether the value represents a multibyte sequence (bool).Nr   selfs    r   is_sequenceKeystroke.is_sequence2   s     zz%%r   c                 `    U R                   c  [        R                  " U 5      $ U R                   $ )zDocstring overwritten.)r   r   __repr__r   s    r   r   Keystroke.__repr__7   s*    +/::+=!!$' 	

	r   c                     U R                   $ )z;String-name of key sequence, such as ``u'KEY_LEFT'`` (str).)r   r   s    r   r   Keystroke.name=        zzr   c                     U R                   $ )z2Integer keycode value of multibyte sequence (int).r   r   s    r   r   Keystroke.codeB   r"   r    ) NN)__name__
__module____qualname____firstlineno____doc__r   propertyr   r   r   r   r   __static_attributes__r%   r   r   r	   r	      s[    $ & &  ''H   r   r	   c                      [        [        5       V s/ s H  n U R                  S5      (       d  M  U PM     nn U Vs0 s H  o"[        [        U5      _M     sn$ s  sn f s  snf )a  
Return mapping of curses key-names paired by their keycode integer value.

:rtype: dict
:returns: Dictionary of (name, code) pairs for curses keyboard constant
    values and their mnemonic name. Such as code ``260``, with the value of
    its key-name identity, ``u'KEY_LEFT'``.
KEY_)dircurses
startswithgetattr)attr	_keynameskeynames      r   get_curses_keycodesr7   H   sV     #&f+ -+$OOF+ +I -=FGY'WVW--YGG-Gs   AAAc                  ,   [        [        5       5      n U R                  [        5        U R                  S [	        5       R                  5       R                  5        5       5        [        [        U R                  5       U R                  5       5      5      $ )a  
Return mapping of keycode integer values paired by their curses key-name.

:rtype: dict
:returns: Dictionary of (code, name) pairs for curses keyboard constant
    values and their mnemonic name. Such as key ``260``, with the value of
    its identity, ``u'KEY_LEFT'``.

These keys are derived from the attributes by the same of the curses module,
with the following exceptions:

* ``KEY_DELETE`` in place of ``KEY_DC``
* ``KEY_INSERT`` in place of ``KEY_IC``
* ``KEY_PGUP`` in place of ``KEY_PPAGE``
* ``KEY_PGDOWN`` in place of ``KEY_NPAGE``
* ``KEY_ESCAPE`` in place of ``KEY_EXIT``
* ``KEY_SUP`` in place of ``KEY_SR``
* ``KEY_SDOWN`` in place of ``KEY_SF``

This function is the inverse of :func:`get_curses_keycodes`.  With the
given override "mixins" listed above, the keycode for the delete key will
map to our imaginary ``KEY_DELETE`` mnemonic, effectively erasing the
phrase ``KEY_DC`` from our code vocabulary for anyone that wishes to use
the return value to determine the key-name by keycode.
c              3   \   #    U  H"  u  pUR                  S 5      (       d  M  X4v   M$     g7f)r/   N)r2   ).0r   values      r   	<genexpr>%get_keyboard_codes.<locals>.<genexpr>s   s&      )A+$T__U[E\)As   ,
,)r   r7   updateCURSES_KEYCODE_OVERRIDE_MIXINglobalscopyitemsdictzipvalueskeys)keycodess    r   get_keyboard_codesrH   V   sk    4 .01HOO12OO )0)9)?)?)A  HOO%x}}788r   c                     0 nU R                   (       a,  U R                   S:w  a  [        R                  XR                   '   U R                  (       a,  U R                  S:w  a  [        R                  XR                  '   U$ )a^  
Determine and return mapping of left and right arrow keys sequences.

:arg blessed.Terminal term: :class:`~.Terminal` instance.
:rtype: dict
:returns: Dictionary of sequences ``term._cuf1``, and ``term._cub1``,
    valued as ``KEY_RIGHT``, ``KEY_LEFT`` (when appropriate).

This function supports :func:`get_terminal_sequences` to discover
the preferred input sequence for the left and right application keys.

It is necessary to check the value of these sequences to ensure we do not
use ``u' '`` and ``u'\b'`` for ``KEY_RIGHT`` and ``KEY_LEFT``,
preferring their true application key sequence, instead.
 )_cuf1r1   	KEY_RIGHT_cub1KEY_LEFT)termkeymaps     r   _alternative_left_rightrR   |   sT    " FzzdjjD(#--zzzzdjjE)#__zzMr   c           	      @  ^ [        U R                  (       a#  S S [        R                  " 5        5        5       OS5      mTR	                  [        U 5      5        TR	                  [        5        [        U4S j[        TR                  5       [        SS9 5       5      $ )a  
Return mapping of keyboard sequences paired by keycodes.

:arg blessed.Terminal term: :class:`~.Terminal` instance.
:returns: mapping of keyboard unicode sequences paired by keycodes
    as integer.  This is used as the argument ``mapper`` to
    the supporting function :func:`resolve_sequence`.
:rtype: OrderedDict

Initialize and return a keyboard map and sequence lookup table,
(sequence, keycode) from :class:`~.Terminal` instance ``term``,
where ``sequence`` is a multibyte input sequence of unicode
characters, such as ``u'\x1b[D'``, and ``keycode`` is an integer
value, matching curses constant such as term.KEY_LEFT.

The return value is an OrderedDict instance, with their keys
sorted longest-first.
c              3   ^   #    U  H#  u  pU(       d  M  UR                  S 5      U4v   M%     g7f)latin1N)decode)r:   seqvals      r   r<   )get_keyboard_sequences.<locals>.<genexpr>   s2      
JS 	 	$H	s#
s   --c              3   V   #    U  H  u  p[         R                  " U5      U4v   M!     g 7fN)r1   tigetstr)r:   rX   caps      r   r<   rY      s'      
6
 __S!3'6s   ')r%   c              3   0   >#    U  H  oTU   4v   M     g 7fr[   r%   )r:   rW   sequence_maps     r   r<   rY      s!      9-8Sl3  -8s   T)keyreverse)rC   does_stylingcapability_namesrB   r>   rR   DEFAULT_SEQUENCE_MIXINr   sortedrF   len)rP   r_   s    @r   get_keyboard_sequencesrg      s    <  
		
.446
 !#$L /56./
  9,2S$-89 : :r   c           
      v    U  VVs1 s H$  n[        S[        U5      5        H  o!SU iM	     M&     snn$ s  snnf )a  
Return a set of proper prefixes for given sequence of strings.

:arg iterable sequences
:rtype: set
:return: Set of all string prefixes

Given an iterable of strings, all textparts leading up to the final
string is returned as a unique set.  This function supports the
:meth:`~.Terminal.inkey` method by determining whether the given
input is a sequence that **may** lead to a final matching pattern.

>>> prefixes(['abc', 'abdf', 'e', 'jkl'])
set([u'a', u'ab', u'abd', u'j', u'jk'])
   N)rangerf   )	sequencesrW   is      r   get_leading_prefixesrm      s4       )Ey%3s82DQG2DGyEEEs   +5c                     UR                  5        H)  u  p4U R                  U5      (       d  M  [        X4X$   S9s  $    [        U =(       a    U S   =(       d    SS9$ )a  
Return a single :class:`Keystroke` instance for given sequence ``text``.

:arg str text: string of characters received from terminal input stream.
:arg OrderedDict mapper: unicode multibyte sequences, such as ``u'\x1b[D'``
    paired by their integer value (260)
:arg dict codes: a :type:`dict` of integer values (such as 260) paired
    by their mnemonic name, such as ``'KEY_LEFT'``.
:rtype: Keystroke
:returns: Keystroke instance for the given sequence

The given ``text`` may extend beyond a matching sequence, such as
``u\x1b[Dxxx`` returns a :class:`Keystroke` instance of attribute
:attr:`Keystroke.sequence` valued only ``u\x1b[D``.  It is up to
calls to determine that ``xxx`` remains unresolved.
)r   r   r   r   r&   )r   )rB   r2   r	   )textmappercodessequencer   s        r   resolve_sequencers      sO    " !,,.??8$$5;GG ) )$q'0S11r   c                 ^    U(       a%  [        SU[        R                  " 5       U -
  -
  5      $ U$ )a  
Return time remaining since ``stime`` before given ``timeout``.

This function assists determining the value of ``timeout`` for
class method :meth:`~.Terminal.kbhit` and similar functions.

:arg float stime: starting time for measurement
:arg float timeout: timeout period, may be set to None to
   indicate no timeout (where None is always returned).
:rtype: float or int
:returns: time remaining as float. If no time is remaining,
   then the integer ``0`` is returned.
r   )maxtime)stimetimeouts     r   
_time_leftry      s(     7>3q'TYY[5012J7Jr   c                    [         R                   " 5       nSu  pE U R                  [        X25      S9nU(       a  XV-  nU R                  SS9nU(       a  M  [        R                  " XS9nUb   XE4$ Ub  [        X25      (       d   XE4$ Mo  )a  
Convenience read-until-pattern function, supporting :meth:`~.get_location`.

:arg blessed.Terminal term: :class:`~.Terminal` instance.
:arg float timeout: timeout period, may be set to None to indicate no
    timeout (where 0 is always returned).
:arg str pattern: target regular expression pattern to seek.
:rtype: tuple
:returns: tuple in form of ``(match, str)``, *match*
    may be :class:`re.MatchObject` if pattern is discovered
    in input stream before timeout has elapsed, otherwise
    None. ``str`` is any remaining text received exclusive
    of the matching pattern).

The reason a tuple containing non-matching data is returned, is that the
consumer should push such data back into the input buffer by
:meth:`~.Terminal.ungetch` if any was received.

For example, when a user is performing rapid input keystrokes while its
terminal emulator surreptitiously responds to this in-band sequence, we
must ensure any such keyboard data is well-received by the next call to
term.inkey() without delay.
)Nr&   )rx   r   )patternstring)rv   inkeyry   research)rP   r{   rx   rw   matchbufr   s          r   _read_untilr     s    0 IIKEJE  jjE!;j<
 JC**Q*'C c 		'6 :	 z%'A'A:+ r   )TABKP_MULTIPLYKP_ADDKP_SEPARATORKP_SUBTRACT
KP_DECIMAL	KP_DIVIDEKP_EQUALKP_0KP_1KP_2KP_3KP_4KP_5KP_6KP_7KP_8KP_9ri   r/   
         	         z[Az[Bz[Cz[Dz[1;2Az[1;2Bz[1;2Cz[1;2Dz[Fz[Hz[Kz[Uz[VzOMzOjzOkzOlzOmzOnzOozOXzOpzOqzOrzOszOtzOuzOvzOwzOxzOyz[1~z[2~z[3~z[4~z[5~z[6~z[7~z[8~z[OAz[OBz[OCz[ODz[OFz[OHzOPzOQzORzOS
KEY_DELETE
KEY_INSERTKEY_PGUP
KEY_PGDOWN
KEY_ESCAPEKEY_SUP	KEY_SDOWNKEY_UP_LEFTKEY_UP_RIGHT
KEY_CENTER	KEY_BEGINgffffff?c                      [         R                  R                  S5      (       a!   [        [         R                  S   5      S-  qg g ! [
         a     g f = f)NESCDELAYg     @@)osenvirongetintDEFAULT_ESCDELAY
ValueErrorr%   r   r   _reinit_escdelayr     sN    
 
zz~~j!!	"2::j#9:VC "  		s   A 
AA)r	   rH   rg   )Rr+   r   r~   rv   platformcollectionsr   blessed._compatr   r   systemjinxedr1   jinxed.has_keyr   rc   curses.has_keyr	   r7   rH   rR   rg   rm   rs   ry   r   _CURSES_KEYCODE_ADDINSru   rE   _LASTVALkeycode_namer@   	KEY_ENTERKEY_BACKSPACEKEY_TABKEY_EXITKEY_UPKEY_DOWNrM   rO   KEY_SRKEY_SF
KEY_SRIGHT	KEY_SLEFTKEY_ENDKEY_HOME	KEY_NPAGE	KEY_PPAGEKEY_KP_MULTIPLY
KEY_KP_ADDKEY_KP_SEPARATORKEY_KP_SUBTRACTKEY_KP_DECIMALKEY_KP_DIVIDEKEY_KP_EQUALKEY_KP_0KEY_KP_1KEY_KP_2KEY_KP_3KEY_KP_4KEY_KP_5KEY_KP_6KEY_KP_7KEY_KP_8KEY_KP_9KEY_FINDKEY_ICKEY_DC
KEY_SELECTKEY_F1KEY_F2KEY_F3KEY_F4rd   KEY_A1KEY_A3KEY_B2KEY_BEGr?   r   r   __all__r%   r   r   <module>r      s   0 
 	   # 2 ??	!DD- -`H#9L2.:bF&2.K"5@ ( "$++-.*LMH'/GIf|#$ +&H _f&&'H _f&&'	H
 ^V))*H ^WH _foo&H v++,H H  H   !H  H 6==!H 6==!H  6$$%!H" 6##$#H$ %H&  'H* +H,   !-H.   !/H<   !=H>  ?H@ 
AHB  !CHD  EHF GHH IHJ KHL MHN OHP QHR SHT UHV WHX YHZ [H\ ]H^ _Hd !eHf gHh iHj ""#kHl !!"mHn !!"oHp !qHr  sHt uHv !wHx !!"yHz !{H|  }H~ !HH IHJ KHL MHN OH \ 6==!6==!!!"6##$6??#&-- FMM"V]]#6==!&..!! &  
   Ir   