
    F\h                         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      nUS;   a  gg)N   r   )NNaHA   )ordunicodedataeast_asian_width)r
   ws     $/usr/lib/python3.13/_pyrepl/utils.py	str_widthr      s/    
1v|$$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   wlenr.      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   r/   s     r   	unbracketr5   !   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})r6   r   b)	appendr   r   category
startswithr&   r   r   repr)r6   charschar_widthsr
   s       r   disp_strr@   ,   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(   r1   str	maketransr4   cacheintr   r.   boolr5   tupler@    r   r   <module>rL      s    	   ) zz"67 ZZ/ =="b!9:     ?C ?C ?) ) )# )!S !U:z#9: !r   