"Te)dddlmZmZddlmZddlmZmZddlm Z ddl m Z ddl m Z mZddlmZmZdd lmZdd lmZmZdd lmZmZer dd lmZmZmZmZGd de Ze dk(rJddlmZeZ!ddlm"Z"mZddlmZeddde"dZ#e!jIe!jIe#yy)) TYPE_CHECKINGOptional) AlignMethod)ROUNDEDBox)cell_len) JupyterMixin) Measurementmeasure_renderables)PaddingPaddingDimensions)Segment)Style StyleType)TextTextType)ConsoleConsoleOptionsRenderableType RenderResultc xeZdZdZefddddddddddddd d d d ed eed edeededee de de de dee dee de de ddfdZ eefdddddddddddd d d d ed eed edeededee de de dee dee de de ddfdZedeefdZedeefdZ d dZ d!dZy)"PanelaA console renderable that draws a border around its contents. Example: >>> console.print(Panel("Hello, World!")) Args: renderable (RenderableType): A console renderable object. box (Box, optional): A Box instance that defines the look of the border (see :ref:`appendix_box`. Defaults to box.ROUNDED. safe_box (bool, optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True. expand (bool, optional): If True the panel will stretch to fill the console width, otherwise it will be sized to fit the contents. Defaults to True. style (str, optional): The style of the panel (border and contents). Defaults to "none". border_style (str, optional): The style of the border. Defaults to "none". width (Optional[int], optional): Optional width of panel. Defaults to None to auto-detect. height (Optional[int], optional): Optional height of panel. Defaults to None to auto-detect. padding (Optional[PaddingDimensions]): Optional padding around renderable. Defaults to 0. highlight (bool, optional): Enable automatic highlighting of panel title (if str). Defaults to False. NcenterTnone)rrF) title title_alignsubtitlesubtitle_alignsafe_boxexpandstyle border_stylewidthheightpadding highlight renderablerboxrrrrr r!r"r#r$r%r&r'returnc ||_||_||_||_||_||_||_||_| |_| |_ | |_ | |_ | |_ ||_ y)N)r(r)rrrrr r!r"r#r$r%r&r')selfr(r)rrrrr r!r"r#r$r%r&r's ,/usr/lib/python3/dist-packages/rich/panel.py__init__zPanel.__init__&si$% (3  ,    (   ") rrrrr r"r#r$r%r&r'c .|||||||||| | | | | dS)z2An alternative constructor that sets expand=False.F) rrrrr r"r#r$r%r&r'r!)clsr(r)rrrrr r"r#r$r%r&r's r-fitz Panel.fitGs;&  #)%  r/cf|jrt|jtrtj|jn|jj }d|_|jjdd|_d|_ |j|jd|SyN  Tr) r isinstancestrr from_markupcopyendplainreplaceno_wrap expand_tabspad)r, title_texts r-_titlez Panel._titleks ::djj#.  ,ZZ__&   JN)//77cBJ !%J   " " $ NN1  r/cf|jrt|jtrtj|jn|jj }d|_|jjdd|_d|_ |j|jd|Syr5) rr9r:rr;r<r=r>r?r@rArB)r, subtitle_texts r- _subtitlezPanel._subtitle{s ==dmmS1  /]]'')  !#M "/"5"5"="=dC"HM $(M !  % % '   a  r/c #RKtj|j}t|rt|j|n |j}|j |j }||j |jz}|j |jnt|j|j}|j |jn |j}|jj||} dtdtdt dt dt"dtf d} |j$} | | j'||j(r|d z n.|j+||j-|d z  j.} |j0xs|j0xsd} | r| d z} | 0t|jd z t3| | j4d z} | d z}|j7| | |j8 }|j;||| }t=| j>|}t=| j@|}t=jB}| |d kr"t=| jE|d z g|n| | |d z |jF| jH|} t=| jJ| jHz||jM| |j-|d z Ed{t=| jH| jNz|||D]}||Ed{|||jP}||j'|||d kr"t=| jS|d z g|n| ||d z |jT| jV|}t=| jX| jVz||jM||j-|d z Ed{t=| jV| jZz||y71773w)N)safetextr$align characterr"r*c`|j}|j||t|jz }|rr|dk(rt j |||z|fddS|dk(r,|dz}t j ||z|f||||z z|fddSt j ||z|f|ddS|S)acGets new aligned text. Args: text (Text): Title or subtitle text. width (int): Desired width. align (str): Alignment. character (str): Character for alignment. style (Style): Border style Returns: Text: New text instance leftTr6)r@r=r)r<truncater r>rassemble)rJr$rKrLr" excess_spacerNs r- align_textz*Panel.__rich_console__..align_texts99;D MM%  8DJJ#77LF?=="\159 $  h&'1,D=="T)51"lT&9:EB $  =="\159 $  Kr/rO)options)r$r%r')r").r unpackr&anyr( get_styler"r#r$ max_widthminr r) substituterintr:rrDstylize_beforer!measure update_widthmaximumr%maxr updater' render_linesrmid_left mid_rightlineget_toprtoptop_leftrender top_rightrG get_bottomrbottom bottom_left bottom_right)r,consolerT_paddingr(r"r#r$r r)rSrC child_width child_height child_optionslines line_startline_endnew_linerfrFs r-__rich_console__zPanel.__rich_console__s>>$,,/25h-GDOOX .T__ !!$**-w001B1BCC zz!   W&& 3  .2]]-B)) hh!!'!9* * "* +.* ;>* GL*  * X[[  !  % %l 3{{ AIG$8$8$C!g {{  !#++uqyk2LA A#    J#,,0,? ?~~j-2L2LUUVY2WX X X#''CMM1<@ @ D OONN     $  ( ( 6  EQJ#..%!)5|D D& ##  M#//CJJ6 E E~~}99%!)D  #**s'7'77F F= Y & s7K-P'/P 0;P'+P#,CP'1P%2/P'#P'%P'ch|j}tj|j\}}}}||z}|r|j|gn |jg}|j =t ||j|j|z dz |j|zdz} n |j } t| | S)NrO) rDr rVr&r(r$r r_rYr`r ) r,rprTrD_rightrNr& renderablesr$s r-__rich_measure__zPanel.__rich_measure__s#NN4<<85!T,39t/?P :: #(():):W)Dq)HI'    JJE5%((r/)rprrTrr*r)rprrTrr*r )__name__ __module__ __qualname____doc__rrrrrboolrr\rr. classmethodr3propertyrrDrGryr~r1r/r-rrsF.# %)#+'+&.#'!"(# $%+!#$## ! # ! #8$#$#4.### #}# ### !#" ##B! %)#+'+&.#'!"(# $%+! $! ! ! ! ! ! 8$! $! 4.! !  ! }!  ! #! ! !! ! F    8D>  C C+;C CJ) )+;) )r/r__main__)r)DOUBLEr)r z Hello, World!z rich.Panelz white on blue)rr"r)r&N)%typingrrrKrr)rrcellsr jupyterr r^r r r&r rsegmentrr"rrrJrrrprrrrrrcrpprintr1r/r-rs*!5/# NNS)LS)l z  A$     AGGIGGAJ#r/