U
    ^g                      @   s  d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
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 d d
lmZ d dlmZ d dlmZ d dlmZ G dd dZedddZe dkre	e! ddZ"e Z#e Z$e"%e# e&e e$ d dZ'e! e"_(e Z$e"%e# e&e e$ d dZ)e	ddZ*e*%e# e%de' d e%de) d d dl+m,Z, e	 Z"ej-ddZ.e.j/ddd  e.j/dd! e.0d"d# e.0d$d% e1d&Z2ej-d'dZ3e3/  e3j/dd! e30e2e. e"j%e,j4e3ej5d(d)d*d+d,d- dS ).    N)process_time)box)Color)ConsoleConsoleOptionsGroupRenderableTypeRenderResult)Markdown)Measurement)Pretty)Segment)Style)Syntax)Table)Textc                   @   s0   e Zd ZeeedddZdeedddZdS )ColorBox)consoleoptionsreturnc                 c   s   t ddD ]}t |jD ]}||j }d|d d  }t||d\}}}	t||d d\}
}}t|d |d |	d }t|
d |d |d }tdt||d	V  qt V  q
d S )
Nr      g?gffffff?g      ?gQ?   u   ▄)colorbgcolor)	range	max_widthcolorsysZ
hls_to_rgbr   Zfrom_rgbr   r   line)selfr   r   yxhlZr1Zg1Zb1Zr2Zg2Zb2r   r    r#   1/tmp/pip-unpacked-wheel-04vb07gv/rich/__main__.py__rich_console__   s    
zColorBox.__rich_console__r   c                 C   s   t d|jS )N   )r   r   )r   r   r   r#   r#   r$   __rich_measure__!   s    zColorBox.__rich_measure__N)	__name__
__module____qualname__r   r   r	   r%   r   r'   r#   r#   r#   r$   r      s     r   )r   c            
   
   C   s
  t jddd} d| _| jddddd | d	 t d
ddddd}|dt  | d| | dd d}t jddd}d|_|t|dddt|dddt|dddt|ddd | dtt	d| t
t
t ddd}| d d! d"}| d#| t dddd$d%gtjd&}|jd'ddd( |jd)dd* |jd+d,ddd- |jd.d/ddd- |d0d1d2d3 |d4d5d2d6 |d7d8d9d: |d;d<d=d> | d?| d@}dAdBgdCdD}| dE|t|dFdddGt|ddH dI}	| dJ|dK|	 t|	 | dLdM | S )Nz8Get a renderable that demonstrates a number of features.r&   T)paddingpad_edgezRich featuresZFeaturecenterzbold red)no_wrapjustifystyleZDemonstrationNF)r   expandshow_header	show_edger,   u   ✓ [bold green]4-bit color[/]
✓ [bold blue]8-bit color[/]
✓ [bold magenta]Truecolor (16.7 million)[/]
✓ [bold yellow]Dumb terminals[/]
✓ [bold cyan]Automatic color conversionZColorsZStyleszAll ansi styles: [bold]bold[/], [dim]dim[/], [italic]italic[/italic], [underline]underline[/], [strike]strikethrough[/], [reverse]reverse[/], and even [blink]blink[/].zLorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque in metus sed sapien ultricies pretium a at justo. Maecenas luctus velit et auctor maximus.)r+   Zcollapse_paddingleftgreen)r/   r0   ZyellowrightZbluefullZredr   z[Word wrap text. Justify [green]left[/], [yellow]center[/], [blue]right[/] or [red]full[/].
)renderable1renderable2r   c                 S   s<   t ddd dd}|jddd |jddd || | |S )NFT)r2   r,   r   r1   1r&   )Zratio2)r   
add_columnadd_row)r8   r9   tabler#   r#   r$   
comparisonZ   s
    z"make_test_card.<locals>.comparisonzAsian
language
supportu!  :flag_for_china:  该库支持中文，日文和韩文文本！
:flag_for_japan:  ライブラリは中国語、日本語、韓国語のテキストをサポートしています
:flag_for_south_korea:  이 라이브러리는 중국어, 일본어 및 한국어 텍스트를 지원합니다z[bold magenta]Rich[/] supports a simple [i]bbcode[/i]-like [b]markup[/b] for [yellow]color[/], [underline]style[/], and emoji! :+1: :apple: :ant: :bear: :baguette_bread: :bus: ZMarkupnoneZdim)r3   r2   r1   Z
row_stylesr   z[green]Date)r0   r.   z[blue]Title)r0   z[cyan]Production BudgetZcyan)r0   r/   r.   z[magenta]Box OfficeZmagentazDec 20, 2019z Star Wars: The Rise of Skywalkerz$275,000,000z$375,126,118zMay 25, 2018z[b]Solo[/]: A Star Wars Storyz$393,151,347zDec 15, 2017z!Star Wars Ep. VIII: The Last Jediz$262,000,000z[bold]$1,332,539,889[/bold]zMay 19, 1999z-Star Wars Ep. [b]I[/b]: [i]The phantom Menacez$115,000,000z$1,027,044,677ZTablesa~  def iter_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
    """Iterate and generate a tuple with a flag for last value."""
    iter_values = iter(values)
    try:
        previous_value = next(iter_values)
    except StopIteration:
        return
    for value in iter_values:
        yield False, previous_value
        previous_value = value
    yield True, previous_valueg?$	@)zPaul AtreideszVladimir HarkonnenzThufir Hawat)FTN)ZfooZatomicz%Syntax
highlighting
&
pretty
printingpython3)Zline_numbersindent_guides)rB   z# Markdown

Supports much of the *markdown* __syntax__!

- Headers
- Basic formatting: **bold**, *italic*, `code`
- Block quotes
- Lists, and more...
    r
   z[cyan]z+more!zBProgress bars, columns, styled logging handler, tracebacks, etc...)r   gridtitler<   r=   r   r,   r   r   from_markupr   r   ZSIMPLEr   r   r
   )
r>   Zcolor_tableZloremZlorem_tabler?   Zmarkup_exampleZexample_tablecodeZpretty_dataZmarkdown_exampler#   r#   r$   make_test_card'   s    



 rG   __main__T)fileZforce_terminalg     @@r&   )recordzrendered in zms (cold cache)zms (warm cache))Panel)r+   r5   r6   )r0   r/   )r.   Z
TextualizezH[u blue link=https://github.com/textualize]https://github.com/textualizeZTwitterzL[u blue link=https://twitter.com/willmcgugan]https://twitter.com/willmcguganzWe hope you enjoy using Rich!

Rich is maintained with [red]:heart:[/] by [link=https://www.textualize.io]Textualize.io[/]

- Will McGugan   )r&   rL   z"[b red]Thanks for trying out Rich!Zbright_blue)r   r+   rD   Zborder_styler-   )r/   )6r   iotimer   Zrichr   Z
rich.colorr   Zrich.consoler   r   r   r   r	   Zrich.markdownr
   Zrich.measurer   Zrich.prettyr   Zrich.segmentr   Z
rich.styler   Zrich.syntaxr   Z
rich.tabler   Z	rich.textr   r   rG   r(   StringIOr   Z	test_cardstartprintroundZpre_cache_takenrI   ZtakencZ
rich.panelrK   rC   Zsponsor_messager<   r=   rE   Zintro_messagemessageZfitZROUNDEDr#   r#   r#   r$   <module>   s~    +





	