Files
ServerSync/lib/rich/__pycache__/segment.cpython-314.pyc

327 lines
34 KiB
Plaintext
Raw Normal View History

2026-02-12 02:28:23 +02:00
+
<00> <0C>i<EFBFBD>d<00><00><><00>^RIHt^RIHt^RIHt^RIHt^RIH t ^RI
H t H t H t HtHtHtHtHtHtHt^RIHtHtHtHtHt^RIHtHt^R IHt] 'd ^R
I H!t!H"t"H#t#]!R 4t$!R R ]4t%]]]%,]]%]]&]'3,3,]]%]&]&3,3,t(]!4!RR]44t)!RR4t*!RR4t+],R8XEd ^RI-H!t!^RI.H/t/^RI0H1t1Rt2]1Pf!R4t4]!!4t ] PkR4] PmR4] PmR4] Pm]/!]2RRR74] Pm4] PmR 4]7!] Pq]444t9] Pm]94] Pm4] PmR!4] Pm]44] PmR"4R##R##)$<24>)<01>IntEnum)<01> lru_cache)<01> filterfalse)<01> getLogger)<01>
attrgetter)
<EFBFBD> TYPE_CHECKING<4E>Dict<63>Iterable<6C>List<73>
NamedTuple<EFBFBD>Optional<61>Sequence<63>Tuple<6C>Type<70>Union)<05>_is_single_cell_widths<68>cached_cell_len<65>cell_len<65>get_character_cell_size<7A> set_cell_size)<02>Result<6C> rich_repr)<01>Style)<03>Console<6C>ConsoleOptions<6E> RenderResult<6C>richc<00>Z<00>]tRt^#tRt^t^t^t^t^t ^t
^t ^t ^ t ^
t^ t^ t^ t^t^t^tRtR#)<04> ControlTypezDNon-printable control codes which typically translate to ANSI codes.<2E>N)<16>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__firstlineno__<5F>__doc__<5F>BELL<4C>CARRIAGE_RETURN<52>HOME<4D>CLEAR<41> SHOW_CURSOR<4F> HIDE_CURSOR<4F>ENABLE_ALT_SCREEN<45>DISABLE_ALT_SCREEN<45> CURSOR_UP<55> CURSOR_DOWN<57>CURSOR_FORWARD<52>CURSOR_BACKWARD<52>CURSOR_MOVE_TO_COLUMN<4D>CURSOR_MOVE_TO<54> ERASE_IN_LINE<4E>SET_WINDOW_TITLE<4C>__static_attributes__r <00><00>3/tmp/pip-target-qd_sq_1j/lib/python/rich/segment.pyrr#sY<00><00>N<> <0C>D<EFBFBD><17>O<EFBFBD> <0C>D<EFBFBD> <0A>E<EFBFBD><13>K<EFBFBD><13>K<EFBFBD><19><15><1A><16><11>I<EFBFBD><14>K<EFBFBD><17>N<EFBFBD><18>O<EFBFBD><1E><19><17>N<EFBFBD><16>M<EFBFBD><19>r7rc<00><>a<00>]tRt^?toRtRtRt]V3RlRl4tV3RlRlt V3RlRlt
]V3R lR
l4t ] ] !R54V3R lR l44tV3R lRlt] V3RlRl4t] R6V3RlRll4t] R7V3RlRll4t] V3RlRl4t] V3RlRl4t] R8V3RlRll4t] R9V3RlRll4t] V3RlRl4t] V3RlR l4t] R:V3R!lR"ll4t] R7V3R#lR$ll4t] R7V3R%lR&ll4t] R7V3R'lR(ll4t] V3R)lR*l4t] V3R+lR,l4t] V3R-lR.l4t] V3R/lR0l4t ] V3R1lR2l4t!V3R3lt"R4t#Vt$R#);<3B>Segmenta<74>A 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.
Nc<00> <<01>V^8<>dQhRS[/#<00><02><00>return)<01>int)<02>format<61> __classdict__s"<22>r8<00> __annotate__<5F>Segment.__annotate__Rs<00><><00>0<>0<>S<EFBFBD>0r7c <0C>6<00>VwrpV'd^#\V4#)zbThe number of terminal cells required to display self.text.
Returns:
int: A number of cells.
)r)<04>self<6C>text<78>_style<6C>controls& r8<00> cell_length<74>Segment.cell_lengthQs<00><00>!%<25><1D><04>g<EFBFBD><1B>q<EFBFBD>/<2F><18>$<24><1E>/r7c<00> <<01>V^8<>dQhRS[/#r<)r)r@rAs"<22>r8rBrC[s<00><><00><1F><1F>v<EFBFBD>r7c#<08><>"<00>VPx<00>VPf!VPeVPx<00>R#R#VPx<00>VPx<00>R#5i<01>N)rFrH<00>style<6C>rEs&r8<00> __rich_repr__<5F>Segment.__rich_repr__[sG<00><00><00><12>i<EFBFBD>i<EFBFBD><0F> <0F><<3C><<3C> <1F><13>z<EFBFBD>z<EFBFBD>%<25><1A>j<EFBFBD>j<EFBFBD> <20>&<26><17>*<2A>*<2A> <1C><16>,<2C>,<2C> <1E>s<00>AAc<00> <<01>V^8<>dQhRS[/#r<<00><01>bool)r@rAs"<22>r8rBrCds<00><><00><1F><1F>$<24>r7c <0C>,<00>\VP4#)z#Check if the segment contains text.)rTrFrOs&r8<00>__bool__<5F>Segment.__bool__ds<00><00><13>D<EFBFBD>I<EFBFBD>I<EFBFBD><EFBFBD>r7c<00> <<01>V^8<>dQhRS[/#r<rS)r@rAs"<22>r8rBrCis<00><><00>(<28>(<28>D<EFBFBD>(r7c <0C><00>VPRJ#)z,Check if the segment contains control codes.N)rHrOs&r8<00>
is_control<EFBFBD>Segment.is_controlhs<00><00><14>|<7C>|<7C>4<EFBFBD>'<27>'r7c<00>8<<01>V^8<>dQhRRRS[RS[R,/#)r=<00>segmentr:<00>cutr><00>r:r:<00>r?r)r@rAs"<22>r8rBrCos(<00><><00>-<19>-<19>9<EFBFBD>-<19>3<EFBFBD>-<19>5<EFBFBD>AU<41>;V<>-r7c <0C>f<00>Vwr4p\pVPpW'8<>d W!RWE43#\p\W', \ V4,4p VRV p
\ V
4p W<>,
p V 'gV!W<>V4V!W9RWE43#V R8Xd@V!W9,4^8Xd-V!VRV R,WE4V!RW9^,R,WE43#V ^8XdGV!W9^,
,4^8Xd-V!VRV ^,
R,WE4V!RW9R,WE43#W<>8d V ^, p K<>V ^,p K<>)aSplit a segment in to two at a given cell position.
Note that splitting a double-width character, may result in that character turning
into two spaces.
Args:
segment (Segment): A segment to split.
cut (int): A cell position to cut on.
Returns:
A tuple of two segments.
<EFBFBD>N<> <20><><EFBFBD><EFBFBD><EFBFBD>)r:rIrr?<00>lenr) <0A>clsr]r^rFrNrH<00>_SegmentrI<00> cell_size<7A>pos<6F>before<72>cell_pos<6F>out_bys &&& r8<00> _split_cells<6C>Segment._split_cellsmsL<00><00> '<27><1C><04>W<EFBFBD><1A><08><1D>)<29>)<29> <0B> <0E> <1D><1A>H<EFBFBD>R<EFBFBD><15>8<>8<> 8<>+<2B> <09><11>3<EFBFBD>$<24><03>D<EFBFBD> <09>1<>2<><03><12><19>$<24>3<EFBFBD>Z<EFBFBD>F<EFBFBD><1F><06>'<27>H<EFBFBD><1D>^<5E>F<EFBFBD><19><1C>V<EFBFBD>G<EFBFBD>4<><1C>T<EFBFBD>$<24>Z<EFBFBD><15>8<><12><12><16><12>|<7C> <09>$<24>)<29> 4<><01> 9<><1C>T<EFBFBD>$<24>3<EFBFBD>Z<EFBFBD>#<23>-<2D>u<EFBFBD>><3E><1C>S<EFBFBD>4<EFBFBD>a<EFBFBD><07> <09>?<3F>2<>E<EFBFBD>C<><12><12><16><12>|<7C> <09>$<24>Q<EFBFBD>w<EFBFBD>-<2D> 8<>A<EFBFBD> =<3D><1C>T<EFBFBD>)<29>C<EFBFBD>!<21>G<EFBFBD>_<EFBFBD>s<EFBFBD>2<>E<EFBFBD>C<><1C>S<EFBFBD>4<EFBFBD><04>:<3A>-<2D>u<EFBFBD>><3E><12><12><18>~<7E><13>q<EFBFBD><08><03><13>q<EFBFBD><08>r7c<00>4<<01>V^8<>dQhRS[RS[R,/#)r=r^r>r_r`)r@rAs"<22>r8rBrC<00>s!<00><><00>,<2C>,<2C>s<EFBFBD>,<2C>u<EFBFBD>-A<>'B<>,r7c <0C><><00>Vwr#pV^8<>gQh\V4'd<V\V48<>dV\RW443#\VRVW44\W!RW443#VPW4#)a@Split 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.
Args:
cut (int): Offset within the segment to cut.
Returns:
Tuple[Segment, Segment]: Two segments.
rbN)rrer:rm)rEr^rFrNrHs&& r8<00> split_cells<6C>Segment.split_cells<6C>s}<00><00> $<24><1C><04>W<EFBFBD><12>a<EFBFBD>x<EFBFBD><0F>x<EFBFBD> !<21>$<24> '<27> '<27><12>c<EFBFBD>$<24>i<EFBFBD><1F><1B>W<EFBFBD>R<EFBFBD><15>8<>8<>8<><17><04>T<EFBFBD>c<EFBFBD>
<EFBFBD>E<EFBFBD>3<><17><04>T<EFBFBD>
<EFBFBD>E<EFBFBD>3<><0E> <0E>
<14> <20> <20><14>+<2B>+r7c<00><<01>V^8<>dQhRR/#)r=r>r:r )r@rAs"<22>r8rBrC<00>s<00><><00><19><19>Y<EFBFBD>r7c <0C><00>V!R4#)zMake a new line segment.<2E>
r )rfs&r8<00>line<6E> Segment.line<6E>s<00><00><13>4<EFBFBD>y<EFBFBD>r7c <00>n<<01>V^8<>dQhRS[R,RS[S[,RS[S[,RS[R,/#)r=<00>segmentsr:rN<00>
post_styler>)r
r r)r@rAs"<22>r8rBrC<00>sE<00><><00>&<1F>&<1F><1A>9<EFBFBD>%<25>&<1F><18><05><EFBFBD>&<1F><1D>U<EFBFBD>O<EFBFBD> &<1F>
<12>)<29> <1C> &r7c <0C>|aaa<05>TpV'dVPoVV3RlV4pS'dVV3RlV4pV#)a<>Apply 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).
c3<00>\<"<00>TF!wrpS!Y'dRMS!V4V4x<00>K# R#5irMr )<06>.0rFrGrH<00>applyrfs& <20><>r8<00> <genexpr><3E>&Segment.apply_style.<locals>.<genexpr><3E>s1<00><><00><00><0E>-<<3C>)<29>D<EFBFBD>'<27><14>D<EFBFBD>'<27>$<24>u<EFBFBD>V<EFBFBD>}<7D>g<EFBFBD>F<>F<>-<<3C>s<00>),c3<00>t<"<00>TF-wrpS!TV'dRMV'd
VS,MSV4x<00>K/ R#5irMr )r}rFrGrHrfrzs& <20><>r8rr<><00>sG<00><><00><00> <0E>.=<3D>)<29>D<EFBFBD>'<27><14><18>#<23><1D>5;<3B>f<EFBFBD>z<EFBFBD>1<><1A><1B><12><12>.=<3D>s<00>8<01>8)<01>__add__)rfryrNrz<00>result_segmentsr~sf&&f @r8<00> apply_style<6C>Segment.apply_style<6C>sC<00><><00>&#<23><0F> <10><19>M<EFBFBD>M<EFBFBD>E<EFBFBD><0E>-<<3C><0E>O<EFBFBD> <16> <0E>.=<3D> <0E>O<EFBFBD><1F>r7c<00>H<<01>V^8<>dQhRS[R,RS[RS[R,/#)r=ryr:rZr>)r
rT)r@rAs"<22>r8rBrC<00>s4<00><><00>@<01>@<01><1F> <09>*<2A>@<01>8<<3C>@<01> <11>)<29> <1C>@r7c <0C>f<00>V'd\\R4V4#\\R4V4#)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.
rH)<03>filterrr)rfryrZs&&&r8<00>filter_control<6F>Segment.filter_control<6F>s+<00><00> <16><19>*<2A>Y<EFBFBD>/<2F><18>:<3A> :<3A><1E>z<EFBFBD>)<29>4<>h<EFBFBD>?<3F> ?r7c<00>R<<01>V^8<>dQhRS[R,RS[S[R,,/#<00>r=ryr:r>)r
r )r@rAs"<22>r8rBrC<00>s)<00><><00><17><17>8<EFBFBD>I<EFBFBD>#6<><17>8<EFBFBD>D<EFBFBD><19>O<EFBFBD>;T<>r7c# <0C>\"<00>.pVPpVF<>pRVP9djVP'gXVwrVpV'dIVPR4wr<>pV'dV!V!W<>44V 'gK<Vx<00>.pVPpKPK}V!V4K<> V'dVx<00>R#R#5i)z<>Split 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.
ruN<><04>appendrFrH<00> partition<6F>
rfryrvr<>r]rFrN<00>_<>_text<78>new_lines
&& r8<00> split_lines<65>Segment.split_lines<65>s<><00><00><00>!<21><04><15><1B><1B><06><1F>G<EFBFBD><13>w<EFBFBD>|<7C>|<7C>#<23>G<EFBFBD>O<EFBFBD>O<EFBFBD>O<EFBFBD>!(<28><0E><04>Q<EFBFBD><1A>,0<>N<EFBFBD>N<EFBFBD>4<EFBFBD>,@<40>)<29>E<EFBFBD>T<EFBFBD><1C><1E>s<EFBFBD>5<EFBFBD>0<>1<><1F>x<EFBFBD>"<22>
<EFBFBD>!<21><04>!%<25><1B><1B><06><1B><17>w<EFBFBD><0F> <20> <10><16>J<EFBFBD> <10>s<00>6B,<01> B,<01>/B,<01>:)B,<01>$B,c<00>h<<01>V^8<>dQhRS[R,RS[S[S[R,S[3,,/#r<>)r
rr rT)r@rAs"<22>r8rBrCs5<00><><00> <20> <20><1F> <09>*<2A> <20> <11>%<25><04>Y<EFBFBD><0F><14>-<2D>.<2E> /<2F> r7c# <0C>d"<00>.pVPpVF<>pRVP9dlVP'gZVwrVpV'dKVPR4wr<>pV'dV!V!W<>44V 'gK<VR3x<00>.pVPpKRKV!V4K<> V'd VR3x<00>R#R#5i)a
Split a sequence of segments in to a list of lines and a boolean to indicate if there was a new line.
Args:
segments (Iterable[Segment]): Segments potentially containing line feeds.
Yields:
Iterable[List[Segment]]: Iterable of segment lists, one per line.
ruTFNr<4E>r<>s
&& r8<00>split_lines_terminator<6F>Segment.split_lines_terminators<><00><00><00>!<21><04><15><1B><1B><06><1F>G<EFBFBD><13>w<EFBFBD>|<7C>|<7C>#<23>G<EFBFBD>O<EFBFBD>O<EFBFBD>O<EFBFBD>!(<28><0E><04>Q<EFBFBD><1A>,0<>N<EFBFBD>N<EFBFBD>4<EFBFBD>,@<40>)<29>E<EFBFBD>T<EFBFBD><1C><1E>s<EFBFBD>5<EFBFBD>0<>1<><1F>x<EFBFBD>#<23>T<EFBFBD>l<EFBFBD>*<2A>!<21><04>!%<25><1B><1B><06><1B><17>w<EFBFBD><0F> <20> <10><17><15>-<2D> <1F> <10>s<00>6B0<01> B0<01>/B0<01>:+B0<01>&
B0c<00>z<<01>V^8<>dQhRS[R,RS[RS[S[,RS[RS[RS[S[R,,/#)r=ryr:<00>lengthrN<00>pad<61>include_new_linesr>)r
r?r rrTr )r@rAs"<22>r8rBrC6sa<00><><00>,I<01>,I<01><1A>9<EFBFBD>%<25>,I<01><14>,I<01><18><05><EFBFBD> ,I<01>
<12> ,I<01>  <20> ,I<01>
<12>$<24>y<EFBFBD>/<2F> "<22>,Ir7c# <0C><>"<00>.pVPpVPpV!R4p VF<>p
RV
P9d<>V
P'g}V
wr<>p V 'dnV P R4wr<>p V'dV!V!W<>44V'gK<V!WbW4R7pV'dVPV 4Vx<00>VP 4KuK<>V!V
4K<> V'dV!WbW4R7x<00>R#R#5i)a<>Split 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.
ru)rNr<>N)r<><00>adjust_line_lengthrFrHr<><00>clear)rfryr<>rNr<>r<>rvr<>r<><00>new_line_segmentr]rF<00> segment_styler<65>r<>r<><00> cropped_lines&&&&&& r8<00>split_and_crop_lines<65>Segment.split_and_crop_lines5s<><00><00><00>*!<21><04><15><1B><1B><06> <20>3<>3<><1A><1E>t<EFBFBD>9<EFBFBD><18><1F>G<EFBFBD><13>w<EFBFBD>|<7C>|<7C>#<23>G<EFBFBD>O<EFBFBD>O<EFBFBD>O<EFBFBD>)0<>&<26><04>Q<EFBFBD><1A>,0<>N<EFBFBD>N<EFBFBD>4<EFBFBD>,@<40>)<29>E<EFBFBD>T<EFBFBD><1C><1E>s<EFBFBD>5<EFBFBD>8<>9<><1F>x<EFBFBD>'9<> <20><05>(<1A> <0C>-<2D>(<28>/<2F>/<2F>0@<40>A<>*<2A>*<2A><1C>
<EFBFBD>
<EFBFBD> <0C><1B><17>w<EFBFBD><0F>! <20>" <10>$<24>T<EFBFBD><15>H<> H<> <10>s<00>A
C-<01> C-<01>/C-<01>AC-<01>C-c <00>d<<01>V^8<>dQhRS[R,RS[RS[S[,RS[RS[R,/#)r=rvr:r<>rNr<>r><00>r r?r rrT)r@rAs"<22>r8rBrCesI<00><><00>*<18>*<18><12>9<EFBFBD>o<EFBFBD>*<18><14>*<18><18><05><EFBFBD> *<18>
<12> *<18>
<0E>i<EFBFBD><1F> *r7c <0C><><00>\RV44pWR8d4V'd W!RW%,
,V4.,pV#VR,pV#WR8<52>d<>.pVPp^pVFfpVPp WY,V8gVP'dV!V4WY, pK@Vwr<>p \ W<>V,
4p
V!V!W<>44V# V#VR,pV#)a<>Adjust 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.
c3<00>8"<00>TFqPx<00>K R#5irM)rI)r}r]s& r8r<00>-Segment.adjust_line_length.<locals>.<genexpr>ws<00><00><00>B<>T<EFBFBD>'<27>-<2D>-<2D>T<EFBFBD>s<00>rc<00>NNN)<05>sumr<6D>rIrHr) rfrvr<>rNr<><00> line_lengthr<68>r<>r]<00>segment_lengthrFr<>r<>s &&&&& r8r<><00>Segment.adjust_line_lengthds<><00><00>&<1A>B<>T<EFBFBD>B<>B<> <0B> <17> <1F><12><1F>3<EFBFBD>s<EFBFBD>f<EFBFBD>.B<>'C<>U<EFBFBD>#K<>"L<>L<><08>&<18><0F># <20><01>7<EFBFBD><08>"<18><0F>!<19> !<21><19>H<EFBFBD><1D>_<EFBFBD>_<EFBFBD>F<EFBFBD><1B>K<EFBFBD><1F><07>!(<28>!4<>!4<><0E><1E>/<2F>&<26>8<>G<EFBFBD>O<EFBFBD>O<EFBFBD>O<EFBFBD><1A>7<EFBFBD>O<EFBFBD><1F>1<>K<EFBFBD>-4<>*<2A>D<EFBFBD><11>(<28><14> <0B>/C<>D<>D<EFBFBD><1A>3<EFBFBD>t<EFBFBD>3<>4<><19><18><0F> <20><18><0F><1C>A<EFBFBD>w<EFBFBD>H<EFBFBD><17>r7c<00>4<<01>V^8<>dQhRS[R,RS[/#)r=rvr:r>)r r?)r@rAs"<22>r8rBrC<00>s#<00><><00>
T<01>
T<01>4<EFBFBD> <09>?<3F>
T<01>s<EFBFBD>
Tr7c <0C>:a<02>\o\V3RlV44#)z<>Get 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.
c3<00>L<"<00>TFwrq3'dKS!V4x<00>K R#5irMr )r}rFrNrH<00> _cell_lens& <20>r8r<00>*Segment.get_line_length.<locals>.<genexpr><3E>s <00><><00><00>S<>t<EFBFBD>';<3B>t<EFBFBD>G<EFBFBD>7<EFBFBD>?<3F>9<EFBFBD>T<EFBFBD>?<3F>?<3F>t<EFBFBD>s<00> $<01>$)rr<>)rfrvr<>s&&@r8<00>get_line_length<74>Segment.get_line_length<74>s<00><><00><1D> <09><12>S<>t<EFBFBD>S<>S<>Sr7c<00>Z<<01>V^8<>dQhRS[S[R,,RS[S[S[3,/#)r=<00>linesr:r>)r rr?)r@rAs"<22>r8rBrC<00>s,<00><><00> '<27> '<27>d<EFBFBD>4<EFBFBD> <09>?<3F>3<> '<27><05>c<EFBFBD>3<EFBFBD>h<EFBFBD><0F> 'r7c <0C>ta<03>VPoV'd\V3RlV44M^pV\V43#)z<>Get 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.
c3<00>4<"<00>TF pS!V4x<00>K R#5irMr )r}rvr<>s& <20>r8r<00>$Segment.get_shape.<locals>.<genexpr><3E>s<00><><00><00>@<40>%<25>$<24><0F><04>-<2D>-<2D>%<25>s<00>)r<><00>maxre)rfr<><00> max_widthr<68>s&& @r8<00> get_shape<70>Segment.get_shape<70>s3<00><><00><1E>-<2D>-<2D><0F>DI<44>C<EFBFBD>@<40>%<25>@<40>@<40>q<EFBFBD> <09><19>3<EFBFBD>u<EFBFBD>:<3A>&<26>&r7c<00><><<01>V^8<>dQhRS[S[R,,RS[RS[S[,RS[S[,RS[RS[S[R,,/#)r=r<>r:<00>width<74>heightrN<00> new_linesr>r<>)r@rAs"<22>r8rBrC<00>sa<00><><00>!<1C>!<1C><13>D<EFBFBD><19>O<EFBFBD>$<24>!<1C><13>!<1C><19><13> <0A> !<1C>
<18><05><EFBFBD> !<1C> <18> !<1C>
<0E>d<EFBFBD>9<EFBFBD>o<EFBFBD> <1E>!r7c  <0C>h<00>T;'g \V4pV'dV!RV,R,V4.MV!RV,V4.pVPpVRVp VU
u.uF q<>!W<>VR7NK up
V R&\V 4V8d*V PV.V\V 4,
,4V #uup
i)a<>Set 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.
rcruN)rNr<>)rer<><00>extend) rfr<>r<>r<>rNr<><00>_height<68>blankr<6B><00> shaped_linesrvs &&&&&& r8<00> set_shape<70>Segment.set_shape<70>s<><00><00>*<19>&<26>&<26>C<EFBFBD><05>J<EFBFBD><07>1:<3A>S<EFBFBD><13>u<EFBFBD><1B>t<EFBFBD>#<23>U<EFBFBD> +<2B> ,<2C><03>C<EFBFBD>%<25>K<EFBFBD>QV<51>@W<>?X<> <0E>!<21>3<>3<><1A><1C>X<EFBFBD>g<EFBFBD><EFBFBD> <0C>EJ<45>
<EFBFBD>EJ<EFBFBD>T<EFBFBD> <1E>t<EFBFBD>%<25> 8<>U<EFBFBD>
<EFBFBD> <0C>Q<EFBFBD><0F> <0F>|<7C> <1C>w<EFBFBD> &<26> <18> <1F> <1F><15><07>7<EFBFBD>S<EFBFBD><1C>5F<35>+F<> G<> H<><1B><1B><> 
s<00>B/c<00><><<01>V^8<>dQhRS[R,RS[S[R,,RS[RS[RS[RS[RS[S[R,,/#<00> r=rfr:r<>r<>r<>rNr<>r><00>rr r?rrT)r@rAs"<22>r8rBrC<00><00>e<00><><00><15><15> <11>)<29>_<EFBFBD><15><13>D<EFBFBD><19>O<EFBFBD>$<24><15><13><15><14> <15>
<15> <15> <18> <15>
<0E>d<EFBFBD>9<EFBFBD>o<EFBFBD> <1E>r7c <0C><><00>V\V4,
pV'g
VR,#VRVpV'dV!RV,R,V4MV!RV,V4pW..V,,pV#)a<>Aligns 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.
r<>Nrcru<00>re<00>rfr<>r<>r<>rNr<><00> extra_linesr<73>s&&&&&& r8<00> align_top<6F>Segment.align_top<6F>sd<00><00>*<1D>s<EFBFBD>5<EFBFBD>z<EFBFBD>)<29> <0B><1A><18><11>8<EFBFBD>O<EFBFBD><15>g<EFBFBD>v<EFBFBD><0E><05>2;<3B><03>C<EFBFBD>%<25>K<EFBFBD>$<24>&<26><05>.<2E><13>S<EFBFBD>5<EFBFBD>[<5B>RW<52>AX<41><05><15><17> <09>K<EFBFBD>/<2F>/<2F><05><14> r7c<00><><<01>V^8<>dQhRS[R,RS[S[R,,RS[RS[RS[RS[RS[S[R,,/#r<>r<>)r@rAs"<22>r8rBrC<00>r<>r7c <0C><><00>V\V4,
pV'g
VR,#VRVpV'dV!RV,R,V4MV!RV,V4pV..V,V,pV#)a<>Aligns 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.
r<>Nrcrur<>r<>s&&&&&& r8<00> align_bottom<6F>Segment.align_bottom<6F>sf<00><00>*<1D>s<EFBFBD>5<EFBFBD>z<EFBFBD>)<29> <0B><1A><18><11>8<EFBFBD>O<EFBFBD><15>g<EFBFBD>v<EFBFBD><0E><05>2;<3B><03>C<EFBFBD>%<25>K<EFBFBD>$<24>&<26><05>.<2E><13>S<EFBFBD>5<EFBFBD>[<5B>RW<52>AX<41><05><17><17> <09>K<EFBFBD>'<27>%<25>/<2F><05><14> r7c<00><><<01>V^8<>dQhRS[R,RS[S[R,,RS[RS[RS[RS[RS[S[R,,/#r<>r<>)r@rAs"<22>r8rBrC se<00><><00><15><15> <11>)<29>_<EFBFBD><15><13>D<EFBFBD><19>O<EFBFBD>$<24><15><13><15><14> <15>
<15> <15> <18> <15>
<0E>d<EFBFBD>9<EFBFBD>o<EFBFBD> <1E>r7c <0C><00>V\V4,
pV'g
VR,#VRVpV'dV!RV,R,V4MV!RV,V4pV^,pWh,
p V..V,V,V..V ,,pV#)a<>Aligns 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.
r<>Nrcrur<>)
rfr<>r<>r<>rNr<>r<>r<><00> top_lines<65> bottom_liness
&&&&&& r8<00> align_middle<6C>Segment.align_middle
s<><00><00>*<1D>s<EFBFBD>5<EFBFBD>z<EFBFBD>)<29> <0B><1A><18><11>8<EFBFBD>O<EFBFBD><15>g<EFBFBD>v<EFBFBD><0E><05>2;<3B><03>C<EFBFBD>%<25>K<EFBFBD>$<24>&<26><05>.<2E><13>S<EFBFBD>5<EFBFBD>[<5B>RW<52>AX<41><05><1F>1<EFBFBD>$<24> <09>"<22>.<2E> <0C><17><17> <09>I<EFBFBD>%<25><05>-<2D>%<25><17> <09>L<EFBFBD>0H<30>H<><05><14> r7c<00>B<<01>V^8<>dQhRS[R,RS[R,/#r<><00>r
)r@rAs"<22>r8rBrC*s%<00><><00><1B><1B><08><19> 3<><1B><08><19>8K<38>r7c# <0C>L"<00>\V4p\V4p\pTFfpTPTP8XdCTP
'g1T!TP TP ,TP4pK`Tx<00>TpKh Tx<00>R# \dR#i;i5i)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)<07>iter<65>next<78> StopIterationr:rNrHrF)rfry<00> iter_segments<74> last_segmentrgr]s&& r8<00>simplify<66>Segment.simplify)s<><00><00><00><1D>X<EFBFBD><0E> <0A> <13><1F> <0A>.<2E>L<EFBFBD><1B><08>$<24>G<EFBFBD><1B>!<21>!<21>W<EFBFBD>]<5D>]<5D>2<>7<EFBFBD>?<3F>?<3F>?<3F>'<27> <20>%<25>%<25><07> <0C> <0C>4<>l<EFBFBD>6H<36>6H<36> <12> <0C>#<23>"<22>&<26> <0C>%<25><1B><1A><><1D> <13> <12> <13>s.<00> B$<01> B<00>7B$<01>AB$<01> B!<03>B$<01> B!<03>!B$c<00>B<<01>V^8<>dQhRS[R,RS[R,/#r<>r<>)r@rAs"<22>r8rBrCEs)<00><><00>L<01>L<01>8<EFBFBD>I<EFBFBD>#6<>L<01>8<EFBFBD>I<EFBFBD>;N<>Lr7c# <0C><>"<00>VFQpVP'gVPfVx<00>K)Vwr4pT!Y4'dVPR4MR4x<00>KS R#5i)z<>Remove all links from an iterable of styles.
Args:
segments (Iterable[Segment]): An iterable segments.
Yields:
Segment: Segments with link removed.
N)rHrN<00> update_link)rfryr]rFrN<00>_controls&& r8<00> strip_links<6B>Segment.strip_linksDsN<00><00><00> <20>G<EFBFBD><16><EFBFBD><EFBFBD><EFBFBD>'<27>-<2D>-<2D>"7<><1D> <0A>(/<2F>%<25><04>X<EFBFBD><19>$<24>5<EFBFBD><05> 1<> 1<>$<24> 7<>d<EFBFBD>K<>K<>  <20>s<00>AAc<00>B<<01>V^8<>dQhRS[R,RS[R,/#r<>r<>)r@rAs"<22>r8rBrCVs%<00><><00>
+<2B>
+<2B>H<EFBFBD>Y<EFBFBD>$7<>
+<2B>H<EFBFBD>Y<EFBFBD><O<>
+r7c# <0C>>"<00>VFwr#pV!VRV4x<00>K R#5i)z<>Remove all styles from an iterable of segments.
Args:
segments (Iterable[Segment]): An iterable segments.
Yields:
Segment: Segments with styles replace with None
Nr )rfryrFrGrHs&& r8<00> strip_styles<65>Segment.strip_stylesUs%<00><00><00>&.<2E> !<21>D<EFBFBD>'<27><15>d<EFBFBD>D<EFBFBD>'<27>*<2A> *<2A>&.<2E>s<00>c<00>B<<01>V^8<>dQhRS[R,RS[R,/#r<>r<>)r@rAs"<22>r8rBrCcs%<00><><00>/<2F>/<2F>H<EFBFBD>Y<EFBFBD>$7<>/<2F>H<EFBFBD>Y<EFBFBD><O<>/r7c# <0C><>"<00>/pVFLwr4pV'd3VPV4pVfVPpWbV&V!W6V4x<00>K@V!VRV4x<00>KN R#5i)z<>Remove all color from an iterable of segments.
Args:
segments (Iterable[Segment]): An iterable segments.
Yields:
Segment: Segments with colorless style.
N)<02>get<65> without_color)rfry<00>cacherFrNrH<00>colorless_styles&& r8<00> remove_color<6F>Segment.remove_colorbs`<00><00><00>%'<27><05>$,<2C> <20>D<EFBFBD><17><14>"'<27>)<29>)<29>E<EFBFBD>"2<><0F>"<22>*<2A>&+<2B>&9<>&9<>O<EFBFBD>#2<>%<25>L<EFBFBD><19>$<24><17>9<>9<><19>$<24><04>g<EFBFBD>.<2E>.<2E>%-<2D>s<00>AAc<00>h<<01>V^8<>dQhRS[R,RS[S[,RS[S[R,,/#)r=ryr:<00>cutsr>)r
r?r )r@rAs"<22>r8rBrCys<<00><><00>B<1E>B<1E><1F> <09>*<2A>B<1E>2:<3A>3<EFBFBD>-<2D>B<1E> <11>$<24>y<EFBFBD>/<2F> "<22>Br7c# <0C><>"<00>.pVPp\V4p\VR4pVR8XdR#V^8wdM.x<00>K$^pVPpVPp \
p
VF<>p V wr<>pV 'gKV'dTM Wz!V 4,pW<>8d V!V 4TpK<W<>8XdDV!V 4V !4x<00>V!4Tp\VR4pVR8XdV'd
V !4x<00>R#K<>V P Wg,
4wpp V wr<>pV!V4V !4x<00>V!4Tp\VR4pVR8XgK<>V'd
V !4x<00>R# V !4x<00>R#5i)z<>Divides 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.
Nrd)r<>r<>r<>r<><00>copyrrq)rfryr<><00>split_segments<74> add_segment<6E> iter_cutsr^ri<00>segments_clear<61> segments_copyr<79>r]rFrGrH<00>end_posrjs&&& r8<00>divide<64>Segment.dividexsV<00><00><00>+-<2D><0E>$<24>+<2B>+<2B> <0B><18><14>J<EFBFBD> <09><12><16>y<EFBFBD>"<22>%<25>C<EFBFBD><12>b<EFBFBD>y<EFBFBD><16><12>a<EFBFBD>x<EFBFBD><15><14>H<EFBFBD><0F><03>'<27>-<2D>-<2D><0E>&<26>+<2B>+<2B> <0A>#<23> <09><1F>G<EFBFBD>$+<2B> !<21>D<EFBFBD>'<27><16>$<24>!(<28>#<23>c<EFBFBD>I<EFBFBD>d<EFBFBD>O<EFBFBD>.C<><07><1A>=<3D><1F><07>(<28>!<21>C<EFBFBD><19><1A>><3E><1F><07>(<28>'<27>/<2F>)<29>"<22>$<24>!<21>C<EFBFBD><1E>y<EFBFBD>"<22>-<2D>C<EFBFBD><1A>b<EFBFBD>y<EFBFBD>)<29>"/<2F>/<2F>1<><1E><19>'.<2E>&9<>&9<>#<23>)<29>&D<>O<EFBFBD>F<EFBFBD>G<EFBFBD>,3<>)<29>D<EFBFBD>'<27><1F><06>'<27>'<27>/<2F>)<29>"<22>$<24><1D>C<EFBFBD><1A>9<EFBFBD>b<EFBFBD>)<29><03><16>"<22>9<EFBFBD>%<25>+<2B>o<EFBFBD>-<2D><1A>G <20>J<1C>o<EFBFBD><1D>s&<00>A-E<01>4E<01><AE<01>AE<01>5E<01>=Ec<00>n<<01>V^8<>dQh/S[;R&S[S[,;R&S[S[S[,,;R&#)r=rFrNrH)<05>strr rr<00> ControlCode)r@rAs"<22>r8rBrC?s9<00><><00><00> <0E>I<EFBFBD><01> <14>E<EFBFBD>?<3F>!<21><01> <16>h<EFBFBD>{<7B>+<2B> ,<2C>3<>!r7r i@)NN<4E>F)NTT)NT)NNF)%r!r"r#r$r%rNrH<00>propertyrIrPrVrZ<00> classmethodrrmrqrvr<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<00>__annotate_func__r6<00>__classdictcell__<5F>rAs@r8r:r:?s$<00><><00><00>
<08>"<22>E<EFBFBD>/3<>G<EFBFBD> <0A>0<><0E>0<><1F><1F><1F><1F><0E>(<28><0E>(<28><11><0E>y<EFBFBD><19>-<19><1A><11>-<19>^,<2C>,<2C>4<11><19><11><19><11>&<1F>&<1F><11>&<1F>P<11>@<01>@<01><11>@<01>$<11><17><11><17>8<11> <20><11> <20><<11>,I<01>,I<01><11>,I<01>\<11>*<18>*<18><11>*<18>X<11>
T<01><11>
T<01><11> '<27><11> '<27><11>!<1C>!<1C><11>!<1C>F<11><15><15><11><15>8<11><15><15><11><15>8<11><15><15><11><15><<11><1B><11><1B>4<11>L<01><11>L<01> <11>
+<2B><11>
+<2B><11>/<2F><11>/<2F>*<11>B<1E><11>B<1E>u<01>r7r:c<00>La<00>]tRtRtoRtR V3RlRlltV3RlRltRtVtR#)
<EFBFBD>Segmentsi<73>a)A simple renderable to render an iterable of segments. This class may be useful if
you want to print segments outside of a __rich_console__ method.
Args:
segments (Iterable[Segment]): An iterable of segments.
new_lines (bool, optional): Add new lines between segments. Defaults to False.
c<00>:<<01>V^8<>dQhRS[S[,RS[RR/#)r=ryr<>r>N)r
r:rT)r@rAs"<22>r8rB<00>Segments.__annotate__<5F>s(<00><><00>#<23>#<23><18>'<27>!2<>#<23>t<EFBFBD>#<23>PT<50>#r7c<08>2<00>\V4VnW nR#rM)<03>listryr<>)rEryr<>s&&&r8<00>__init__<5F>Segments.__init__<5F>s<00><00><1C>X<EFBFBD><0E><04> <0A>"<22>r7c<00>&<<01>V^8<>dQhRRRRRR/#<00>r=<00>consoler<00>optionsrr>rr )r@rAs"<22>r8rBr<00>s%<00><><00> %<25> %<25> <20> %<25>+;<3B> %<25> <17> %r7c#<08><>"<00>VP'd2\P4pVPF pVx<00>Vx<00>K R#VPRjx<01>L
R#L5irM)r<>r:rvry)rErrrvr]s&&& r8<00>__rich_console__<5F>Segments.__rich_console__<5F>sB<00><00><00> <10>><3E>><3E>><3E><1A><<3C><<3C>><3E>D<EFBFBD><1F>=<3D>=<3D><07><1D> <0A><1A>
<EFBFBD>)<29><1C>}<7D>}<7D> $<24> $<24>s<00>AA<01>A<04>A)r<>ryNr ) r!r"r#r$r%rrr6rrs@r8rr<00>s<00><><00><00><08>#<23>#<23> %<25> %r7rc<00>Ha<00>]tRtRtoRV3RlRlltV3RlRltRtVtR#) <09> SegmentLinesi<73>c<00>J<<01>V^8<>dQhRS[S[S[,,RS[RR/#)r=r<>r<>r>N)r
r r:rT)r@rAs"<22>r8rB<00>SegmentLines.__annotate__<5F>s,<00><><00> #<23> #<23>h<EFBFBD>t<EFBFBD>G<EFBFBD>}<7D>5<> #<23>$<24> #<23>SW<53> #r7c <0C>2<00>\V4VnW nR#)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)rr<>r<>)rEr<>r<>s&&&r8r<00>SegmentLines.__init__<5F>s<00><00><1A>%<25>[<5B><04>
<EFBFBD>"<22>r7c<00>&<<01>V^8<>dQhRRRRRR/#rr )r@rAs"<22>r8rBr#<00>s%<00><><00>
 <20>
 <20> <20>
 <20>+;<3B>
 <20> <17>
 r7c#<08><>"<00>VP'd8\P4pVPFpTRjx<01>L
Vx<00>K R#VPF pTRjx<01>L
K R#L-L 5irM)r<>r:rvr<>)rErrr<>rvs&&& r8r<00>SegmentLines.__rich_console__<5F>sV<00><00><00> <10>><3E>><3E>><3E><1E>|<7C>|<7C>~<7E>H<EFBFBD><1C>
<EFBFBD>
<EFBFBD><04><1F><0F><0F><1E><0E>#<23><1D>
<EFBFBD>
<EFBFBD><04><1F><0F><0F>#<23> <20> <20>s!<00>;A/<01>A+<06>"A/<01> A-<06>! A/<01>-A/)r<>r<>Nr )r!r"r#r$rrr6rrs@r8r!r!<00>s<00><><00><00> #<23> #<23>
 <20>
 r7r!<00>__main__)r)<01>Syntax)<01>Textz<74>from 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:
<EFBFBD>pythonT)<01> 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):<3A>enumr<00> functoolsr<00> itertoolsr<00>loggingr<00>operatorr<00>typingrr r
r r r rrrr<00>cellsrrrrr<00>reprrrrNrrrrr<00>logrr?r r
r:rr!r!<00> rich.console<6C> rich.syntaxr*<00> rich.textr+<00>code<64> from_markuprF<00>rule<6C>printr<00>render<65> fragmentsr r7r8<00><module>r@s<><00><01><18><1F>!<21><1D><1F> <02> <02> <02><02><02>$<24><18><10>><3E>><3E><0F><06><17><03><1A>'<27><1A>*<14> <09>+<2B><16> <09>+<2B>u<EFBFBD>S<EFBFBD>#<23>X<EFBFBD><EFBFBD>
&<26>'<27> <09>+<2B>s<EFBFBD>C<EFBFBD>
<1F> <20>"<22><02> <0B> <0B><1B>{ <1E>j<EFBFBD>{ <1E> <0A>{ <1E>|%<25>%<25>2 <20> <20>2 <0C>z<EFBFBD><19>$<24>"<22><1E> <17>D<EFBFBD>
<10> <1B> <1B><<3C> =<3D>D<EFBFBD><15>i<EFBFBD>G<EFBFBD> <0B>L<EFBFBD>L<EFBFBD><1E> <20> <0B>M<EFBFBD>M<EFBFBD>g<><06> <0C>M<EFBFBD>M<EFBFBD>4<>5<> <0B>M<EFBFBD>M<EFBFBD>&<26><14>x<EFBFBD>d<EFBFBD>;<3B><<3C> <0B>M<EFBFBD>M<EFBFBD>O<EFBFBD> <0B>M<EFBFBD>M<EFBFBD>]<5D><06><15>W<EFBFBD>^<5E>^<5E>D<EFBFBD>)<29>*<2A>I<EFBFBD> <0B>M<EFBFBD>M<EFBFBD>)<29><1C> <0B>M<EFBFBD>M<EFBFBD>O<EFBFBD> <0B>M<EFBFBD>M<EFBFBD>V<>W<> <0B>M<EFBFBD>M<EFBFBD>$<24><17> <0B>M<EFBFBD>M<EFBFBD>^<5E><06>;r7