2bi^SSKJr SSKJr SSKJr SSKJr SSKJ r SSK J r J r J r JrJrJrJrJrJrJr SSKJrJrJrJrJr SS KJrJr SS KJr \ (a SS K J!r!J"r"J#r# \"S 5r$"S S\5r%\\\%\\%\\&\'44\\%\&\&44r(\"5"SS\55r)"SS5r*"SS5r+\,S:XGaSSK-J!r! SSK.J/r/ SSK0J1r1 Sr2\1Rf"S5r4\!"5r \ RkS5 \ RmS5 \ RmS5 \ Rm\/"\2SSS 95 \ Rm5 \ RmS!5 \7"\ Rq\455r9\ Rm\95 \ Rm5 \ RmS"5 \ Rm\45 \ RmS#5 g$g$)%)IntEnum) lru_cache) filterfalse) getLogger) attrgetter) TYPE_CHECKINGDictIterableList NamedTupleOptionalSequenceTupleTypeUnion)_is_single_cell_widthscached_cell_lencell_lenget_character_cell_size set_cell_size)Result rich_repr)Style)ConsoleConsoleOptions RenderResultrichcX\rSrSrSrSrSrSrSrSr Sr S r S r S r S rS rSrSrSrSrSrSrg) ControlType#zDNon-printable control codes which typically translate to ANSI codes.r N)__name__ __module__ __qualname____firstlineno____doc__BELLCARRIAGE_RETURNHOMECLEAR SHOW_CURSOR HIDE_CURSORENABLE_ALT_SCREENDISABLE_ALT_SCREEN CURSOR_UP CURSOR_DOWNCURSOR_FORWARDCURSOR_BACKWARDCURSOR_MOVE_TO_COLUMNCURSOR_MOVE_TO ERASE_IN_LINESET_WINDOW_TITLE__static_attributes__r1ڊ/builddir/build/BUILDROOT/alt-python313-pip-23.3.1-3.el8.x86_64/opt/alt/python313/lib/python3.13/site-packages/pip/_vendor/rich/segment.pyr r #sYN DO D EKKIKNONMrHr c\rSrSr%Sr\\S'Sr\\ \S'Sr \\ \ \S'\ S\4Sj5rS\4S jrS\4S jr\ S\4S j5r\\"S 5S SS\S\S4Sj55rS\S\S4Sjr\S1Sj5r\S2S\SS\\ S\\ S\S4Sjj5r\S3S\SS\S\S4Sjj5r\S\SS\\S4Sj5r\S4S\SS\S\\ S\S\S\\S4 Sjj5r \S5S\SS\S\\ S\S\S4 Sjj5r!\S\SS\4Sj5r"\S \\SS\\\44S!j5r#\S6S \\SS"\S#\\S\\ S$\S\\S4 S%jj5r$\S3S&\%SS \\SS"\S#\S\ S$\S\\S4S'jj5r&\S3S&\%SS \\SS"\S#\S\ S$\S\\S4S(jj5r'\S3S&\%SS \\SS"\S#\S\ S$\S\\S4S)jj5r(\S\SS\S4S*j5r)\S\SS\S4S+j5r*\S\SS\S4S,j5r+\S\SS\S4S-j5r,\S\SS.\\S\\S4S/j5r-S0r.g)7Segment?aA piece of text with associated style. Segments are produced by the Console render process and are ultimately converted in to strings to be written to the terminal. Args: text (str): A piece of text. style (:class:`~rich.style.Style`, optional): An optional style to apply to the text. control (Tuple[ControlCode], optional): Optional sequence of control codes. Attributes: cell_length (int): The cell length of this Segment. textNstylecontrolreturnc4UupnU(aS$[U5$)zbThe number of terminal cells required to display self.text. Returns: int: A number of cells. r)r)selfrM_stylerOs rI cell_lengthSegment.cell_lengthQs!%gq/$/rHc## URv URcURbURv ggURv URv g7fN)rMrOrNrRs rI __rich_repr__Segment.__rich_repr__[sGii << zz%jj &** ,, AAc,[UR5$)z#Check if the segment contains text.)boolrMrXs rI__bool__Segment.__bool__dsDIIrHcURSL$)z,Check if the segment contains control codes.N)rOrXs rI is_controlSegment.is_controlhs||4''rHi@segmentcut)rKrKcUup4n[nURnX':a X"SXE54$[n[X'- [ U5S- -5n USU n [ U 5n X:XaU"XU5U"X9SXE54$U [ U5:agX9n U S- n X"U 5- n USU n X:XaU"XU5U"X9SXE54$X:a U"U SU S- S-XE5U"SX9S-XE54$U [ U5:aMg[ S5e)Nr zWill never reach here)rKrTrintlenrAssertionError) clsrcrdrMrNrO_SegmentrT cell_sizeposbeforecell_poschars rI _split_cellsSegment._split_cellsmsG 'W))  HR88 8+ 3$TQ78dsF# ?0dU4 CIo9D 1HC  $ 'H$3ZFVG4T$Z8~VIcAg.4eES4:-u>CIo 455rHcUup#n[U5(a:U[U5:aU[SX454$[USUX45[X!SX454$URX5$)aSplit segment in to two segments at the specified column. If the cut point falls in the middle of a 2-cell wide character then it is replaced by two spaces, to preserve the display width of the parent segment. Returns: Tuple[Segment, Segment]: Two segments. rfN)rrirKrr)rRrdrMrNrOs rI split_cellsSegment.split_cellssr $W !$ ' 'c$iWR888Tc E3T E3    ++rHcU"S5$)zMake a new line segment. r1)rks rIline Segment.lines4yrHsegments post_stylecx^^^UnU(aURmUU4SjU5nT(a UU4SjU5nU$)aApply style(s) to an iterable of segments. Returns an iterable of segments where the style is replaced by ``style + segment.style + post_style``. Args: segments (Iterable[Segment]): Segments to process. style (Style, optional): Base style. Defaults to None. post_style (Style, optional): Style to apply on top of segment style. Defaults to None. Returns: Iterable[Segments]: A new iterable of segments (possibly the same iterable). c3Z># UH upnT"X(aSOT"U5U5v M" g7frWr1).0rMrSrOapplyrks rI &Segment.apply_style..s1-<)D'D'$uV}gFF-# UH'upnT"UU(aSO U(aUT-OTU5v M) g7frWr1)rrMrSrOrkr|s rIrrsG .=)D'#5;fz1.=s/2)__add__)rkr{rNr|result_segmentsrs` ` @rI apply_styleSegment.apply_stylesC&# MME-<O  .= OrHracdU(a[[S5U5$[[S5U5$)aFilter segments by ``is_control`` attribute. Args: segments (Iterable[Segment]): An iterable of Segment instances. is_control (bool, optional): is_control flag to match in search. Returns: Iterable[Segment]: And iterable of Segment instances. rO)filterrr)rkr{ras rIfilter_controlSegment.filter_controls+ *Y/: :z)4h? ?rHc#Z# /nURnUHnSUR;alUR(d[UupVnU(aMURS5upnU(aU"U"X55 U (aUv /nURnU(aMKM}MU"U5 M U(aUv gg7f)zSplit a sequence of segments in to a list of lines. Args: segments (Iterable[Segment]): Segments potentially containing line feeds. Yields: Iterable[List[Segment]]: Iterable of segment lists, one per line. rxN)appendrMrO partition) rkr{ryrrcrMrN__textnew_lines rI split_linesSegment.split_liness!Gw||#GOO!(Q,0NN4,@)ETs501" !!%dw  J s B B+B+lengthpadinclude_new_linesc## /nURnURnU"S5n UHn SU R;aU R(d|U upn U (anU R S5upn U(aU"U"X55 U(a3U"XbX4S9nU(aURU 5 Uv UR 5 U (aMlMMU"U 5 M U(a U"XbX4S9v gg7f)aSplit segments in to lines, and crop lines greater than a given length. Args: segments (Iterable[Segment]): An iterable of segments, probably generated from console.render. length (int): Desired line length. style (Style, optional): Style to use for any padding. pad (bool): Enable padding of lines that are less than `length`. Returns: Iterable[List[Segment]]: An iterable of lines of segments. rx)rNrN)radjust_line_lengthrMrOrclear)rkr{rrNrrryrrnew_line_segmentrcrM segment_stylerrr cropped_lines rIsplit_and_crop_linesSegment.split_and_crop_lines s*! 33t9Gw||#GOO)0&Q,0NN4,@)ETs589'9 ( -(//0@A** dw! " $TH H s B?C%"C%rycn[SU55nXR:a"U(aX"SX%- -U5/-nU$USSnU$XR:aq/nURnSnUHXnURn XY-U:dUR(aU"U5 XY- nM6Uupn [ XU- 5n U"U"X55 U$ U$USSnU$)aAdjust a line to a given width (cropping or padding as required). Args: segments (Iterable[Segment]): A list of segments in a single line. length (int): The desired width of the line. style (Style, optional): The style of padding if used (space on the end). Defaults to None. pad (bool, optional): Pad lines with spaces if they are shorter than `length`. Defaults to True. Returns: List[Segment]: A line of segments with the desired length. c38# UHoRv M g7frW)rT)rrcs rIr-Segment.adjust_line_length..KsBT'--TsrgNr)sumrrTrOr) rkryrrNr line_lengthrrrcsegment_lengthrMrrs rIrSegment.adjust_line_length8s&BTBB   3sf.B'CU#K"LL&# 7"! !H__FK!(!4!4/&8GOO7O1K-4*D( /CDD3t34 AwHrHc:^[m[U4SjU55$)zGet the length of list of segments. Args: line (List[Segment]): A line encoded as a list of Segments (assumes no '\\n' characters), Returns: int: The length of the line. c3J># UHupo3(aMT"U5v M g7frWr1)rrMrNrO _cell_lens rIr*Segment.get_line_length..ps St';tG7?9T??ts ##)rr)rkryrs @rIget_line_lengthSegment.get_line_lengthes StSSSrHlinescr^URmU(a[U4SjU55OSnU[U54$)zGet the shape (enclosing rectangle) of a list of lines. Args: lines (List[List[Segment]]): A list of lines (no '\\n' characters). Returns: Tuple[int, int]: Width and height in characters. c34># UH nT"U5v M g7frWr1)rryrs rIr$Segment.get_shape..}s@%$--%sr)rmaxri)rkr max_widthrs @rI get_shapeSegment.get_shapers3--DIC@%@@q 3u:&&rHwidthheight new_linesc 6U=(d [U5nU(aU"SU-S-U5/O U"SU-U5/nURnUSUn UV s/sH o"XUS9PM sn U SS&[U 5U:a!U RU/U[U 5- -5 U $s sn f)aSet the shape of a list of lines (enclosing rectangle). Args: lines (List[List[Segment]]): A list of lines. width (int): Desired width. height (int, optional): Desired height or None for no change. style (Style, optional): Style of any padding added. new_lines (bool, optional): Padded lines should include " ". Defaults to False. Returns: List[List[Segment]]: New list of lines. rgrxN)rN)rirextend) rkrrrrNr_heightblankr shaped_linesrys rI set_shapeSegment.set_shapes*&CJ1:Sut#U + ,C%KQV@W?X !33Xg EJ EJT t% 8U Q | w &   7S5F+F G H  sBrkcU[U5- nU(dUSS$USUnU(aU"SU-S-U5O U"SU-U5nX//U--nU$)aAligns lines to top (adds extra lines to bottom as required). Args: lines (List[List[Segment]]): A list of lines. width (int): Desired width. height (int, optional): Desired height or None for no change. style (Style): Style of any padding added. new_lines (bool, optional): Padded lines should include " ". Defaults to False. Returns: List[List[Segment]]: New list of lines. NrgrxrirkrrrrNr extra_linesrs rI align_topSegment.align_topsd*s5z) 8Ogv2;C%K$&.S5[RWAX K// rHcU[U5- nU(dUSS$USUnU(aU"SU-S-U5O U"SU-U5nU//U-U-nU$)aAligns render to bottom (adds extra lines above as required). Args: lines (List[List[Segment]]): A list of lines. width (int): Desired width. height (int, optional): Desired height or None for no change. style (Style): Style of any padding added. Defaults to None. new_lines (bool, optional): Padded lines should include " ". Defaults to False. Returns: List[List[Segment]]: New list of lines. Nrgrxrrs rI align_bottomSegment.align_bottomsf*s5z) 8Ogv2;C%K$&.S5[RWAX K'%/ rHcU[U5- nU(dUSS$USUnU(aU"SU-S-U5O U"SU-U5nUS-nXh- n U//U-U-U//U --nU$)aAligns lines to middle (adds extra lines to above and below as required). Args: lines (List[List[Segment]]): A list of lines. width (int): Desired width. height (int, optional): Desired height or None for no change. style (Style): Style of any padding added. new_lines (bool, optional): Padded lines should include " ". Defaults to False. Returns: List[List[Segment]]: New list of lines. Nrgrxr"r) rkrrrrNrrr top_lines bottom_liness rI align_middleSegment.align_middles*s5z) 8Ogv2;C%K$&.S5[RWAX1$ ".  I%-% L0HH rHc#:# [U5n[U5n[nUH`nURUR:Xa=UR (d,U"UR UR -UR5nMZUv UnMb Uv g![a gf=f7f)aSimplify an iterable of segments by combining contiguous segments with the same style. Args: segments (Iterable[Segment]): An iterable of segments. Returns: Iterable[Segment]: A possibly smaller iterable of segments that will render the same way. N)iternext StopIterationrKrNrOrM)rkr{ iter_segments last_segmentrlrcs rIsimplifySegment.simplifysX   .L$G!!W]]27??' %% 4l6H6H  #"& %   s( B B A1B BBBBc## UHNnUR(d URcUv M'Uup4nU"X4(aURS5OS5v MP g7f)zRemove all links from an iterable of styles. Args: segments (Iterable[Segment]): An iterable segments. Yields: Segment: Segments with link removed. N)rOrN update_link)rkr{rcrMrN_controls rI strip_linksSegment.strip_linkssL G'--"7 (/%X$5 1 1$ 7dKK  r[c#<# UHup#nU"USU5v M g7f)zRemove all styles from an iterable of segments. Args: segments (Iterable[Segment]): An iterable segments. Yields: Segment: Segments with styles replace with None Nr1)rkr{rMrSrOs rI strip_stylesSegment.strip_styles)s%&. !D'dD'* *&.sc## 0nUHJup4nU(a1URU5nUcURnXbU'U"X6U5v M>U"USU5v ML g7f)zRemove all color from an iterable of segments. Args: segments (Iterable[Segment]): An iterable segments. Yields: Segment: Segments with colorless style. N)get without_color)rkr{cacherMrNrOcolorless_styles rI remove_colorSegment.remove_color6s`%'$, D"'))E"2"*&+&9&9O#2%L$99$g..%-sAAcutsc## /nURn[U5n[US5nUS:Xa/$US:waO/v M!SnURnURn [ n UHn U upnU (dMU(aUO Xz"U 5-nX:a U"U 5 UnM5X:Xa@U"U 5 U "5v U"5 Un[US5nUS:XaU(a U "5v gMzU R Xg- 5unn U upnU"U5 U "5v U"5 Un[US5nUS:XaU(a U "5v gU (aMM U "5v g7f)zDivides an iterable of segments in to portions. Args: cuts (Iterable[int]): Cell positions where to divide. Yields: [Iterable[List[Segment]]]: An iterable of Segments in List. rN)rrrrcopyrru)rkr{rsplit_segments add_segment iter_cutsrdrnsegments_clear segments_copyrrcrMrSrOend_posros rIdivideSegment.divideLsf+-$++ J y"%Cby axH '--&++ # G$+ !D'$!(#cIdO.C=(!C>('/)"$!Cy"-Cby)"//1'.&9&9#)&DOFG,3)D'''/)"$C9b)"9%+o-C$ JosA+E 1C E <E r1)rPrK)NNF)NTT)NT)NNF)/r2r3r4r5r6str__annotations__rNr rrOr ControlCodepropertyrhrTrrYr]r^ra classmethodrrrrruryr rrr rrrrrrrrrrrrrrrrGr1rHrIrKrK?s  I!E8E?!/3GXh{+ ,3 0S00v$(D((y$69$63$65AU;V$6$6L,s,u-A'B,,"&&* &9%&&UO & )  &&P?D@ *@8<@ ) @@$8I#68DO;T8 "&"& ,I9%,I,I ,I  ,I  ,I $y/ ",I,I\ "& *9o** *  * i **X T4 ? Ts T T 'd4 ?3 'c3h ' ' !%!% !DO$!! !  !  ! d9o !!F  )_DO$      d9o 8  )_DO$      d9o 8  )_DO$      d9o < 38K4L8I#6L8I;NLL  +HY$7 +HY><<>D==  )}} $ $sAAAA)rr{rrrrrrPr) r2r3r4r5r6r rKr]rrrGr1rHrIrrsD#'!2#t#PT# %  %+; %  %rHrcP\rSrSrS S\\\S\SS4SjjrS Sjr Sr g) SegmentLinesirrrPNc0[U5UlX lg)aA simple renderable containing a number of lines of segments. May be used as an intermediate in rendering process. Args: lines (Iterable[List[Segment]]): Lists of segments forming lines. new_lines (bool, optional): Insert new lines after each line. Defaults to False. N)rrr)rRrrs rIrSegmentLines.__init__s%[ "rHc## UR(a6[R5nURHnUShvN Uv M gURH nUShvN M gN+N 7frW)rrKryr)rRrrrrys rIrSegmentLines.__rich_console__sT >>||~H # #  s!:A,A(!A,A* A,*A,)rrrr) r2r3r4r5r r rKr]rrrGr1rHrIrrsC #htG}5 #$ #SW #     +;    rHr__main__)r)Syntax)Textzfrom rich.console import Console console = Console() text = Text.from_markup("Hello, [bold magenta]World[/]!") console.print(text)zHello, [bold magenta]World[/]!z rich.Segmentz]A Segment is the last step in the Rich render process before generating text with ANSI codes.z Consider the following code: pythonT) line_numberszRWhen you call [b]print()[/b], Rich [i]renders[/i] the object in to the following: zAThe Segments are then processed to produce the following output: zS You will only need to know this if you are implementing your own Rich renderables.N):enumr functoolsr itertoolsrloggingroperatorrtypingrr r r r r rrrrcellsrrrrrreprrrrNrrrrrlogr rhrrrKrrr2pip._vendor.rich.consolepip._vendor.rich.syntaxrpip._vendor.rich.textr code from_markuprMruleprintrrender fragmentsr1rHrIrs!   $>>'* + +uS#X &' +sC  "  O jO  O d%%2  2 z0.* D   < =DiG LL  MMg MM45 MM&xd;< MMO MM]W^^D)*I MM) MMO MMVW MM$ MM^;rH