<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
U
    ʗRe                     @   s8  d dl Z d dlmZ d dlmZmZ ddlmZ e dj	Z
edeedd	d
Zefeeegef edddZeddeedddZeddeedddZeeedddZd#eeeee dddZedkr4eed eddD ]Zee qeddd D ]$Zeeded!  ed"e  qdS )$    N)	lru_cache)CallableList   )CELL_WIDTHSu   ^[ -o ˿Ͱ-҂]*$i   )textreturnc                    s   t  t fdd| 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  qd 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	<genexpr>   s     z"cached_cell_len.<locals>.<genexpr>)get_character_cell_sizesum)r   
total_sizer
   r   r   cached_cell_len   s    r   )r   	_cell_lenr   c                    s2   t | dk r|| S t t fdd| 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  qd S r	   r
   r   r   r
   r   r   )   s     zcell_len.<locals>.<genexpr>)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_sizeord)r   r
   r
   r   r   -   s    
r   )	codepointr   c                 C   s~   t }d}t|d }|| d }|| \}}}| |k r@|d }n"| |krR|d }n|dkr^dS |S ||k rlqz|| d }q dS )r   r   r      )r   r   )r   _tablelower_boundupper_boundindexstartendwidthr
   r
   r   r   :   s    

r   )r   totalr   c           	      C   s   t | r4t| }||k r(| d||   S | d| S |dkr@dS t| }||krT| S ||k rl| d||   S d}t| }|| d }| d|d  }t|}||d krt|d dkr|dd d S ||kr|S ||kr|}qx|}qxdS )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%   posbefore
before_lenr
   r
   r   set_cell_sizeW   s0    r0   )r   max_sizepositionr   c           	         s   t   fdd| D }|}g g}|d j}t|D ]@\}}|| |krb||g |d j}|}q2||7 }|| q2dd |D S )z[Break text in to equal (cell) length strings, returning the characters in reverse
    orderc                    s   g | ]}| |fqS r
   r
   r   _get_character_cell_sizer
   r   
<listcomp>   s    zchop_cells.<locals>.<listcomp>r   c                 S   s   g | ]}d  |qS )r)   )join)r   liner
   r
   r   r5      s     )r   appendreversed)	r   r1   r2   
charactersr   linesr8   r   r+   r
   r3   r   
chop_cells|   s    



r<   __main__u   😽u]   这是对亚洲语言支持的测试。面对模棱两可的想法，拒绝猜测的诱惑。   P   r   |x)r   )re	functoolsr   typingr   r   _cell_widthsr   compilematchr*   strintr   r   r   r   r0   r<   __name__printr7   rangenr
   r
   r
   r   <module>   s(    %

