"TeĸUddlZddlmZmZddlmZddlmZddlm Z m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZdd l m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+m,Z,e r ddl-m.Z.m/Z/m0Z0m1Z1dZ2de3d<dZ4de3d<ejjdZ6ee7dfZ8 e e7gee,fZ9GddeZ:Gdde%Z;ee>jd"gd#e>jd$gd%e.Z-e-jd&e-je>d'(e-je-jd)e-je>d*d+,e-je-jd-e-je>d.d/,e-je-jd0e-je>d1d2,e-jyy)3N)partialreduce)gcd) itemgetter) TYPE_CHECKINGAnyCallableDictIterableList NamedTupleOptionalTupleUnion) loop_last) pick_bool) divide_line) AlignMethod)cell_len set_cell_size)Lines)strip_control_codes) EmojiVariant) JupyterMixin) Measurement)Segment)Style StyleType)ConsoleConsoleOptions JustifyMethodOverflowMethoddefaultr"DEFAULT_JUSTIFYfoldr#DEFAULT_OVERFLOWz\s+$TextceZdZUdZeed< eed< eeefed< defdZ de fdZ dede de dffd Zdeddfd Zdeddfd Zd eddfd Zy)Spanz A marked up region in some text.startendstylereturncVd|jd|jd|jdS)NzSpan(z, ))r+r,r-selfs +/usr/lib/python3/dist-packages/rich/text.py__repr__z Span.__repr__8s)tzzl"TXXJba@@c4|j|jkDSN)r,r+r1s r3__bool__z Span.__bool__;sxx$**$$r5offsetc||jkr|dfS||jk\r|dfS|\}}}t|t|||}t|j||}||fS)z)Split a span in to 2 from a given offset.N)r+r,r*min)r2r9r+r,r-span1span2s r3splitz Span.split>sm DJJ :  TXX :  sEUCV,e4UYYU+e|r5c4|\}}}t||z||z|S)zMove start and end by a given offset. Args: offset (int): Number of characters to add to start and end. Returns: TextSpan: A new TextSpan with adjusted position. r*r2r9r+r,r-s r3movez Span.moveKs'!sEEFNC&L%88r5cJ|\}}}||k\r|St|t|||S)zCrop the span at the given offset. Args: offset (int): A value between start and end. Returns: Span: A new (possibly smaller) span. )r*r;rAs r3 right_cropzSpan.right_cropWs2!sE S=KE3vs+U33r5cellsc6|r|\}}}t|||z|S|S)zExtend the span by the given number of cells. Args: cells (int): Additional space to add to end of span. Returns: Span: A span. r@)r2rEr+r,r-s r3extendz Span.extendes+  $ E3sU{E2 2Kr5N)__name__ __module__ __qualname____doc__int__annotations__rstrrr4boolr8rrr>rBrDrGr5r3r*r*.s* J H e )A#A%$% C E&(62B*B$C  93 96 9 4 4 4 C F r5r*ceZdZdZgdZ dddddddddedeeefd ed d ed d ee dedee dee e ddfdZ de fdZde fdZdefdZdefdZdeddfdZdede fdZdede fdZdee efddfdZede fdZedefdZeddddddd dedeeefd!e d"eed ed d ed deddfd#Zedddddd$d%dedeeefd ed d ed d ee dedee ddfd&Ze dddd'dede d ed d ed ddf d(Z!edddddd$dd)d*eede"ee ffdeeefd ed d ed d ee dede d+ee#eefddfd,Z$edefd-Z%e%jLd.eddfd/Z%ede e fd0Z'e'jLde e ddfd1Z'dd2eddfd3Z(dd4Z) ddeeefd5e dee ddfd6Z* ddeeefd5e dee ddfd7Z+ dd+e#eefd5e dee ddfd8Z,dd+ee#eefd9eddfd:Z-d;eddfd<Z.d=d>d?e defd@Z/dAe ddfdBZ0 dddCdDedeee1e fdEede fdFZ2ddGdHe3edeeefdIe de fdJZ4ddKZ5dLe ddfdMZ6dNe ddfdOZ7d=d>dPdQde3e8fdRZ9d=d>dPdQde:fdSZ;dd=d>dede3dTfdUZddYdZd[e d ed d\e ddfd]Z?dd^Z@dd_e d`eddfdaZAdd_e d`eddfdbZBdd_e d`eddfdcZCdddeDdee d`eddfdfZE ddedefdeeedgfddfdhZFddiZGdje3e"eee fddfdkZHddlZI ddYdYdmdnedoe dpe deJfdqZKdre3e deJfdsZLddte ddfduZMddd$ddvd=d>dee d ed d ed de d ee deJfdwZNdee deJfdxZOde fdyZP ddzd{d|d}ee d`ede ddfd~ZQy)r(aText with color / style. Args: text (str, optional): Default unstyled text. Defaults to "". style (Union[str, Style], optional): Base style for text. Defaults to "". justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. no_wrap (bool, optional): Disable text wrapping, or None for default. Defaults to None. end (str, optional): Character to end text with. Defaults to "\\n". tab_size (int): Number of spaces per tab, or ``None`` to use ``console.tab_size``. Defaults to None. spans (List[Span], optional). A list of predefined style spans. Defaults to None. ) _textr-justifyoverflowno_wrapr,tab_size_spans_lengthN )rSrTrUr,rVspanstextr-rSr"rTr#rUr,rVr[r.ct|} | g|_||_||_||_||_||_||_|xsg|_t| |_ yr7) rrRr-rSrTrUr,rVrWlenrX) r2r\r-rSrTrUr,rVr[sanitized_texts r3__init__z Text.__init__sY-T2$%  29 4<    "'+2 / r5c|jSr7)rXr1s r3__len__z Text.__len__s ||r5c,t|jSr7)rOrXr1s r3r8z Text.__bool__sDLL!!r5c|jSr7plainr1s r3__str__z Text.__str__s zzr5c<d|jd|jdS)Nz)rfrWr1s r3r4z Text.__repr__s ~Qt{{oQ77r5otherct|ttfr#|j}|j ||St Sr7) isinstancerNr(copyappendNotImplemented)r2rkresults r3__add__z Text.__add__s2 ec4[ )YY[F MM% Mr5ct|tstS|j|jk(xr|j|jk(Sr7)rmr(rprfrWr2rks r3__eq__z Text.__eq__s7%&! !zzU[[(HT[[ELL-HHr5ct|tr||jvSt|tr|j|jvSy)NF)rmrNrfr(rts r3 __contains__zText.__contains__s; eS !DJJ& & t $;;$**, ,r5slicecdtddffd }t|tr||S|jtj\}}}|dk(rj ||g}|dSt d)Nr9r.r(c t}tj|jDcgc]\}}}||cxkDr|k\r nn |dd| c}}}d}|Scc}}}w)NrrrY)r[r,)r*r(rfrW)r9_Spanr+r,r-r\r2s r3 get_text_atz%Text.__getitem__..get_text_atslE 6".2[[)sEV,u,!Q& DKs#Arz%slices with step!=1 are not supported)rLrmindicesr^rfdivide TypeError)r2rxr|r+stopstepliness` r3 __getitem__zText.__getitem__sz    eS !u% % % c$**o > E4qy UDM2Qx GHHr5c,t|jS)z5Get the number of cells required to render this text.)rrfr1s r3rz Text.cell_lens ##r5cddlm}g}|j}dd|jfgd|jDd|jDt |d|jf}|j tddd}|j}|D]5\}}} ||kDr||||||}| s"||rd | d nd | d 7d j|} | S) z~Get console markup to render this Text. Returns: str: A string potentially creating markup tags. r)escaperFc3NK|]}|jd|jfywFN)r+r-.0spans r3 zText.markup..s F$tzz5$**- F#%c3NK|]}|jd|jfywTN)r,r-rs r3rzText.markup..s Cttxxtzz* CrTkeyz[/][rY) markuprrfr-rWr^sortrrojoin) r2routputrf markup_spanspositionror9closingr-rs r3rz Text.markups #  tzz " F$++ F Dt{{ C Ztzz *  jA./&2 C "FGU veHV456!E7!}qq\B  C  r5T)r-emoji emoji_variantrSrTr,rrcTddlm}|||||} || _|| _|| _| S)aCreate Text instance from markup. Args: text (str): A string containing console markup. style (Union[str, Style], optional): Base style for text. Defaults to "". emoji (bool, optional): Also render emoji code. Defaults to True. emoji_variant (str, optional): Optional emoji variant, either "text" or "emoji". Defaults to None. justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. end (str, optional): Character to end text with. Defaults to "\\n". Returns: Text: A Text instance with markup rendered. r)render)rr)rrrSrTr,) clsr\r-rrrSrTr,r rendered_texts r3 from_markupzText.from_markups54 #tU%}U ' !)  r5r-rSrTrUr,rVc ddlm}td||||||} |} | jd| j |D} | S)aCreate a Text object from a string containing ANSI escape codes. Args: text (str): A string containing escape codes. style (Union[str, Style], optional): Base style for text. Defaults to "". justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. no_wrap (bool, optional): Disable text wrapping, or None for default. Defaults to None. end (str, optional): Character to end text with. Defaults to "\\n". tab_size (int): Number of spaces per tab, or ``None`` to use ``console.tab_size``. Defaults to None. r) AnsiDecoderrZ)rSrTrUr,rVr-c3 K|]}|ywr7rPrlines r3rz!Text.from_ansi..GsCdTCs )ansirr(rdecode) rr\r-rSrTrUr,rVrjoinerdecoderrqs r3 from_ansizText.from_ansi$sQ. &  -CgnnT.BCC r5rSrTc>||||}|j||S)aaConstruct a Text instance with a pre-applied styled. A style applied in this way won't be used to pad the text when it is justified. Args: text (str): A string containing console markup. style (Union[str, Style]): Style to apply to the text. Defaults to "". justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. Returns: Text: A text instance with a style applied to the entire string. r)stylize)rr\r-rSrT styled_texts r3styledz Text.styledJs&*$(C E"r5)r-rSrTrUr,rVmetapartsrc|||||||} | j} t} |D]"} t| | tfr | | | | $|r| j || S)aConstruct a text instance by combining a sequence of strings with optional styles. The positional arguments should be either strings, or a tuple of string + style. Args: style (Union[str, Style], optional): Base style for text. Defaults to "". justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. no_wrap (bool, optional): Disable text wrapping, or None for default. Defaults to None. end (str, optional): Character to end text with. Defaults to "\\n". tab_size (int): Number of spaces per tab, or ``None`` to use ``console.tab_size``. Defaults to None. meta (Dict[str, Any], optional). Meta data to apply to text, or None for no meta data. Default to None Returns: Text: A new text instance. r)ror(rmrN apply_meta) rr-rSrTrUr,rVrrr\ro_Textparts r3assemblez Text.assemblecsq6   D$ -t     OOD ! r5ct|jdk7r)dj|jg|jdd|jdS)z Get the text as a single string.rrYNr)r^rRrr1s r3rfz Text.plains? tzz?a WWTZZ01DJJqMzz!}r5new_textc||jk7rXt|}|g|jdd|j}t ||_||jkDr|j yyy)zSet the text to a new value.N)rfrrRrXr^ _trim_spans)r2rr_ old_lengths r3rfz Text.plainsa tzz !0:N+,DJJqMJ~.DLDLL(  ") "r5c|jS)z.Get a reference to the internal list of spans.rWr1s r3r[z Text.spanss{{r5c|dd|_y)z Set spans.Nr)r2r[s r3r[z Text.spanssAh r5rfc t||j|j|j|j|j |j }|S)zNReturn a new Text instance with copied metadata (but not the string or spans).r)r(r-rSrTrUr,rV)r2rf copy_selfs r3 blank_copyzText.blank_copysA **LL]]LL]] r5c t|j|j|j|j|j |j |j}|j|jdd|S)zReturn a copy of this instance.rN) r(rfr-rSrTrUr,rVrW)r2rs r3rnz Text.copysY JJ**LL]]LL]] #kk r5r+c |r_t|}|dkr||z}||}|dkr||z}||k\s||kry|jjt|t |||yy)azApply a style to the text, or a portion of the text. Args: style (Union[str, Style]): Style instance or style definition to apply. start (int): Start offset (negative indexing is supported). Defaults to 0. end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None. rN)r^rWror*r;r2r-r+r,lengths r3rz Text.stylizesq YFqy{Qwsl#, KK  tE3vs+;UC D r5c |r`t|}|dkr||z}||}|dkr||z}||k\s||kry|jjdt|t |||yy)aApply a style to the text, or a portion of the text. Styles will be applied before other styles already present. Args: style (Union[str, Style]): Style instance or style definition to apply. start (int): Start offset (negative indexing is supported). Defaults to 0. end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None. rN)r^rWinsertr*r;rs r3stylize_beforezText.stylize_beforess YFqy{Qwsl#, KK  q$uc&#.>"F G r5cVtj|}|j|||y)agApply metadata to the text, or a portion of the text. Args: meta (Dict[str, Any]): A dict of meta information. start (int): Start offset (negative indexing is supported). Defaults to 0. end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None. )r+r,N)r from_metar)r2rr+r,r-s r3rzText.apply_metas$% U%S 1r5handlersc |in|}|j|jDcic] \}}d|| c}}|jtj||Scc}}w)aApply event handlers (used by Textual project). Example: >>> from rich.text import Text >>> text = Text("hello world") >>> text.on(click="view.toggle('world')") Args: meta (Dict[str, Any]): Mapping of meta information. **handlers: Keyword args are prefixed with "@" to defined handlers. Returns: Text: Self is returned to method may be chained. @)updateitemsrrr)r2rrrvalues r3onzText.on s\\rt 8HI*#uqY%IJ U__T*+ JsA# suffixcp|jj|r|jt|yy)zaRemove a suffix if it exists. Args: suffix (str): Suffix to remove. N)rfendswithrDr^)r2rs r3 remove_suffixzText.remove_suffixs+ ::  v & OOCK ( 'r5consoler r9c|dkrt||z}|j}||jj}|jD]"\}}}||cxkDr|k\sn|||dz }$|S)a Get the style of a character at give offset. Args: console (~Console): Console where text will be rendered. offset (int): Offset in to text (negative indexing supported) Returns: Style: A Style instance. rrYr$)r^ get_styler-rnrW)r2rr9rr-r+r, span_styles r3get_style_at_offsetzText.get_style_at_offset'sz A:Y'F%% $**%**,&*kk ; "E3 V$u$:r:: ; r5spacesc\|dkry|j}d|z}|ryt|}|Dcgc]$}|j|k\r|j|n|&c}|jdd|j j ||xj|z c_y|xj|z c_ycc}w)zExtend the Text given number of spaces where the spaces have the same style as the last character. Args: spaces (int): Number of spaces to add to the Text. rNri) r[r^r,rGrWrRrorXrf)r2rr[ new_spaces end_offsetrs r3 extend_stylezText.extend_style;s Q;  6\ TJ"(,xx:'= F#4GDKKN JJ  j ) LLF "L JJ* $Js)B)) style_prefix re_highlightrc d}|jj}t}|j}t j ||D]}|j } |r9| \} } t|r ||| | n|} | | | kDr||| | | |dz }|jjD]-} | | \} } | dk7s| | kDs||| | || /|S)aHighlight text with a regular expression, where group names are translated to styles. Args: re_highlight (str): A regular expression. style (Union[GetStyleCallable, StyleType]): Optional style to apply to whole match, or a callable which accepts the matched text and returns a style. Defaults to None. style_prefix (str, optional): Optional prefix to add to style group names. Returns: int: Number of regex matches rr) rWror*rfrefinditerrcallable groupdictkeys)r2rr-rcount append_spanr{rfmatchget_spanr+r, match_stylenames r3highlight_regexzText.highlight_regexPs&kk((  [[u5 LEzzH%Z s9A%eE%$45e *sU{eS+ >? QJE)..0 L%d^ sB;3;eS\N4&2I JK L L r5)case_sensitivewordsrc6djd|D}|jj}d}t}t j ||j |rdntjD]+}|jd\} } ||| | ||dz }-|S)aBHighlight words with a style. Args: words (Iterable[str]): Words to highlight. style (Union[str, Style]): Style to apply. case_sensitive (bool, optional): Enable case sensitive matching. Defaults to True. Returns: int: Number of words highlighted. |c3FK|]}tj|ywr7)rrrwords r3rz'Text.highlight_words..s>BIIdO>s!rflagsr) rrWror*rrrf IGNORECASEr) r2rr-rre_wordsadd_spanrr{rr+r,s r3highlight_wordszText.highlight_wordsvs"88>>>;;%%[[ djj^  EAJE3 U5#u- . QJE    r5cB|jj|_y)z"Strip whitespace from end of text.N)rfrstripr1s r3rz Text.rstripsZZ&&( r5sizect|}||kDr]||z }tj|j}|6t|j d}|j t ||yyy)zRemove whitespace beyond a certain width at the end of the text. Args: size (int): The desired size of the text. Nr)r^_re_whitespacesearchrfgrouprDr;)r2r text_lengthexcesswhitespace_matchwhitespace_counts r3 rstrip_endzText.rstrip_endso $i   4'F-44TZZ@ +#&'7'='=a'@#A $4f =>, r5 new_lengthct|}||k7r/||kr|j||z y|j||z yy)z.s>Xd^>rc32K|]}t|ywr7rrs r3rz(Text.__rich_measure__..s141r)rf splitlinesmaxr>r)r2rrr\rmax_text_widthrmin_text_widths r3__rich_measure__zText.__rich_measure__s^zz!BG>>>Q 5:C151 1 >>::r5rc#VKt}|j}|jst||r ||yt|jt j }tt|jd}|Dcic]\}}|||jc}}||jd<dgd|Dd|Dt|ddf} | jtdd gj} j} ijt j d t ffd } t#| | ddD]9\\} }}\}}}|r | |n| ||| kDs'||| || ;|r ||yycc}}ww) aRender the text as Segments. Args: console (Console): Console instance. end (Optional[str], optional): Optional end character. Returns: Iterable[Segment]: Result of render that may be written to the console. Nrrr)rFrc3@K|]\}}|jd|fywr)r+rindexrs r3rzText.render..s M[UDtzz5%( Mc3@K|]\}}|jd|fywrrr%s r3rzText.render..s J+%txxu% Jr'Trr.cttfdtD}|}||S|}||<|S)z#Construct current style from stack.c3(K|] }| ywr7rP)r _style_id style_maps r3rz9Text.render..get_current_style..sOI9Y/Os)tuplesorted)styles cached_style current_stylecombinestack style_cachestyle_cache_getr,s r3get_current_stylez&Text.render..get_current_stylesFOOOF*62L'###FOM"/K  r5)rrfrWrrrnulllist enumerater-r^rrroremovegetr2zip)r2rr,_Segmentr\renumerated_spansr&rr[ stack_append stack_popr6r9leavingstyle_id next_offset_r2r3r4r5r,s @@@@@r3rz Text.renderszz{{$- sm# G--uzz|D  $++q 9:EUVkeTUIdjj11V  , !   M.iter_texts>zz"+E"2#JD$J" # !  s$< <:<rc3FK|]\}}}|z|z|ywr7rP)rr+r,r-r{r9s r3rzText.join..'s0%E3funfslE:!) rr rRrGrWror*r-r^rX) r2rrrH extend_textr extend_spansr\r{r9s `` @@r3rz Text.joins??$ !8F+ !nn++ oo,, -- K D  #zzE&&3t9*rrRrrr(rr^rXrW) r2rVrror cell_positionrr tab_remainderrrqs r3 expand_tabszText.expand_tabs/sV tzz !   }}H  H!JJttJ< !D4::%t !  44 @! !Dzz**40)-B)9~"L$LL"  JJ< E(9':;DJ r5alignwidthc|j||t|jz }|r]|dk(r|j||y|dk(r-|dz}|j |||j||z |y|j ||yy)zAlign text to a given width. Args: align (AlignMethod): One of "left", "center", or "right". width (int): Desired width. character (str, optional): Character to pad with. Defaults to " ". leftcenterN)rXrrfrra)r2rcrdr[ excess_spacerfs r3rcz Text.aligns ex 33 |Y7("#q( dI.|d2I> lI6 r5rc Lt|ttfs tdt |rtt|tr~t |}|j j|t |}t ||r)|jjt||z||xjz c_ |St|trt| td|j|jr9|jjt |z|j|j j|j|jjfd|jD|xjt |z c_ |S)zAdd text with an optional style. Args: text (Union[Text, str]): A str or Text to append. style (str, optional): A style name. Defaults to None. Returns: Text: Returns self for chaining. z(Only str or Text can be appended to Textz2style must not be set when appending Text instancec3FK|]\}}}|z|z|ywr7rPrr+r,r-r{rs r3rzText.append..s2#)sE%+-s[/@%H#rJ)rmrNr(rr^rrRrorWr*rX ValueErrorr-rfrG)r2r\r-r_r9r{rs @@r3roz Text.appendsO$d ,FG G t9$$!4T!: !!.1T!.1 KK&&tFF[4H%'PQ + $ #D$'$$L#ll ::KK&&k;T+BDJJO !!$**- ""#-1[[# D )  r5c t|j|jr9|jj t |z|j|j j |j|jjfd|jD|xjt |z c_|S)a Append another Text instance. This method is more performant that Text.append, but only works for Text. Args: text (Text): The Text instance to append to this instance. Returns: Text: Returns self for chaining. c3FK|]\}}}|z|z|ywr7rPrls r3rz#Text.append_text..s2 !sE %+%s['8% @ rJ) r*rXr-rWror^rRrfrG)r2r\r{rs @@r3 append_textzText.append_textsll :: KK  u[+D 2I4::V W $**%  %)[[   D !  r5tokensc  |jj}|jj}t}t |}|D]9\}}|||r||||t |z||t |z };||_|S)a)Append iterable of str and style. Style may be a Style instance or a str style definition. Args: tokens (Iterable[Tuple[str, Optional[StyleType]]]): An iterable of tuples containing str content and style. Returns: Text: Returns self for chaining. )rRrorWr*r^rX)r2rqrprr{r9contentr-s r3 append_tokenszText.append_tokenssjj'' kk(( T$ #NGU  E&&3w<*?GH c'l "F  #   r5cN|jj|jy)zCopy styles from another Text instance. Args: text (Text): A Text instance to copy styles from, must be the same length. N)rWrG)r2r\s r3 copy_styleszText.copy_styless 4;;'r5)rO allow_blank separatorrOrwcsJd|jvrt|jgS|r@|jdt j t j D}n.;s  %  sr.c3KtjtjD]}|j\}}||ywr7)rrrr)rr+r,rxr\s r3 flatten_spansz!Text.split..flatten_spans@sC[[9)=tDE!&JE3KIsA Ac3BK|]}|jk7s|ywr7re)rrrxs r3rzText.split..Fs!yAXs) rfrrnr~rrrr rLrpop)r2rxrOrwrr|r\s ` @r3r>z Text.split#s"777yzz D $))+' ' KK )+RYYy5I4)P E  8C=  !%]_!=Et}}Y7 IIK r5offsetsc t|}|st|jgS|jt }dg||}tt ||dd}|j |j|jttfd|D}|js|S|jDcgc]}|jj}}t |} t} |jD]\} } d} | }| |zdz} ||\}}| |kr|dz }n | |kDr|dz} nn | |zdz}(| |kr|}n/|x}} | } ||\}}| |kr|dz }n | |kDr|dz} nn | |zdz}(t||dzD]D}||\}}td| |z }t!| |z ||z }||kDs2||| ||F|Scc}w)zDivide text in to a number of lines at given offsets. Args: offsets (Iterable[int]): Offsets used to divide text. Returns: Lines: New RichText instances between offsets. rrNc3BK|]\}}||yw))r-rSrTNrP)rr+r,rrSrTr-r\s r3rzText.divide..fs; s U3!    srh)r8rrnrfr^r<r-rSrTr(rW_linesror*rangerr;)r2r_offsetsrdivide_offsets line_ranges new_linesr _line_appends line_countr{ span_startspan_end lower_bound upper_bound start_line_no line_startline_end end_line_noline_no new_startnew_endrrSrTr-r\s @@@@@r3r~z Text.divideOsI=$))+' 'zz$i 4h4 43~~ab/ABC  ,,== *  {{ 8A8H8HI++I I% +/;;$ M 'J%K$K(;61rRrrNr~r rXrG) r2rrdrSrTrVrU wrap_justify wrap_overflowrrrrs r3rz Text.wraps.A$,,A/  EDMME5E GT\\59QX=QJJ4J0 $Dt|  *!4&M %c$i]f=TU KK0 ! '& '!!UL="" = em < = LL #! $" r5ct}|j}|jD]}|j||||S)zFit the text in to given width by chopping in to lines. Args: width (int): Maximum characters in a line. Returns: Lines: Lines container. )rror>r)r2rdrrors r3fitzText.fitsCwJJL D OOE " 4L  r5c:tjd|jtjDchc]}t |j d}} t t|Dcgc] }|dzr | c}xsd}|Scc}wcc}w#t$rd}Y|SwxYw)zrAuto-detect indentation of code. Returns: int: Number of spaces used to indent code. ^( *)(.*)$rrrh) rrrf MULTILINEr^rrrr)r2r _indentationsindent indentations r3detect_indentationzText.detect_indentations]DJJbllS   A    s-RvPQzVRSXWX   S K s/!BB % B 0B 4 B B BBu│z dim green)r[r- indent_sizec$||jn|}|j}|j|d|dz z}tjd}g}|j } d} |j dD]} |j| j} | r| jds| dz } 7| jd} tt| |\}}||zd|z}|| jt|dz| _| j|dt|| r"|jt|| g| zd} | | | r |jtd | g| z|jd j!|}|S) uAdds indent guide lines to text. Args: indent_size (Optional[int]): Size of indentation, or None to auto detect. Defaults to None. character (str, optional): Character to use for indentation. Defaults to "│". style (Union[Style, str], optional): Style of indent guides. Returns: Text: New text with indentation guides. NrirrrTrrhr-rYrZ)rrnrRrcompileror>rrfrdivmodr^rrGr(rr)r2rr[r- _indent_sizer\ indent_line re_indentradd_line blank_linesrrr full_indentsremaining_space new_indentrs r3with_indent_guideszText.with_indent_guidess$5@4Gt..0[ yy{ " C JJ}- " ## JJ4J0 DOODJJ/E Aq [[^F,23v; ,M )L/',67o8M7NOJ#djjZ1B&CCDJ LL3z? 3  $z"?!@;!NO TN     d2U34{B C??4(--i8r5)rYrY)rY)r.r()rNr7)r.N)ri)r\r(r.r()r\r(r.N)rZ)r)RrHrIrJrK __slots__rNrrrrOrLr r*r`rbr8rgr4rrrobjectrurwrxrpropertyrr classmethodrrrrrrr rrfsetterr[rrnrrrrrrrGetStyleCallablerr rrr rrrrr"rrrRrXrrSrarrrcrorprtrvrr>r~rDrrrrrPr5r3r(r(us   I#%0 .2/3"&"&&*00S%Z 0 /* 0 +, 0$003-0T #0 0."$"8#8SVIFItI &TIsEz!2IvI4$#$$: $&04-1/3S%Z     - /*+, B $&-1/3"&"###S%Z # /* # +, #$##3-# ##J .2/3  /*  +,  0$&-1/3"&)-+c65i#889+S%Z +/* + +, + $ +++tCH~&+ ++Zs  \\#c#d##tDz \\4:$  V  "! ES%Z EEc] E  E:! HS%Z HHc] H  H6JN 2cN 2+. 29A# 2  2xS#X/CF()C)D)9ce(%3%4%0?C$  $$. 9:;$  $ $V $ }S%Z    :) ?s ?t ?5S5T5; ;+;; ' ;& ;  ;+; ;  ;9 i9 c9 8I;N9 v%(6*%v%N('HSM('T('\04 //+, /  /  /6  t"ccD ? .(*#(! ** *  *  *XMhsmMM^T*.2/3"&... /* . +, ..$. .` C.&*.& .c]. .  .  .r5__main__)r a Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Loremboldipsumitaliczjustify='left'redrzjustify='center'greenrg)r-rSzjustify='right'bluerightzjustify='full'magentafull)Br functoolsrrmathroperatorrtypingrrr r r r r rrr_loopr_pickr_wraprrcrrErr containersrcontrolrrrjupyterrmeasurersegmentrr-rrrr r!r"r#r%rMr'rrrNTextTyperr*r(rH rich.consoler\rruleprintrPr5r3rs %   *(! #OO#,,%+"+G$ f 1SE8I#667D:DN|<|~% z$  P D 'F+'H-iG LL!" MM$eM$ MMO LL#$ MM$gxM8 MMO LL"# MM$fgM6 MMO LL!" MM$iM8 MMO3r5