o
    Rh                     @   s   d dl mZ ddlmZ ddlmZmZ ddlmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ G d
d deZedkrxd dlZd dlmZ zejd ZW n ey^   dZY nw e Zeeed e Zejeddd dS dS )    )Union   )AlignMethod)cell_lenset_cell_size)ConsoleConsoleOptionsRenderResult)JupyterMixinMeasurement)Style)Textc                   @   s   e Zd ZdZ	dddddddeeef d	ed
eeef dededdfddZ	defddZ
dededefddZdededefddZdededefddZdS )Ruleu  A console renderable to draw a horizontal rule (line).

    Args:
        title (Union[str, Text], optional): Text to render in the rule. Defaults to "".
        characters (str, optional): Character(s) used to draw the line. Defaults to "─".
        style (StyleType, optional): Style of Rule. Defaults to "rule.line".
        end (str, optional): Character at end of Rule. defaults to "\\n"
        align (str, optional): How to align the title, one of "left", "center", or "right". Defaults to "center".
     u   ─z	rule.line
center)
charactersstyleendaligntitler   r   r   r   returnNc                C   sN   t |dk r
td|dvrtd|d|| _|| _|| _|| _|| _d S )Nr   z:'characters' argument must have a cell width of at least 1)leftr   rightzAinvalid value for align, expected "left", "center", "right" (not ))r   
ValueErrorr   r   r   r   r   )selfr   r   r   r   r    r   K/home/air/sanwanet/backup_V2/venv/lib/python3.10/site-packages/rich/rule.py__init__   s   	

zRule.__init__c                 C   s   d| j d| jdS )NzRule(z, r   )r   r   )r   r   r   r   __repr__.   s   zRule.__repr__consoleoptionsc                 c   s   |j }|jr| j sdn| j}t|}| js!| ||V  d S t| jtr+| j}n|j	| jdd}|j
dd|_
|  | jdkrFdnd}td	|| }|sZ| ||V  d S t| jd
}	| jdkr|j|dd |t|j
 d }
t||
| d  }||
d  |t|j
 t|j
 }t||
| d  }|| |	|j
d | j |	| |	d|j
 | j nH| jdkr|j|dd |	| |	d |	|||	j  | j n%| jdkr|j|dd |	|||j d  | j |	d |	| t|	j
||	_
|	V  d S )N-z	rule.text)r   r    r         r   )r   ellipsis)overflowr   r   r   )	max_width
ascii_onlyr   isasciir   r   
_rule_line
isinstancer   
render_strplainreplaceexpand_tabsr   maxr   truncateappendr   r   )r   r"   r#   widthr   	chars_len
title_textrequired_spacetruncate_width	rule_text
side_widthr   right_lengthr   r   r   r   __rich_console__1   s\   








zRule.__rich_console__r7   r6   c                 C   s6   t | j|| d  | j}|| t|j||_|S Nr   )r   r   r   r4   r   r0   )r   r7   r6   r;   r   r   r   r-   i   s   
zRule._rule_linec                 C   s
   t ddS r?   r   )r   r"   r#   r   r   r   __rich_measure__o   s   
zRule.__rich_measure__)r   )__name__
__module____qualname____doc__r   strr   r   r   r    r!   r   r   r	   r>   intr-   r   r@   r   r   r   r   r      sJ    



8r   __main__N)r   zHello, World)r   foor&   )r6   )typingr   r   r   cellsr   r   r"   r   r   r	   jupyterr
   measurer   r   r   textr   r   rA   sysrich.consoleargv
IndexErrorprintr   r   r   r   <module>   s,    i