"TeddlmZddlZddlmZddlmZddlmZejdjZ eddd Z e fdd Z ed dd Zed dd ZddZ ddZedk(rQeededdD] Zee edddD]Zeededzedez!yy)) annotationsN) lru_cache)Callable) CELL_WIDTHSu^[ -o ˿Ͱ-҂]*$ic<ttfd|D}|S)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. c3.K|] }|ywN.0 character _get_sizes ,/usr/lib/python3/dist-packages/rich/cells.py z"cached_cell_len..@iYy)@)get_character_cell_sizesum)text total_sizers @rcached_cell_lenr s (I@4@@J cht|dkr||Sttfd|D}|S)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. ic3.K|] }|ywr r r s rrzcell_len..+rr)lenrr)r _cell_lenrrs @rcell_lenrs5 4y3'I@4@@J r)maxsizec*tt|S)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_sizeord)rs rrr/s $C N 33rct}d}t|dz }||zdz} ||\}}}||kr|dz }n||kDr|dz}n |dk(rdS|S||kr y||zdz}8)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. rr)rr) codepoint_table lower_bound upper_boundindexstartendwidths rr!r!<sFKf+/K ; &1 ,E "5MsE u !)K _!)K 1 . .  $  {*q0 rc`t|r t|}||kr |d||z zzS|d|S|dkryt|}||k(r|S||kr |d||z zzSd}t|} ||zdz}|d|dz}t|}||dzk(rt|ddk(r|dddzS||k(r|S||kDr|}n|}N)z?Set the length of a string to fit within given number of cells. Nrr$rr%)_is_single_cell_widthsrr) rtotalsize cell_sizer+r,posbefore before_lens r set_cell_sizer8Ysd#4y %<#.. .FU| zIE 5cUY./// E d)C s{q iaf%  "xr ';q'@#2;$ $  M  CE rct}gg}|j}|dj}d}|D]<}||}||z|kD} | r||g|dj}|}0||||z }>|D cgc]} dj| c} Scc} w)ahSplit text into lines such that each line fits within the available (cell) width. Args: text: The text to fold such that it fits in the given width. width: The width available (number of cells). Returns: A list of strings such that each string in the list has cell width less than or equal to the available width. r%rr0)rappendjoin) rr-_get_character_cell_sizelinesappend_new_lineappend_to_last_line total_widthr cell_widthchar_doesnt_fitlines r chop_cellsrD|s 7 TEllO)**K & -i8 % 2U:  YK ("')"2"2 $K  * : %K &', ,dBGGDM ,, ,s,B__main__u😽u]这是对亚洲语言支持的测试。面对模棱两可的想法,拒绝猜测的诱惑。Pr%|x)rstrreturnint)rrJrzCallable[[str], int]rKrL)rrJrKrL)r&rLrKrL)rrJr2rLrKrJ)rrJr-rLrKz list[str]) __future__rre functoolsrtypingr _cell_widthsrcompilematchr1rrrr!r8rD__name__printrCrangenr rrrXs7" %$$QRXX 4";J   4 4 4 4  8 F"- "- "-"-J z !& )*~ABC d  2q"  mBCDGJJ K cAg r