
    Vi              
          S SK r S SKJr  S SKJrJr  SSKJr  \ R                  " S5      R                  r
\" S5      S\S	\4S
 j5       r\4S\S\\/\4   S	\4S jjr\" SS9S\S	\4S j5       r\" SS9S\S	\4S j5       rS\S\S	\4S jrSS\S\S\S	\\   4S jjr\S:X  aU  \" \" S5      5        \" SS5       H  r\" \5        M     \" SSS5       H   r\" \" S\5      S-   5        \" S\-  5        M"     gg)     N)	lru_cache)CallableList   )CELL_WIDTHSu   ^[ -o ˿Ͱ-҂]*$i   textreturnc                 >   ^ [         m[        U4S jU  5       5      nU$ )a  Get the number of cells required to display text.

This method always caches, which may use up a lot of memory. It is recommended to use
`cell_len` over this method.

Args:
    text (str): Text to display.

Returns:
    int: Get the number of cells required to display text.
c              3   4   >#    U  H  nT" U5      v   M     g 7fN .0	character	_get_sizes     ]/home/james-whalen/.local/share/pipx/venvs/semgrep/lib/python3.13/site-packages/rich/cells.py	<genexpr>"cached_cell_len.<locals>.<genexpr>        @4iYy))4   )get_character_cell_sizesum)r   
total_sizer   s     @r   cached_cell_lenr      s      (I@4@@J    	_cell_lenc                 l   ^ [        U 5      S:  a  U" U 5      $ [        m[        U4S jU  5       5      nU$ )zGet the number of cells required to display text.

Args:
    text (str): Text to display.

Returns:
    int: Get the number of cells required to display text.
i   c              3   4   >#    U  H  nT" U5      v   M     g 7fr   r   r   s     r   r   cell_len.<locals>.<genexpr>)   r   r   )lenr   r   )r   r   r   r   s      @r   cell_lenr!      s5     4y3'I@4@@Jr   )maxsizer   c                 *    [        [        U 5      5      $ )zGet the cell size of a character.

Args:
    character (str): A single character.

Returns:
    int: Number of cells (0, 1 or 2) occupied by that character.
)_get_codepoint_cell_sizeord)r   s    r   r   r   -   s     $C	N33r   	codepointc                     [         nSn[        U5      S-
  nX#-   S-  n X   u  pVnX:  a  US-
  nOX:  a  US-   nO
US:X  a  S$ U$ X2:  a   gX#-   S-  nM7  )zGet the cell size of a character.

Args:
    codepoint (int): Codepoint of a character.

Returns:
    int: Number of cells (0, 1 or 2) occupied by that character.
r   r      )r   r    )r&   _tablelower_boundupper_boundindexstartendwidths           r   r$   r$   :   s     FKf+/K&1,E
"ME!)K_!)K1..$ *q0 r   totalc                 j   [        U 5      (       a  [        U 5      nX!:  a
  U SX-
  -  -   $ U SU $ US::  a  g[        U 5      nX1:X  a  U $ X1:  a
  U SX-
  -  -   $ Sn[        U 5      n XE-   S-  nU SUS-    n[        U5      nXS-   :X  a  [        US   5      S:X  a  USS S-   $ X:X  a  U$ X:  a  UnOUnMO  )z?Set the length of a string to fit within given number of cells. Nr    r(   r   r)   )_is_single_cell_widthsr    r!   )	r   r1   size	cell_sizer.   r/   posbefore
before_lens	            r   set_cell_sizer;   W   s     d##4y<#...FU|zIcU.///E
d)C {q iaf%
"xr
';q'@#2;$$MCE r   max_sizepositionc                 Z   [         nU  Vs/ s H  oDU" U5      4PM     nnUn/ /nUS   R                  n[        U5       H>  u  pIXi-   U:  a%  UR                  U/5        US   R                  nU	nM2  Xi-  nU" U5        M@     U V
s/ s H  n
SR                  U
5      PM     sn
$ s  snf s  sn
f )zWBreak text in to equal (cell) length strings, returning the characters in reverse
orderr)   r4   )r   appendreversedjoin)r   r<   r=   _get_character_cell_sizer   
charactersr   linesr?   r6   lines              r   
chop_cellsrF   |   s      7JNJNY,Y78$   J TE2YF#J/	x'LL)%2Y%%FJJ9 0 ',,edBGGDMe,,!  -s   B#B(__main__u   😽u]   这是对亚洲语言支持的测试。面对模棱两可的想法，拒绝猜测的诱惑。   P   r)   |x)r   )re	functoolsr   typingr   r   _cell_widthsr   compilematchr5   strintr   r!   r   r$   r;   rF   __name__printrE   rangenr   r   r   <module>rX      s   	  ! % $QRXX  4# #  " ;J 3 8SE3J#7 c   4	4s 	4s 	4 	4 4   8   C  C  J-S -C -3 -tCy -. z	
!&
)*~  AB  Cd C2q"m  BC  D  GJ  J  	KcAg  r   