
    	                         S SK r S SKrS SKrSSKJrJr  SSKJr  \ R                  " S5      r\ R                  " S5      r	\
R                  SSS.5      r\R                  S	\
S
\4S j5       rS\
S
\4S jrSS\
S\S
\
4S jjrS\
S
\\\4   4S jrg)    N   )
CharBuffer
CharWidths)tracez\x1b\[[ -@]*[A-~]z\x01.*?\x02 )creturnc                     [        U 5      S:  a  g[        R                  " U 5      (       a  g[        R                  " U 5      nUS:X  a  U S:w  a  g[        R                  " U 5      nUS;   a  gg)N   r   r   Cf   ­)NNaHA   )ordunicodedata	combiningcategoryeast_asian_width)r
   r   ws      :platform/bundledpythonunix/lib/python3.13/_pyrepl/utils.py	str_widthr      sd    
1v|Q##A&H4AM$$Q'A!!    sc                     [        U 5      S:X  a  U S:w  a  [        U 5      $ [        S U  5       5      n[        R	                  U 5      nU R                  S5      nU[        S U 5       5      -
  U-   $ )Nr   c              3   8   #    U  H  n[        U5      v   M     g 7fN)r   .0is     r   	<genexpr>wlen.<locals>.<genexpr>    s     )q!1q   c              3   8   #    U  H  n[        U5      v   M     g 7fr"   )lenr#   s     r   r&   r'   $   s     11Ar(   )r*   r   sumANSI_ESCAPE_SEQUENCEfindallcount)r   lengthsequence
ctrl_z_cnts       r   wlenr2      se    
1v{qF{|)q))F#++A.HJC1111J>>r   including_contentc                 f    U(       a  [         R                  SU 5      $ U R                  [        5      $ )zReturn `s` with \001 and \002 characters removed.

If `including_content` is True, content between \001 and \002 is also
stripped.
r   )ZERO_WIDTH_BRACKETsub	translateZERO_WIDTH_TRANS)r   r3   s     r   	unbracketr9   '   s*     !%%b!,,;;'((r   bufferc                 8   / n/ nU (       d  X4$ U  H  nUS:X  a$  UR                  U5        UR                  S5        M-  [        U5      S:  a$  UR                  U5        UR                  S5        M`  [        R                  " U5      R	                  S5      (       a;  S[        U5      -  nUR                  U5        UR                  [        U5      5        M  UR                  U5        UR                  [        U5      5        M     [        S[        U 5      XS9  X4$ )	a6  Decompose the input buffer into a printable variant.

Returns a tuple of two lists:
- the first list is the input buffer, character by character;
- the second list is the visible width of each character in the input
  buffer.

Examples:
>>> utils.disp_str("a = 9")
(['a', ' ', '=', ' ', '9'], [1, 1, 1, 1, 1])
r    r   r   r   Cz\u%04xzdisp_str({buffer}) = {s}, {b})r:   r   b)	appendr   r   r   
startswithr*   r   r   repr)r:   charschar_widthsr
   s       r   disp_strrC   2   s     E K!!;LLOq!Vc\LLOq!!!!$//44CF"ALLOs1v&LLOy|,  

)$v,%Wr   )F)rer   	functoolstypesr   r   r   compiler,   r5   str	maketransr8   cacheintr   r2   boolr9   tuplerC    r   r   <module>rO      s    	   ) zz"67 ZZ/ =="b!9:     ?C ?C ?) ) )# )!S !U:z#9: !r   