HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/rich/__pycache__/cells.cpython-37.pyc
B

��f��@s6ddlmZddlZddlmZddlmZddlmZe�	d�j
Zed�d	d
d�dd
��Zefd	dd
d�dd�Z
edd�d	d
d�dd��Zedd�d
d
d�dd��Zd	d
d	d�dd�Zd	d
dd�dd�Zed k�r2eed!��xed"d#�D]Zee�q�Wx4ed$dd%�D]$Zeed"e�d&�ed'e��q
WdS)(�)�annotationsN)�	lru_cache)�Callable�)�CELL_WIDTHSu^[ -o ˿Ͱ-҂]*$i�str�int)�text�returncst�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.
    c3s|]}�|�VqdS)N�)�.0�	character)�	_get_sizer�;/opt/alt/python37/lib/python3.7/site-packages/rich/cells.py�	<genexpr>sz"cached_cell_len.<locals>.<genexpr>)�get_character_cell_size�sum)r	�
total_sizer)rr�cached_cell_len
s
rzCallable[[str], int])r	�	_cell_lenr
cs2t|�dkr||�St�t�fdd�|D��}|S)z�Get 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.
    ic3s|]}�|�VqdS)Nr)rr
)rrrr+szcell_len.<locals>.<genexpr>)�lenrr)r	rrr)rr�cell_lens
	r)�maxsize)r
r
cCstt|��S)z�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_size�ord)r
rrrr/s
r)�	codepointr
cCs�t}d}t|�d}||d}x\||\}}}||krB|d}n"||krT|d}n|dkr`dS|S||krnP||d}q"WdS)z�Get 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)rZ_tableZlower_boundZupper_bound�index�start�end�widthrrrr<s

r)r	�totalr
c	Cs�t|�r4t|�}||kr(|d||S|d|�S|dkr@dSt|�}||krT|S||krl|d||Sd}t|�}xr||d}|d|d�}t|�}||dkr�t|d�dkr�|dd�dS||kr�|S||kr�|}qz|}qzWdS)z?Set the length of a string to fit within given number of cells.� Nr�rrr)�_is_single_cell_widthsrr)	r	r"�sizeZ	cell_sizerr �pos�beforeZ
before_lenrrr�
set_cell_sizeYs2r)z	list[str])r	r!r
c
Cs|t}gg}|j}|dj}d}xN|D]F}||�}|||k}	|	rZ||g�|dj}|}q$||�||7}q$Wdd�|D�S)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.
    rrcSsg|]}d�|��qS)r$)�join)r�linerrr�
<listcomp>�szchop_cells.<locals>.<listcomp>)r�append)
r	r!Z_get_character_cell_size�linesZappend_new_lineZappend_to_last_lineZtotal_widthr
Z
cell_widthZchar_doesnt_fitrrr�
chop_cells|s



r/�__main__u😽u]这是对亚洲语言支持的测试。面对模棱两可的想法,拒绝猜测的诱惑。��Pr�|�x)�
__future__r�re�	functoolsr�typingrZ_cell_widthsr�compile�matchr%rrrrr)r/�__name__�printr+�range�nrrrr�<module>s$
#%