�
]�gL
� � � d dl mZ d dlZd dlmZ ddlmZ ddlmZm Z ej
d� � Zdd�Zddd�Z
edk r�ddlmZ ed�� � Ze� d� � e e dd� � � � ed�� � Ze� � � e� d� � e� � � e� d� � dS dS ) � )�annotationsN)�Iterable� )� loop_last)�cell_len�
chop_cellsz \s*\S+\s*�text�str�return�Iterable[tuple[int, int, str]]c # �� K � d}t � | |� � }|�R|� � � \ }}|� d� � }|||fV � t � | |� � }|�PdS dS )z�Yields each word from the text as a tuple
containing (start_index, end_index, word). A "word" in this context may
include the actual word and any whitespace to the right.
r N)�re_word�match�span�group)r �position�
word_match�start�end�words �Z/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/rich/_wrap.py�wordsr s� � � � �
�H����t�X�.�.�J�
�
��_�_�&�&�
��s�����"�"���S�$������]�]�4��-�-�
� �
�
�
�
�
� T�width�int�fold�bool� list[int]c �� � g }|j }d}t }t | � � D ]�\ }}} || � � � � � }
||z
}||
k }|r| || � � z
}�?|
|k ro|rTt | |�� � }
t |
� � D ]2\ }}|r ||� � |r ||� � }� |t
|� � z
}�3��|r ||� � || � � }��|r|r ||� � || � � }��|S )a� Given a string of text, and a width (measured in cells), return a list
of cell offsets which the string should be split at in order for it to fit
within the given width.
Args:
text: The text to examine.
width: The available cell width.
fold: If True, words longer than `width` will be folded onto a new line.
Returns:
A list of indices to break the line at.
r �r )�appendr r �rstripr r �len)r r r �break_positionsr! �cell_offset� _cell_lenr �_endr �word_length�remaining_space�word_fits_remaining_space�folded_word�last�lines r �divide_liner. s^ � � "$�O�
�
#�F��K��I�"�4�[�[� .� .���t�T��i����
�
�.�.���+�-��$3�{�$B�!�$� .��9�9�T�?�?�*�K�K� �U�"�"� � 2�",�T��"?�"?�"?�K�&/��&<�&<� /� /�
��d� � *�"�F�5�M�M�M�� /�*3�)�D�/�/�K�K�!�S��Y�Y�.�E�E�
/� � &���u�
�
�
�"+�)�D�/�/�K�K��
.��
.� ��u�
�
�
�'�i��o�o����r �__main__)�Console�
r z@12345 abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ 12345�abcdefghijklmnopqrstuvwxyz� uR TextualはPythonの高速アプリケーション開発フレームワークですu4 アプリケーションは1670万色を使用でき)r r
r r )T)r r
r r r r r r )�
__future__r �re�typingr �_loopr �cellsr r �compiler r r. �__name__�consoler0 �print�rule� r r �<module>r? s\ �� "� "� "� "� "� "� � � � � � � � � � � � � � � � � '� '� '� '� '� '� '� '�
�"�*�\�
"�
"��.� .� .� .�4� 4� 4� 4� 4�n �z��� � � � � � ��g�B����G��M�M�T�U�U�U� �E�*�*�1�2�
6�
6�7�7�7��g�B����G��L�L�N�N�N��M�M�f�g�g�g��L�L�N�N�N��M�M�H�I�I�I�I�I� �r