관리-도구
편집 파일: cells.cpython-38.pyc
U &?�f� � @ s. d dl mZ d dlZd dlmZ d dlmZ ddlmZ e� d�j Zed�d d d�dd ��Zefd 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�r*eed!�� ed"d#�D ]Zee� q�ed$dd%�D ]$Zeed"e�d& � ed'e � �qdS )(� )�annotationsN)� lru_cache)�Callable� )�CELL_WIDTHSu ^[ -o ˿Ͱ-҂]*$i �str�int)�text�returnc 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 �D/opt/hc_python/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 zCallable[[str], int])r � _cell_lenr c s2 t | �dk r|| �S t� 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. i c 3 s | ]}� |�V qd S r r r r r r r + s zcell_len.<locals>.<genexpr>)�lenr r )r r r r r r �cell_len s r )�maxsize)r r c C s t t| ��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 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 )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. r r � ���)r r )r �_table�lower_bound�upper_bound�index�start�end�widthr r r r <