Files
tamigo-cli/venv/lib/python3.12/site-packages/rich/__pycache__/segment.cpython-312.pyc

322 lines
29 KiB
Plaintext
Raw Normal View History

<EFBFBD>
<00><16>i<EFBFBD>d<00><00><><00>ddlmZddlmZddlmZddlmZddlm Z ddl
m Z m Z m Z mZmZmZmZmZmZmZddlmZmZmZmZmZdd lmZmZdd
lmZe r
dd l m!Z!m"Z"m#Z#ed <0C>Z$Gd <0A>de<01>Z%eee%ee%ee&e'ffee%e&e&ffZ(e<1D>Gd<0F>de<0F><00>Z)Gd<11>d<12>Z*Gd<13>d<14>Z+e,dk(<00>rddl-m!Z!ddl.m/Z/ddl0m1Z1dZ2e1jfd<1A>Z4e!<21>Z e jkd<1B>e jmd<1C>e jmd<1D>e jme/e2dd<1F> <20><00>e jm<00>e jmd!<21>e7e jqe4<65><00>Z9e jme9<65>e jm<00>e jmd"<22>e jme4<65>e jmd#<23>y$y$)%<25>)<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<6F>)<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>P<00>eZdZdZdZdZdZdZdZdZ dZ
d Z d
Z d Z d Zd ZdZdZdZdZy)<13> ControlTypezDNon-printable control codes which typically translate to ANSI codes.r<00><00><00><00><00><00><00><00> <00>
<00> <00> <00> <00><00><00>N)<14>__name__<5F>
__module__<EFBFBD> __qualname__<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><00><00>R/home/daniel/Projects/tamigo-cli/venv/lib/python3.12/site-packages/rich/segment.pyr r #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>rEr c<00><><00>eZdZUdZeed<dZeeed<dZ ee
e ed<e de fd<07><04>Zdefd<08>Zdefd <09>Ze defd
<EFBFBD><04>Zeed <0B>d dd e dedfd<0F><04><00>Zd e dedfd<10>Zed0d<11><04>Ze d1deddeedeededfd<14><05>Ze d2deddededfd<16><05>Zededdeedfd<17><04>Zededdeeedeffd<18><04>Ze d3dedde deedededeedf d<1C><05>Z e d4dedde deedededf
d<1E><05>Z!ededde fd<1F><04>Z"ed eeddee e ffd!<21><04>Z#e d5d eedd"e d#ee deed$edeedf d%<25><05>Z$e d2d&e%dd eedd"e d#e ded$edeedfd'<27><05>Z&e d2d&e%dd eedd"e d#e ded$edeedfd(<28><05>Z'e d2d&e%dd eedd"e d#e ded$edeedfd)<29><05>Z(ededdedfd*<2A><04>Z)ededdedfd+<2B><04>Z*ededdedfd,<2C><04>Z+ededdedfd-<2D><04>Z,ededd.ee deedfd/<2F><04>Z-y)6<>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.
<20>textN<74>style<6C>control<6F>returnc<00>,<00>|\}}}|rdSt|<01>S)zzThe number of terminal cells required to display self.text.
Returns:
int: A number of cells.
r)r)<04>selfrI<00>_stylerKs rF<00> cell_lengthzSegment.cell_lengthQs!<00><00>!%<25><1D><04>f<EFBFBD>g<EFBFBD><1B>q<EFBFBD>/<2F><18>$<24><1E>/rEc#<00><>K<00>|j<00><01>|j<00>|j<00>|j<00><01>yy|j<00><01>|j<00><01>y<00>w<01>N)rIrKrJ<00>rNs rF<00> __rich_repr__zSegment.__rich_repr__[sH<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>,<00>t|j<00>S)z#Check if the segment contains text.)<02>boolrIrSs rF<00>__bool__zSegment.__bool__ds<00><00><13>D<EFBFBD>I<EFBFBD>I<EFBFBD><EFBFBD>rEc<00><00>|jduS)z,Check if the segment contains control codes.N)rKrSs rF<00>
is_controlzSegment.is_controlhs<00><00><14>|<7C>|<7C>4<EFBFBD>'<27>'rEi@<00>segment<6E>cut)rHrHc<00><><00>|\}}}t}|j}||k\r ||d||<05>fSt}t||z t |<03>z<00>} |d| }
t |
<EFBFBD>} | |z
} | s||
||<05>||| d||<05>fS| dk(r1||| <00>dk(r#||d| dz||<05>|d|| dzdz||<05>fS| dk(r4||| dz
<00>dk(r#||d| dz
dz||<05>|d|| dz||<05>fS| |kr| dz } n| dz} <09><>)a\Split 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.
<20>N<><4E><EFBFBD><EFBFBD><EFBFBD>r!<00> r)rHrPr<00>int<6E>lenr) <0A>clsrZr[rIrJrK<00>_SegmentrP<00> cell_size<7A>pos<6F>before<72>cell_pos<6F>out_bys rF<00> _split_cellszSegment._split_cellsmss<00><00> '<27><1C><04>e<EFBFBD>W<EFBFBD><1A><08><1D>)<29>)<29> <0B> <0E>+<2B> <1D><1A>H<EFBFBD>R<EFBFBD><15><07>8<>8<> 8<>+<2B> <09><11>3<EFBFBD><1B>$<24><03>D<EFBFBD> <09>1<>2<><03><12><19>$<24>3<EFBFBD>Z<EFBFBD>F<EFBFBD><1F><06>'<27>H<EFBFBD><1D><03>^<5E>F<EFBFBD><19><1C>V<EFBFBD>U<EFBFBD>G<EFBFBD>4<><1C>T<EFBFBD>#<23>$<24>Z<EFBFBD><15><07>8<><12><12><16><12>|<7C> <09>$<24>s<EFBFBD>)<29> 4<><01> 9<><1C>T<EFBFBD>$<24>3<EFBFBD>Z<EFBFBD>#<23>-<2D>u<EFBFBD>g<EFBFBD>><3E><1C>S<EFBFBD>4<EFBFBD><03>a<EFBFBD><07> <09>?<3F>2<>E<EFBFBD>7<EFBFBD>C<><12><12><16><12>|<7C> <09>$<24>s<EFBFBD>Q<EFBFBD>w<EFBFBD>-<2D> 8<>A<EFBFBD> =<3D><1C>T<EFBFBD>)<29>C<EFBFBD>!<21>G<EFBFBD>_<EFBFBD>s<EFBFBD>2<>E<EFBFBD>7<EFBFBD>C<><1C>S<EFBFBD>4<EFBFBD><03><04>:<3A>-<2D>u<EFBFBD>g<EFBFBD>><3E><12><12><18>#<23>~<7E><13>q<EFBFBD><08><03><13>q<EFBFBD><08><03>-rEc<00><><00>|\}}}|dk\sJ<00>t|<02>r=|t|<02>k\r|td||<04>fSt|d|||<04>t||d||<04>fS|j||<01>S)axSplit 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.
rr]N)rrarHri)rNr[rIrJrKs rF<00> split_cellszSegment.split_cells<6C>s<><00><00> $<24><1C><04>e<EFBFBD>W<EFBFBD><12>a<EFBFBD>x<EFBFBD><0F>x<EFBFBD> !<21>$<24> '<27><12>c<EFBFBD>$<24>i<EFBFBD><1F><1B>W<EFBFBD>R<EFBFBD><15><07>8<>8<>8<><17><04>T<EFBFBD>c<EFBFBD>
<EFBFBD>E<EFBFBD>7<EFBFBD>3<><17><04>S<EFBFBD>T<EFBFBD>
<EFBFBD>E<EFBFBD>7<EFBFBD>3<><0E> <0E>
<14> <20> <20><14>s<EFBFBD>+<2B>+rEc<00><00>|d<01>S)zMake a new line segment.<2E>
rD)rbs rF<00>linez Segment.line<6E>s<00><00><13>4<EFBFBD>y<EFBFBD>rE<00>segments<74>
post_stylec<00>`<00><00><03><05>|}|r|j<00><05><05>fd<01>|D<00>}<04>r <0C><00>fd<02>|D<00>}|S)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).
c3<00>N<00>K<00>|]\}}}<00>||rdn<00>|<02>|<03><00><01><00>y<00>wrRrD)<06>.0rIrOrK<00>applyrbs <20><>rF<00> <genexpr>z&Segment.apply_style.<locals>.<genexpr><3E>s0<00><><00><><00><0E>)<29>D<EFBFBD>&<26>'<27><14>D<EFBFBD>'<27>$<24>u<EFBFBD>V<EFBFBD>}<7D>g<EFBFBD>F<><0E>s<00>"%c3<00>P<00>K<00>|]\}}}<00>||rdn|r|<02>zn<01>|<03><00><01><00>y<00>wrRrD)rsrIrOrKrbrps <20><>rFruz&Segment.apply_style.<locals>.<genexpr><3E>sB<00><><00><><00> <0E>*<2A>D<EFBFBD>&<26>'<27><14><18>#<23><1D>5;<3B>f<EFBFBD>z<EFBFBD>1<><1A><1B><12> <0E>s<00>#&)<01>__add__)rbrorJrp<00>result_segmentsrts` ` @rF<00> apply_stylezSegment.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>rErYc<00>Z<00>|rttd<01>|<01>Sttd<01>|<01>S)a2Filter 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.
rK)<03>filterrr)rbrorYs rF<00>filter_controlzSegment.filter_control<6F>s+<00><00> <16><19>*<2A>Y<EFBFBD>/<2F><18>:<3A> :<3A><1E>z<EFBFBD>)<29>4<>h<EFBFBD>?<3F> ?rEc#<00>K<00>g}|j}|D]k}d|jvrS|jsG|\}}}|s<01>&|jd<01>\}} }|r||||<06><00>| r|<02><01>g}|j}|r<01>=<3D>d||<04><00>m|r|<02><01>yy<02>w)aSplit 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.
rmN<><04>appendrIrK<00> partition<6F>
rbrornrrZrIrJ<00>_<>_text<78>new_lines
rF<00> split_lineszSegment.split_lines<65>s<><00><00><><00>!<21><04><15><1B><1B><06><1F> <20>G<EFBFBD><13>w<EFBFBD>|<7C>|<7C>#<23>G<EFBFBD>O<EFBFBD>O<EFBFBD>!(<28><0E><04>e<EFBFBD>Q<EFBFBD><1A>,0<>N<EFBFBD>N<EFBFBD>4<EFBFBD>,@<40>)<29>E<EFBFBD>8<EFBFBD>T<EFBFBD><1C><1E>s<EFBFBD>5<EFBFBD>%<25>0<>1<><1F>"<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>6B c#<00>K<00>g}|j}|D]m}d|jvrU|jsI|\}}}|s<01>&|jd<01>\}} }|r||||<06><00>| r|df<02><01>g}|j}|r<01>?<3F>f||<04><00>o|r|df<02><01>yy<04>w)a2Split 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.
rmTFNr~r<>s
rF<00>split_lines_terminatorzSegment.split_lines_terminators<><00><00><><00>!<21><04><15><1B><1B><06><1F> <20>G<EFBFBD><13>w<EFBFBD>|<7C>|<7C>#<23>G<EFBFBD>O<EFBFBD>O<EFBFBD>!(<28><0E><04>e<EFBFBD>Q<EFBFBD><1A>,0<>N<EFBFBD>N<EFBFBD>4<EFBFBD>,@<40>)<29>E<EFBFBD>8<EFBFBD>T<EFBFBD><1C><1E>s<EFBFBD>5<EFBFBD>%<25>0<>1<><1F>#<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>6B <01>>B <01>8B <01>length<74>pad<61>include_new_linesc#<00><>K<00>g}|j}|j}|d<01>} |D]<5D>}
d|
jvrt|
jsh|
\} } } | s<01>&| j d<01>\}}} |r|||| <0C><00>|r3|||||<04><02>}|r|j| <09>|<10><01>|j <00>| r<01>^<5E><>||
<EFBFBD><00><>|r|||||<04><02><00><01>yy<03>w)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.
rm)rJr<>N)r<00>adjust_line_lengthrIrKr<><00>clear)rbror<>rJr<>r<>rnrr<><00>new_line_segmentrZrI<00> segment_styler<65>r<>r<><00> cropped_lines rF<00>split_and_crop_lineszSegment.split_and_crop_lines5s<><00><00><><00>*!<21><04><15><1B><1B><06> <20>3<>3<><1A><1E>t<EFBFBD>9<EFBFBD><18><1F> <20>G<EFBFBD><13>w<EFBFBD>|<7C>|<7C>#<23>G<EFBFBD>O<EFBFBD>O<EFBFBD>)0<>&<26><04>m<EFBFBD>Q<EFBFBD><1A>,0<>N<EFBFBD>N<EFBFBD>4<EFBFBD>,@<40>)<29>E<EFBFBD>8<EFBFBD>T<EFBFBD><1C><1E>s<EFBFBD>5<EFBFBD>-<2D>8<>9<><1F>'9<> <20>&<26><05>3<EFBFBD>(<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>6<EFBFBD><15>C<EFBFBD>H<> H<> <10>s<00>A
C<01> AC<01>+Crnc<00>^<00>td<01>|D<00><00>}||kr|r||d||z
z|<03>gz}|S|dd}|S||kDrmg}|j}d}|D]V}|j} || z|ks |jr||<08>|| z }<05>1|\}
} } t |
||z
<00>}
|||
| <0B><00>|S|S|dd}|S)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.
c3<00>4K<00>|]}|j<00><01><00>y<00>wrR)rP)rsrZs rFruz-Segment.adjust_line_length.<locals>.<genexpr>ws<00><00><><00>B<>'<27>'<27>-<2D>-<2D>B<>s<00>r_Nr)<05>sumrrPrKr) rbrnr<>rJr<><00> line_lengthr<68>rrZ<00>segment_lengthrIr<>r<>s rFr<>zSegment.adjust_line_lengthds<00><00>&<1A>B<>T<EFBFBD>B<>B<> <0B> <17><16> <1F><12><1F>3<EFBFBD>s<EFBFBD>f<EFBFBD>{<7B>.B<>'C<>U<EFBFBD>#K<>"L<>L<><08>&<18><0F># <20><01>7<EFBFBD><08>"<18><0F>!<19>6<EFBFBD> !<21><19>H<EFBFBD><1D>_<EFBFBD>_<EFBFBD>F<EFBFBD><1B>K<EFBFBD><1F> <1A><07>!(<28>!4<>!4<><0E><1E><1E>/<2F>&<26>8<>G<EFBFBD>O<EFBFBD>O<EFBFBD><1A>7<EFBFBD>O<EFBFBD><1F>><3E>1<>K<EFBFBD>-4<>*<2A>D<EFBFBD>-<2D><11>(<28><14>v<EFBFBD> <0B>/C<>D<>D<EFBFBD><1A>3<EFBFBD>t<EFBFBD>]<5D>3<>4<><19><18><0F> <1A><18><0F><1C>A<EFBFBD>w<EFBFBD>H<EFBFBD><17>rEc<00>8<00><02>t<00>t<00>fd<01>|D<00><00>S)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><<00>K<00>|]\}}}|r<01>
<00>|<01><00><01><00>y<00>wrRrD)rsrIrJrK<00> _cell_lens <20>rFruz*Segment.get_line_length.<locals>.<genexpr><3E>s<00><><00><><00>S<>';<3B>t<EFBFBD>U<EFBFBD>G<EFBFBD>7<EFBFBD>9<EFBFBD>T<EFBFBD>?<3F>S<>s<00> <01> )rr<>)rbrnr<>s @rF<00>get_line_lengthzSegment.get_line_length<74>s<00><><00><1D> <09><12>S<>t<EFBFBD>S<>S<>SrE<00>linesc<00>f<00><03>|j<00>|rt<00>fd<01>|D<00><00>nd}|t|<01>fS)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>.<00>K<00>|] }<00>|<01><00><01><00>y<00>wrRrD)rsrnr<>s <20>rFruz$Segment.get_shape.<locals>.<genexpr><3E>s<00><><00><><00>@<40>$<24><0F><04>-<2D>@<40>s<00>r)r<><00>maxra)rbr<><00> max_widthr<68>s @rF<00> get_shapezSegment.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>&rE<00>width<74>height<68> new_linesc<00>$<00>|xs t|<01>}|r|d|zdz|<04>gn |d|z|<04>g}|j}|d|} |D<00>
cgc] }
||
||<04><04><00><02>c}
| ddt| <09>|kr!| j|g|t| <09>z
z<00>| Scc}
w)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.
r_rmN)rJ)rar<><00>extend) rbr<>r<>r<>rJr<><00>_height<68>blankr<6B><00> shaped_linesrns rF<00> set_shapezSegment.set_shape<70>s<><00><00>*<19>&<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>=A<> <1E>t<EFBFBD>U<EFBFBD>%<25> 8<>
<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 rbc<00><><00>|t|<01>z
}|s|ddS|d|}|r|d|zdz|<04>n |d|z|<04>}||gg|zz}|S)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.
Nr_rm<00>ra<00>rbr<>r<>r<>rJr<><00> extra_linesr<73>s rF<00> align_topzSegment.align_top<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><15>%<25><17> <09>K<EFBFBD>/<2F>/<2F><05><14> rEc<00><><00>|t|<01>z
}|s|ddS|d|}|r|d|zdz|<04>n |d|z|<04>}|gg|z|z}|S)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.
Nr_rmr<>r<>s rF<00> align_bottomzSegment.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> rEc<00><><00>|t|<01>z
}|s|ddS|d|}|r|d|zdz|<04>n |d|z|<04>}|dz}||z
} |gg|z|z|gg| zz}|S)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.
Nr_rmr!r<>)
rbr<>r<>r<>rJr<>r<>r<><00> top_lines<65> bottom_liness
rF<00> align_middlezSegment.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>Y<EFBFBD>.<2E> <0C><17><17> <09>I<EFBFBD>%<25><05>-<2D>%<25><17> <09>L<EFBFBD>0H<30>H<><05><14> rEc#<00>&K<00>t|<01>} t|<02>}t}|D]X}|j|jk(r7|j
s+||j |j z|j<00>}<03>S|<03><01>|}<03>Z|<03><01>y#t$rYywxYw<01>w)a)Simplify 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> StopIterationrHrJrKrI)rbro<00> iter_segments<74> last_segmentrcrZs rF<00>simplifyzSegment.simplify)s<><00><00><><00><1D>X<EFBFBD><0E> <0A> <13><1F> <0A>.<2E>L<EFBFBD><1B><08>$<24> '<27>G<EFBFBD><1B>!<21>!<21>W<EFBFBD>]<5D>]<5D>2<>7<EFBFBD>?<3F>?<3F>'<27> <20>%<25>%<25><07> <0C> <0C>4<>l<EFBFBD>6H<36>6H<36> <12> <0C>#<23>"<22>&<26> <0C> '<27><1B><1A><><1D> <13> <12> <13>s(<00> B<01> B<00>A(B<01> B<03> B<01> B<03>Bc#<00><>K<00>|D]C}|js |j<00>|<02><01><00> |\}}}|||r|jd<01>nd<01><00><01><00>Ey<01>w)z<>Remove all links from an iterable of styles.
Args:
segments (Iterable[Segment]): An iterable segments.
Yields:
Segment: Segments with link removed.
N)rKrJ<00> update_link)rbrorZrIrJ<00>_controls rF<00> strip_linkszSegment.strip_linksDsV<00><00><><00> <20> L<01>G<EFBFBD><16><EFBFBD><EFBFBD>'<27>-<2D>-<2D>"7<><1D> <0A>(/<2F>%<25><04>e<EFBFBD>X<EFBFBD><19>$<24>5<EFBFBD><05> 1<> 1<>$<24> 7<>d<EFBFBD>K<>K<>  L<01>s<00>A
A c#<00>:K<00>|D]\}}}||d|<04><00><01><00>y<01>w)z<>Remove all styles from an iterable of segments.
Args:
segments (Iterable[Segment]): An iterable segments.
Yields:
Segment: Segments with styles replace with None
NrD)rbrorIrOrKs rF<00> strip_styleszSegment.strip_stylesUs-<00><00><><00>&.<2E> +<2B> !<21>D<EFBFBD>&<26>'<27><15>d<EFBFBD>D<EFBFBD>'<27>*<2A> *<2A> +<2B>s<00>c#<00><>K<00>i}|D]E\}}}|r1|j|<04>}|<06>|j}|||<||||<05><00><01><00>:||d|<05><00><01><00>Gy<01>w)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)rbro<00>cacherIrJrK<00>colorless_styles rF<00> remove_colorzSegment.remove_colorbsl<00><00><><00>%'<27><05>$,<2C> /<2F> <20>D<EFBFBD>%<25><17><14>"'<27>)<29>)<29>E<EFBFBD>"2<><0F>"<22>*<2A>&+<2B>&9<>&9<>O<EFBFBD>#2<>E<EFBFBD>%<25>L<EFBFBD><19>$<24><0F><17>9<>9<><19>$<24><04>g<EFBFBD>.<2E>.<2E> /<2F>s<00>AA<01>cutsc#<00>VK<00>g}|j}t|<02>} t|d<01>}|dk(ry|dk7rng<00><01><00>d}|j}|j} t
}
|D]<5D>} | \} } }| s<01> |r|n
||
| <0C>z}||kr || <0B>|}<07>+||k(r9|| <0B>| <09><00><01>|<08>|}t|d<01>}|dk(r |r | <09><00><01>y<02>i| j ||z
<00>\}} | \} } }||<10>| <09><00><01>|<08>|}t|d<01>}|dk(r |r | <09><00><01>y| r<01><><EFBFBD><EFBFBD>| <09><00><01>y<02>w)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.
r^Nr)rr<>r<>r<><00>copyrrk)rbror<><00>split_segments<74> add_segment<6E> iter_cutsr[re<00>segments_clear<61> segments_copyr<79>rZrIrOrK<00>end_posrfs rF<00>dividezSegment.dividexsp<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> <13><10><03>'<27>-<2D>-<2D><0E>&<26>+<2B>+<2B> <0A>#<23> <09><1F># <1B>G<EFBFBD>$+<2B> !<21>D<EFBFBD>&<26>'<27><16>!(<28>#<23>c<EFBFBD>I<EFBFBD>d<EFBFBD>O<EFBFBD>.C<><07><1A>S<EFBFBD>=<3D><1F><07>(<28>!<21>C<EFBFBD><19><1A>c<EFBFBD>><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><03>)<29>&D<>O<EFBFBD>F<EFBFBD>G<EFBFBD>,3<>)<29>D<EFBFBD>&<26>'<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>C<17># <1B>J<1C>o<EFBFBD><1D>s<00>A%D)<01>(B4D)<01> D))rLrH)NN<4E>F)NTT)NT)NNF).r0r1r2r3<00>str<74>__annotations__rJr rrKr<00> ControlCode<64>propertyr`rPrrTrVrWrY<00> classmethodrrrirkrnr
ryr|r r<>r<>r<>r<>r<>r<>r<>rr<>r<>r<>r<>r<>r<>r<>r<>rDrErFrHrH?s<><00><00>
<08> <0E>I<EFBFBD>!<21>E<EFBFBD>8<EFBFBD>E<EFBFBD>?<3F>!<21>/3<>G<EFBFBD>X<EFBFBD>h<EFBFBD>{<7B>+<2B> ,<2C>3<> <0A>0<>S<EFBFBD>0<><0E>0<><1F>v<EFBFBD><1F><1F>$<24><1F><0E>(<28>D<EFBFBD>(<28><0E>(<28><11><0E>y<EFBFBD><19>-<19>9<EFBFBD>-<19>3<EFBFBD>-<19>5<EFBFBD>AU<41>;V<>-<19><1A><11>-<19>^,<2C>s<EFBFBD>,<2C>u<EFBFBD>-A<>'B<>,<2C>4<11><19><11><19><11>"&<26>&*<2A> &<1F><1A>9<EFBFBD>%<25>&<1F><18><05><EFBFBD>&<1F><1D>U<EFBFBD>O<EFBFBD> &<1F>
<12>)<29> <1C> &<1F><11>&<1F>P<11>?D<>@<01><1F> <09>*<2A>@<01>8<<3C>@<01> <11>)<29> <1C>@<01><11>@<01>$<11><17>8<EFBFBD>I<EFBFBD>#6<><17>8<EFBFBD>D<EFBFBD><19>O<EFBFBD>;T<><17><11><17>8<11> <20><1F> <09>*<2A> <20> <11>%<25><04>Y<EFBFBD><0F><14>-<2D>.<2E> /<2F> <20><11> <20><<11>
"&<26><18>"&<26> ,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>,I<01><11>,I<01>\<11>
"&<26><18> *<18><12>9<EFBFBD>o<EFBFBD>*<18><14>*<18><18><05><EFBFBD> *<18>
<12> *<18>
<0E>i<EFBFBD><1F> *<18><11>*<18>X<11>
T<01>4<EFBFBD> <09>?<3F>
T<01>s<EFBFBD>
T<01><11>
T<01><11> '<27>d<EFBFBD>4<EFBFBD> <09>?<3F>3<> '<27><05>c<EFBFBD>3<EFBFBD>h<EFBFBD><0F> '<27><11> '<27><11>
!%<25>!%<25><1F> !<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>!<1C><11>!<1C>F<11> <20> <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><15><11><15>8<11> <20> <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><15><11><15>8<11> <20> <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><15><11><15><<11><1B><08><19> 3<><1B><08><19>8K<38><1B><11><1B>4<11>L<01>8<EFBFBD>I<EFBFBD>#6<>L<01>8<EFBFBD>I<EFBFBD>;N<>L<01><11>L<01> <11>
+<2B>H<EFBFBD>Y<EFBFBD>$7<>
+<2B>H<EFBFBD>Y<EFBFBD><O<>
+<2B><11>
+<2B><11>/<2F>H<EFBFBD>Y<EFBFBD>$7<>/<2F>H<EFBFBD>Y<EFBFBD><O<>/<2F><11>/<2F>*<11>B<1E><1F> <09>*<2A>B<1E>2:<3A>3<EFBFBD>-<2D>B<1E> <11>$<24>y<EFBFBD>/<2F> "<22>B<1E><11>BrErHc<00>@<00>eZdZdZddeededdfd<06>Z d d<07>Zy)
<EFBFBD>Segmentsa=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.
ror<>rLNc<00>2<00>t|<01>|_||_yrR)<03>listror<>)rNror<>s rF<00>__init__zSegments.__init__<5F>s<00><00><1C>X<EFBFBD><0E><04> <0A>"<22><04>rEc#<00><>K<00>|jr.tj<00>}|jD]
}|<04><01>|<03><01><00> y|jEd{<00><02><02>y7<00><05>wrR)r<>rHrnro)rN<00>console<6C>optionsrnrZs rF<00>__rich_console__zSegments.__rich_console__<5F>sF<00><00><><00> <10>><3E>><3E><1A><<3C><<3C>><3E>D<EFBFBD><1F>=<3D>=<3D> <1B><07><1D> <0A><1A>
<EFBFBD> <1B><1C>}<7D>}<7D> $<24> $<24>s<00>A
A<01> A<04> Ar<><00>r<>rr<>rrLr) r0r1r2r3r
rHrVr<>r<>rDrErFr<>r<><00>sD<00><00><08>#<23><18>'<27>!2<>#<23>t<EFBFBD>#<23>PT<50>#<23> %<25> <20> %<25>+;<3B> %<25> <17> %rEr<>c<00>B<00>eZdZddeeededdfd<05>Z dd<06>Zy) <09> SegmentLinesr<73>r<>rLNc<00>2<00>t|<01>|_||_y)a=A 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)r<>r<>r<>)rNr<>r<>s rFr<>zSegmentLines.__init__<5F>s<00><00><1A>%<25>[<5B><04>
<EFBFBD>"<22><04>rEc#<00><>K<00>|jr4tj<00>}|jD]}|Ed{<00><02><02>|<03><01><00>y|jD] }|Ed{<00><02><02><00>y7<00>'7<00> <09>wrR)r<>rHrnr<>)rNr<>r<>r<>rns rFr<>zSegmentLines.__rich_console__<5F>s`<00><00><><00> <10>><3E>><3E><1E>|<7C>|<7C>~<7E>H<EFBFBD><1C>
<EFBFBD>
<EFBFBD> <1F><04><1F><0F><0F><1E><0E> <1F><1D>
<EFBFBD>
<EFBFBD> <20><04><1F><0F><0F> <20> <20><> <20>s!<00>5A#<01>A<06>A#<01>A!<06>A#<01>!A#r<>r<>) r0r1r2r
r rHrVr<>r<>rDrErFr<>r<><00>sC<00><00> #<23>h<EFBFBD>t<EFBFBD>G<EFBFBD>}<7D>5<> #<23>$<24> #<23>SW<53> #<23>
 <20> <20>
 <20>+;<3B>
 <20> <17>
 rEr<><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>reprrrrJrr<>rrr<00>logr r`r<>r<>rHr<>r<>r0<00> rich.console<6C> rich.syntaxr<78><00> rich.textr<74><00>code<64> from_markuprI<00>rule<6C>printr<74><00>render<65> fragmentsrDrErF<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>
<1C>4<EFBFBD> <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>;rE