
    F\h<                     `   S r SSSSSSSSS	S
SS.r0 SS_SS_SS_SS_SS	_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_S S _S!S!_S"S"_S#S#_S$S$_S%S%_S&S&_S'S'_S(S(_S)S)_S*S*_S+S+_S,S	_S-S-_S.S/_ES
S0S1.Er " S2 S3\5      rS4\S,\\   4S5 jrS6\S7\S,\	\\   \4   4S8 jr
S;S9 jrg:)<an  
Keymap contains functions for parsing keyspecs and turning keyspecs into
appropriate sequences.

A keyspec is a string representing a sequence of key presses that can
be bound to a command. All characters other than the backslash represent
themselves. In the traditional manner, a backslash introduces an escape
sequence.

pyrepl uses its own keyspec format that is meant to be a strict superset of
readline's KEYSEQ format. This means that if a spec is found that readline
accepts that this doesn't, it should be logged as a bug. Note that this means
we're using the `\C-o' style of readline's keyspec, not the `Control-o' sort.

The extension to readline is that the sequence \<KEY> denotes the
sequence of characters produced by hitting KEY.

Examples:
`a'      - what you get when you hit the `a' key
`\EOA'  - Escape - O - A (up, on my terminal)
`\<UP>' - the up arrow key
`\<up>' - ditto (keynames are case-insensitive)
`\C-o', `\c-o'  - control-o
`\M-.'  - meta-period
`\E.'   - ditto (that's how meta works for pyrepl)
`\<tab>', `\<TAB>', `\t', `\011', '\x09', '\X09', '\C-i', '\C-I'
   - all of these are the tab character.
\'"
	)r   r   r   abefnrtv	backspacedeletedownendenterescapef1f2f3f4f5f6f7f8f9f10f11f12f13f14f15f16f17f18f19f20homeinsertleftz	page downzpage upreturnrightspace up)tabr6   c                       \ rS rSrSrg)KeySpecErrorh    N)__name__
__module____qualname____firstlineno____static_attributes__r;       %/usr/lib/python3.13/_pyrepl/keymap.pyr9   r9   h   s    rA   r9   keysc                     Sn/ nU[        U 5      :  a/  [        X5      u  p1UR                  U5        U[        U 5      :  a  M/  U$ )z3Parse keys in keyspec format to a sequence of keys.    )len_parse_single_key_sequenceextend)rC   sr   ks       rB   
parse_keysrK   l   sB    	AA
c$i-)$2	 c$i- HrA   keyrI   c                 D   SnSnSnU(       Gd+  U[        U 5      :  Ga  X   S:X  Ga  XS-      R                  5       nU[        ;   a  [        U   nUS-  nGOUS:X  aS  XS-      S:w  a  [        SUS-   [	        U 5      4-  5      eU(       a  [        S	US-   [	        U 5      4-  5      eSnUS
-  nGOqUS:X  aS  XS-      S:w  a  [        SUS-   [	        U 5      4-  5      eU(       a  [        SUS-   [	        U 5      4-  5      eSnUS
-  nGOUR                  5       (       a%  XS-   US-    n[        [        US5      5      nUS-  nOUS:X  a%  XS-   US-    n[        [        US5      5      nUS-  nOUS:X  a~  U R                  SU5      nUS:X  a  [        SUS-   [	        U 5      4-  5      eXS-   U R                  5       nU[        ;  a  [        SXAS-   [	        U 5      4-  5      e[        U   nUS-   nO/[        S[	        U5      US-   [	        U 5      4-  5      eX   nUS-  nU(       d  U[        U 5      :  a  GM  U(       a>  [        U5      S:X  a  [        [        U5      S-  5      nOUS;   a  SU 3nO[        S5      eU/U4nU(       a  US   R                  SS5        U$ )NrE    r         c-z*\C must be followed by `-' (char %d of %s)zdoubled \C- (char %d of %s)   mz*\M must be followed by `-' (char %d of %s)zdoubled \M- (char %d of %s)      x   <>z)unterminated \< starting at char %d of %sz*unrecognised keyname `%s' at char %d of %sz,unknown backslash escape %s at char %d of %s   >   r1   r3   zctrl z\C- followed by invalid keyr   )rF   lower_escapesr9   reprisdigitchrintfind	_keynamesordr0   )	rL   rI   ctrlmetaretrQ   r   r   results	            rB   rG   rG   v   s   DD
Ca#c(l6T>E
  "AH}qkQc1u:$&Eq5$s),-  &6!a%c9KK  Qc1u:$&Eq5$s),-  &6!a%c9KK  QAA&#a)nQcAA&#a*oQcHHS!$7&Dq5$s),-  a%!n**,i'&DAtCy12   nE"BAwAtCy12 
 &CFAy a#c(lz s8q=c#ho&C%%#-C=>>UAXFq	F#MrA   c                 j   0 nU R                  5        H<  u  p4[        U[        5      (       a  US S nOUS   nXBR                  U0 5      USS  '   M>     UR                  5        HL  u  p4X;   a5  [	        U5      S:w  a  [        SUR                  5       < S35      eXA   X#'   M?  [        XA5      X#'   MN     U$ )NrO   rE   zkey definitions for z clash)items
isinstancebytes
setdefaultrF   r9   valuescompile_keymap)keymapemptyr   rL   valuefirsts         rB   rp   rp      s    
Alln
c5!!GEFE+0UBAB( % ggi
>5zQ"U\\^#UVV#E1AF   HrA   N)rA   )__doc__r^   rd   	Exceptionr9   strlistrK   rb   tuplerG   rp   r;   rA   rB   <module>rz      s9  *< 										%%h% F% 
5	%
 T% f% 	$% 	$% 	$% 	$% 	$% 	$% 	$% 	$% 	$%  
5!%" 
5#%$ 
5%%& 
5'%( 
5)%* 
5+%, 
5-%. 
5/%0 
51%2 
53%4 
55%6 F7%8 h9%: F;%< =%> y?%@ dA%B WC%D SE%F 
I%	P	9 	S T#Y LC LC LE$s)S.4I L^rA   