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

138 lines
11 KiB
Plaintext
Raw Normal View History

<EFBFBD>
<00><16>i/0<00><01><><00>UddlmZddlmZddlmZddlmZmZm Z m
Z
ddl m Z e
eeefZed<06>Zgd<07>Zded <eeD<00><00><01>cgc]\}}eee||d
z<00><00>D]}|<02><03><00>!c}}}<00>Zej0Zd ed <Gd <0A>de<08>Zed<0F><10>ddd<11><05>Zed<0F>ddd<12><05>Zddd<13>Zdd<14>Z d dd<15>Z d dd<16>Z d dd<17>Z!dd d<18>Z"dd!d<19>Z#ycc}}}w)"<22>)<01> annotations)<01> lru_cache)<01>
itemgetter)<04>Callable<6C>
NamedTuple<EFBFBD>Sequence<63>Tuple)<01>load<61>))<02> <00>~)<02><><00><>)<02><>i<>)ipi<>)i%i<>%)i(i<>(zlist[tuple[int, int]]<5D>_SINGLE_CELL_UNICODE_RANGES<45>zCallable[[str], bool]<5D>_is_single_cell_widthsc<01>0<00>eZdZUdZded<ded<ded<y) <09> CellTablezDContains unicode data required to measure the cell widths of glyphs.<2E>str<74>unicode_versionzSequence[tuple[int, int, int]]<5D>widthszfrozenset[str]<5D>narrow_to_wideN)<05>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__<5F>__annotations__<5F><00><00>P/home/daniel/Projects/tamigo-cli/venv/lib/python3.12/site-packages/rich/cells.pyrr&s<00><00>N<><18><18> *<2A>*<2A>"<22>"r ri)<01>maxsizec<01><00>t|<00>}|r|dksd|cxkrdkrynyt|<01>j}|d}||dkDryd}t|<03>dz
}||kr/||zdz }||\}} }
||kr|dz
}n || kDr|dz}n|
S||kr<01>/y)aGet the cell size of a character.
Args:
character (str): A single character.
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
Returns:
int: Number of cells (0, 1 or 2) occupied by that character.
r <00>rr<00><><EFBFBD><EFBFBD><EFBFBD>r)<04>ord<72>load_cell_tabler<00>len) <0B> characterr<00> codepoint<6E>table<6C>
last_entry<EFBFBD> lower_bound<6E> upper_bound<6E>index<65>start<72>end<6E>widths r!<00>get_character_cell_sizer3.s<><00><00><14>I<EFBFBD><0E>I<EFBFBD><10>Y<EFBFBD><12>^<5E>u<EFBFBD> <09>'A<>E<EFBFBD>'A<><10>(B<01><10> <1B>O<EFBFBD> ,<2C> 3<> 3<>E<EFBFBD><16>r<EFBFBD><19>J<EFBFBD><10>:<3A>a<EFBFBD>=<3D> <20><10><13>K<EFBFBD><15>e<EFBFBD>*<2A>q<EFBFBD>.<2E>K<EFBFBD>
<15><1B>
$<24><1C>{<7B>*<2A>q<EFBFBD>0<><05>!<21>%<25>L<EFBFBD><19><05>s<EFBFBD>E<EFBFBD> <14>u<EFBFBD> <1C><1F>!<21>)<29>K<EFBFBD> <16><13>_<EFBFBD><1F>!<21>)<29>K<EFBFBD><18>L<EFBFBD> <16><1B>
$<24> r c<01><00>t||<01>S)a<>Get the number of cells required to display text.
This method always caches, which may use up a lot of memory. It is recommended to use
`cell_len` over this method.
Args:
text (str): Text to display.
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
Returns:
int: Get the number of cells required to display text.
)<01> _cell_len<65><02>textrs r!<00>cached_cell_lenr8Qs<00><00> <15>T<EFBFBD>?<3F> +<2B>+r c<01>N<00>t|<00>dkr t||<01>St||<01>S)<02> Get the cell length of a string (length as it appears in the terminal).
Args:
text: String to measure.
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
Returns:
Length of string in terminal cells.
i)r(r8r5r6s r!<00>cell_lenr;bs)<00><00> <0B>4<EFBFBD>y<EFBFBD>3<EFBFBD><EFBFBD><1E>t<EFBFBD>_<EFBFBD>5<>5<> <14>T<EFBFBD>?<3F> +<2B>+r c<01>J<00><01>t|<00>r t|<00>Sd|vrd|vrt<00>fd<03>|D<00><00>St<00><01>}d}d}ddh}d}t|<00>}||krJ||}||vr!|dk(r|dz }n+|r)|||jvz }d}nt |<08><01>x} r|}|| z }|dz }||kr<01>J|S)r:<00><>c3<01>6<00>K<00>|]}t|<01><02><00><01><00>y<00>w)N)r3)<03>.0r)rs <20>r!<00> <genexpr>z_cell_len.<locals>.<genexpr><3E>s<00><><00><><00>
<EFBFBD>DM<EFBFBD> #<23>I<EFBFBD><EFBFBD> ?<3F>
<EFBFBD>s<00>rNr)rr(<00>sumr'rr3)
r7r<00>
cell_table<EFBFBD> total_width<74>last_measured_character<65>SPECIALr/<00>character_countr)<00>character_widths
` r!r5r5qs<><00><><00><1E>d<EFBFBD>#<23><12>4<EFBFBD>y<EFBFBD><18><10>t<EFBFBD><1B><08><04> 4<><12>
<EFBFBD>QU<EFBFBD>
<EFBFBD>
<EFBFBD>
<EFBFBD>!<21><1F>1<>J<EFBFBD><13>K<EFBFBD>*.<2E><1B><17><18>"<22>G<EFBFBD> <0A>E<EFBFBD><19>$<24>i<EFBFBD>O<EFBFBD>
<0F>/<2F>
!<21><18><15>K<EFBFBD> <09> <14><07> <1F><18>H<EFBFBD>$<24><15><11>
<EFBFBD><05>(<28><1B>6<>*<2A>:S<>:S<>S<>S<> <0B>*.<2E>'<27>"9<>)<29>_<EFBFBD>"U<>U<><EFBFBD>U<>*3<>'<27><1B><EFBFBD>.<2E> <0B> <0A><11>
<EFBFBD><05> <10>/<2F>
!<21> <17>r c<01>F<00>t|<01>}t|<00>}d}d}d}g}ddh}||kr<>||x} |vr<>|s|j||dzx}df<03><00>*| dk(r!|||dz
krdndz }|d\}
} } |
|| f|d<nD|dz }|r,|d\}
} } ||jvr d}| dz } |dz }|
|| f|d<n|d\}
} } |
|| f|d<<00><>t | |<01>x} r!| }|j||dzx}| f<03>|| z }n2|r|d\}
} } |
|dzx}| f|d<n|j||dzx}df<03>||kr<01><>||fS)aTDivide text into spans that define a single grapheme, and additionally return the cell length of the whole string.
The returned spans will cover every index in the string, with no gaps. It is possible for some graphemes to have a cell length of zero.
This can occur for nonsense strings like two zero width joiners, or for control codes that don't contribute to the grapheme size.
Args:
text: String to split.
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
Returns:
A tuple of a list of *spans* and the cell length of the entire string. A span is a list of tuples
of three values consisting of (<START>, <END>, <CELL LENGTH>), where START and END are string indices,
and CELL LENGTH is the cell length of the single grapheme.
rNr=r>rr r%)r'r(<00>appendrr3)r7rrC<00>codepoint_countr/rErD<00>spansrFr)r0<00>_end<6E> cell_lengthrHs r!<00>split_graphemesrO<00>s<><00><00>$!<21><1F>1<>J<EFBFBD><19>$<24>i<EFBFBD>O<EFBFBD> <0A>E<EFBFBD>*.<2E><1B><13>K<EFBFBD>(*<2A>E<EFBFBD><17><18>"<22>G<EFBFBD>
<0F>/<2F>
!<21><1D>e<EFBFBD><1B> $<24>I<EFBFBD><17> 0<><18><16> <0C> <0C>e<EFBFBD>e<EFBFBD>a<EFBFBD>i<EFBFBD>%7<>U<EFBFBD><11>;<3B><<3C><18><18>H<EFBFBD>$<24><16>e<EFBFBD><EFBFBD><11>':<3A>;<3B><11><11>B<><05>+0<><12>9<EFBFBD>(<28><05>t<EFBFBD>[<5B>"<22>E<EFBFBD>;<3B>7<><05>b<EFBFBD> <09><16><11>
<EFBFBD><05>*<2A>/4<>R<EFBFBD>y<EFBFBD>,<2C>E<EFBFBD>4<EFBFBD><1B>.<2E>*<2A>2K<32>2K<32>K<>26<32>/<2F>#<23>q<EFBFBD>(<28> <0B>#<23>q<EFBFBD>(<28> <0B>!&<26><05>{<7B> ;<3B>E<EFBFBD>"<22>I<EFBFBD>
05<30>R<EFBFBD>y<EFBFBD>,<2C>E<EFBFBD>4<EFBFBD><1B>!&<26><05>{<7B> ;<3B>E<EFBFBD>"<22>I<EFBFBD> <14>5<>i<EFBFBD><1F>Q<> Q<>?<3F> Q<>&/<2F> #<23> <11>L<EFBFBD>L<EFBFBD>%<25>%<25>!<21>)<29>!3<><15>_<EFBFBD>E<> F<> <17>?<3F> *<2A>K<EFBFBD><15>+0<><12>9<EFBFBD>(<28><05>t<EFBFBD>[<5B>"<22>U<EFBFBD>Q<EFBFBD>Y<EFBFBD>$6<>E<EFBFBD> <0B>D<><05>b<EFBFBD> <09><16> <0C> <0C>e<EFBFBD>e<EFBFBD>a<EFBFBD>i<EFBFBD>%7<>U<EFBFBD><11>;<3B><<3C>W <10>/<2F>
!<21>Z <12>;<3B> <1F>r c<01><><00>|dkrd|fSt||<02>\}}t||z t|<03>z<00>}tt t
|d|<00><00>} ||k(r$|t|<03>k\r|dfS||d}|d|||dfS||kr,||\}} }
||
z|kDr|d|dzd|| dzfS|dz }||
z }n.||dz
\}} }
||
z
|kr|d|dzd|| dzfS|dz}||
z}<06><>)<06>pSplit text by cell position.
If the cell position falls within a double width character, it is converted to two spaces.
Args:
text: Text to split.
cell_position Offset in cells.
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
Returns:
Tuple to two split strings.
r<00>N<> r)rO<00>intr(rB<00>map<61>_span_get_cell_len) r7<00> cell_positionrrLrN<00>offset<65> left_size<7A> split_indexr0r1<00> cell_sizes r!<00> _split_textr\<00>sS<00><00><15><01><19><11>4<EFBFBD>x<EFBFBD><0F>(<28><14><EFBFBD>?<3F><16>E<EFBFBD>;<3B><11>-<2D>+<2B>-<2D><13>U<EFBFBD><1A>;<3B> <<3C>F<EFBFBD><13>C<EFBFBD>*<2A>E<EFBFBD>'<27>6<EFBFBD>N<EFBFBD>;<3B><<3C>I<EFBFBD>
<0E> <14> <0A> %<25><15><13>U<EFBFBD><1A>#<23><1B>R<EFBFBD>x<EFBFBD><0F><1F><06>-<2D><01>*<2A>K<EFBFBD><17> <0C><1B>%<25>t<EFBFBD>K<EFBFBD>L<EFBFBD>'9<>9<> 9<> <14>}<7D> $<24>$)<29>&<26>M<EFBFBD> !<21>E<EFBFBD>3<EFBFBD> <09><18>9<EFBFBD>$<24>}<7D>4<><1B>F<EFBFBD>U<EFBFBD>|<7C>c<EFBFBD>)<29>3<EFBFBD><14>c<EFBFBD>d<EFBFBD><1A>+;<3B>;<3B>;<3B> <12>a<EFBFBD>K<EFBFBD>F<EFBFBD> <15><19> "<22>I<EFBFBD>$)<29>&<26>1<EFBFBD>*<2A>$5<> !<21>E<EFBFBD>3<EFBFBD> <09><18>9<EFBFBD>$<24>}<7D>4<><1B>F<EFBFBD>U<EFBFBD>|<7C>c<EFBFBD>)<29>3<EFBFBD><14>c<EFBFBD>d<EFBFBD><1A>+;<3B>;<3B>;<3B> <12>a<EFBFBD>K<EFBFBD>F<EFBFBD> <15><19> "<22>I<EFBFBD># r c<01>F<00>t|<00>r
|d|||dfSt|||<02>S)rQN)rr\)r7rWrs r!<00>
split_textr^s4<00><00><1E>d<EFBFBD>#<23><13>N<EFBFBD>]<5D>#<23>T<EFBFBD>-<2D>.<2E>%9<>9<>9<> <16>t<EFBFBD>]<5D>O<EFBFBD> <<3C><r c<01><><00>t|<00>r t|<00>}||kr |d||z
zzS|d|S|dkryt|<00>}||k(r|S||kr |d||z
zzSt|||<02>\}}|S)a$Adjust a string by cropping or padding with spaces such that it fits within the given number of cells.
Args:
text: String to adjust.
total: Desired size in cells.
unicode_version: Unicode version.
Returns:
A string with cell size equal to total.
rSNrrR)rr(r;r\)r7<00>totalr<00>sizer[<00>_s r!<00> set_cell_sizerc+s<><00><00><1E>d<EFBFBD>#<23><12>4<EFBFBD>y<EFBFBD><04> <0F>%<25><<3C><17>#<23><15><14><1C>.<2E>.<2E> .<2E><13>F<EFBFBD>U<EFBFBD>|<7C><1B> <0C><01>z<EFBFBD><11><18><14><0E>I<EFBFBD><10>E<EFBFBD><19><13> <0B><10>5<EFBFBD><18><13>c<EFBFBD>U<EFBFBD>Y<EFBFBD>.<2E>/<2F>/<2F>/<2F><19>$<24><05><EFBFBD>7<>G<EFBFBD>D<EFBFBD>!<21> <0F>Kr c<01>0<00>t|<00>r*tdt|<00>|<01>D<00>cgc]
}||||z<00><02> c}St||<02>\}}d}g}d}|D]+\} }
} || z|kDr|j ||| <00>| }d}|| z }<06>-|r|j ||d<00>|Scc}w)ahSplit text into lines such that each line fits within the available (cell) width.
Args:
text: The text to fold such that it fits in the given width.
width: The width available (number of cells).
Returns:
A list of strings such that each string in the list has cell width
less than or equal to the available width.
rN)r<00>ranger(rOrJ) r7r2rr/rLrb<00> line_size<7A>lines<65> line_offsetr0r1r[s r!<00>
chop_cellsriFs<><00><00><1E>d<EFBFBD>#<23>9><3E>q<EFBFBD>#<23>d<EFBFBD>)<29>U<EFBFBD>9S<39>T<><05><04>U<EFBFBD>U<EFBFBD>U<EFBFBD>]<5D>+<2B>T<>T<><1E>t<EFBFBD>_<EFBFBD>5<>H<EFBFBD>E<EFBFBD>1<EFBFBD><11>I<EFBFBD><19>E<EFBFBD><13>K<EFBFBD>!&<26><1F><1D><05>s<EFBFBD>I<EFBFBD> <14>y<EFBFBD> <20>5<EFBFBD> (<28> <11>L<EFBFBD>L<EFBFBD><14>k<EFBFBD>%<25>0<> 1<><1F>K<EFBFBD><19>I<EFBFBD><11>Y<EFBFBD><1E> <09> <1F> <11> <0A> <0C> <0C>T<EFBFBD>+<2B>,<2C>'<27>(<28> <10>L<EFBFBD><4C>Us<00>BN)<01>auto)r)rrr<00>returnrT)r7rrrrkrT)r7rrrrkz'tuple[list[CellSpan], int]')r7rrWrTrrrkztuple[str, str])r7rr`rTrrrkr)r7rr2rTrrrkz list[str])$<24>
__future__r<00> functoolsr<00>operatorr<00>typingrrrr <00>rich._unicode_datar
r'rT<00>CellSpanrVrr<00> frozensetrU<00>chrre<00> _SINGLE_CELLS<4C>
issupersetrrr3r8r;r5rOr\r^rcri)<03>_startrMr)s000r!<00><module>rws<><00><01>"<22><1F><1F>8<>8<>6<> <10><13>c<EFBFBD>3<EFBFBD><1D> <1F><08><1F><01>]<5D><12>6<02><1B>2<><02><1A>8<><06><06> <18>F<EFBFBD>D<EFBFBD><1C>S<EFBFBD>%<25><06><04>q<EFBFBD><08>"9<>:<3A><06> <16> <12><06><11><06><02> <0A>1><3E>0H<30>0H<30><16>-<2D>H<>#<23>
<EFBFBD>#<23> <0B>4<EFBFBD><18> <0A><19> <0A>D <0B>4<EFBFBD><1F> ,<2C><11> ,<2C> ,<2C>-<17>b'-<2D>G <20>
<0A>G <20> #<23>G <20>!<21>G <20>V;A<01>)#<23>
<0A>)#<23>!<21>)#<23>47<34>)#<23><14>)#<23>Z;A<01>=<3D>
<0A>=<3D>!<21>=<3D>47<34>=<3D><14>=<3D>(<10>6<11><>Y s<00>$C*