U
ʗRe @ s8 d dl Z d dlmZ d dlmZmZ ddlmZ e dj Z
edeedd d
Z
e
feeegef eddd
ZeddeedddZeddeedddZeeedddZd#eeeee dddZedkr4eed eddD ]Zee qeddd D ]$Zeeded! ed"e qdS )$ N) lru_cache)CallableList )CELL_WIDTHSu ^[ -o ˿Ͱ-҂]*$i )textreturnc s t t fdd| 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.
c 3 s | ]} |V qd S N .0 character _get_sizer
/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/rich/cells.py s z"cached_cell_len..)get_character_cell_sizesum)r
total_sizer
r r cached_cell_len s
r )r _cell_lenr c s2 t | dk r|| S t t fdd| 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.
i c 3 s | ]} |V qd S r r
r r r
r r ) s zcell_len..)lenr r )r r r r
r r cell_len s
r )maxsize)r
r c C s t t| S )Get 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)r
r
r
r r - s
r ) codepointr c C s~ t }d}t|d }|| d }|| \}}}| |k r@|d }n"| |krR|d }n|dkr^dS |S ||k rlqz|| d }q dS )r r r )r r )r _tablelower_boundupper_boundindexstartendwidthr
r
r r : s
r )r totalr c C s t | r4t| }||k r(| d|| S | d| S |dkr@dS t| }||krT| S ||k rl| d|| S d}t| }|| d }| d|d }t|}||d krt|d dkr|dd d S ||kr|S ||kr|}qx|}qxdS )z?Set the length of a string to fit within given number of cells. Nr r r r )_is_single_cell_widthsr r ) r r' size cell_sizer$ r% posbefore
before_lenr
r
r
set_cell_sizeW s0 r0 )r max_sizepositionr c s t fdd| D }|}g g}|d j}t|D ]@\}}|| |krb||g |d j}|}q2||7 }|| q2dd |D S )z[Break text in to equal (cell) length strings, returning the characters in reverse
orderc s g | ]}| |fqS r
r
r _get_character_cell_sizer
r