wib*UddlmZddlmZddlmZddlmZmZm Z m Z ddl m Z e eeefZedZgdZded <ed eDZejZd ed <Gd deZedd(d)dZedd(d*dZd(d*dZd*dZ d(d+dZ d(d,d Z d(d,d!Zd(d-d#Zd(d.d&Z d'S)/) annotations) lru_cache) itemgetter)Callable NamedTupleSequenceTuple)load)) ~))i)ipi)i%i%)i(i(zlist[tuple[int, int]]_SINGLE_CELL_UNICODE_RANGESc jg|]0\}}ttt||dzD]}|1S))mapchrrange).0_start_end characters Z/home/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/rich/cells.py rs[ FDS%q"9"9::  zCallable[[str], bool]_is_single_cell_widthsc2eZdZUdZded<ded<ded<dS) CellTablezDContains unicode data required to measure the cell widths of glyphs.strunicode_versionzSequence[tuple[int, int, int]]widthszfrozenset[str]narrow_to_wideN)__name__ __module__ __qualname____doc____annotations__rrr r &s<NN****""""""rr i)maxsizeautorr!r"returnintcHt|}|r|dksd|cxkrdkrnndSt|j}|d}||dkrdSd}t|dz }||kr4||zdz }||\}} } ||kr|dz }n|| kr|dz}n| S||k4dS)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 rrr)ordload_cell_tabler#len) rr" codepointtable last_entry lower_bound upper_boundindexstartendwidths rget_character_cell_sizer>.sIIY^^u 'A'A'A'AE'A'A'A'A'Aq O , , 3ErJ:a=  qKe**q.K  $ ${*q0!%LsE u  !)KK __!)KKL  $ $ 1rtextc"t||S)aGet 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. ) _cell_lenr?r"s rcached_cell_lenrCQs T? + ++rcht|dkrt||St||S) 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)r4rCrArBs rcell_lenrFbs3 4yy3t_555 T? + ++rct|rt|Sd|vrd|vrtfd|DSt}d}d}ddh}d}t|}||krM||}||vr|dkr|dz }n*|r|||jvz }d}nt |x} r|}|| z }|dz }||kM|S)rE‍️c38K|]}t|VdS)N)r>)rrr"s r z_cell_len..s?  DM #I ? ?      rrNr)rr4sumr3r$r>) r?r" cell_table total_widthlast_measured_characterSPECIALr:character_countrcharacter_widths ` rrArAqs@d##4yyt 4 4    QU      !11JK*."G E$iiO / ! !K   H$$ ( /6*:SSS *.'"9)_"U"UU /*3'.    / ! ! r'tuple[list[CellSpan], int]'ct|}t|}d}d}d}g}ddh}||kr||x} |vrU| dkr|dz }|r|d\} } } | || f|d<n2|r0|dz }|r)|d\} } } ||jvr d}| dz } |dz }| || f|d<gt| |x} r%| }|||dzx}| f|| z }n|r|d\} } } | |dzx}| f|d<||k||fS)zDivide text into spans that define a single grapheme. Args: text: String to split. unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version. Returns: List of spans. rNrHrIr r1r)r3r4r$r>append)r?r"rMcodepoint_countr:rOrNspansrPrr;r cell_lengthrRs rsplit_graphemesrYs!11J$iiO E*.K(*E"G / ! !e $I 0 0H$$ .=s'TTTUUU]*+TTTrrN)rrr4rYrU) r?r=r"rWrk line_sizelines line_offsetr;r<rds `` r chop_cellsrs1sd##UTTTTTq#d))U9S9STTTTt_55HE1IEK!&sI y 5 ( ( LLk%/0 1 1 1KIY ) T+,,'((( LrN)r,)rr!r"r!r-r.)r?r!r"r!r-r.)r?r!r"r!r-rS)r?r!rZr.r"r!r-r[)r?r!rhr.r"r!r-r!)r?r!r=r.r"r!r-rm)! __future__r functoolsroperatorrtypingrrrr rich._unicode_datar r3r.CellSpanr`rr) frozenset _SINGLE_CELLS issupersetrr r>rCrFrArYrergrlrsr*rrr}sQ"""""""888888888888666666 c3 Z]]666 7 1>0HHHHH##### ### 4     D 4 , , , , , , , , , ,----b'-2 2 2 2 2 l;A)#)#)#)#)#Z;A=====(6r