Files
ServerSync/lib/wcwidth/__pycache__/textwrap.cpython-314.pyc

214 lines
27 KiB
Plaintext
Raw Normal View History

2026-02-12 02:28:23 +02:00
+
9<><39>iEq<00><01>n<00>Rt^RIHt^RIt^RIt^RIt^RIHtHt^RI H
t ^RI H t ^RI Ht^RIHt^RIHt]'d ^R IHtHt!R
R ]4t]P.!R 4tR RltRRltRRlt!RR]P84tR*RRR^RRRRR^RRRRRR R!RR"RR#RR$RR%R&R'R/R(R)llltR#)+z<>
Sequence-aware text wrapping functions.
This module provides functions for wrapping text that may contain terminal escape sequences, with
proper handling of Unicode grapheme clusters and character display widths.
)<01> annotationsN)<02> TYPE_CHECKING<4E>
NamedTuple)<01>width)<01>iter_sequences)<01>iter_graphemes)<01> propagate_sgr)<01>ZERO_WIDTH_PATTERN)<02>Any<6E>Literalc<01>:<00>]tRt^t$RtR]R&R]R&R]R&RtR#)<08>_HyperlinkStatez>State for tracking an open OSC 8 hyperlink across line breaks.<2E>str<74>url<72>params<6D>
terminator<EFBFBD>N)<07>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__firstlineno__<5F>__doc__<5F>__annotations__<5F>__static_attributes__r<00><00>7/tmp/pip-target-wqrk2shd/lib/python/wcwidth/textwrap.pyr r s<00><00>H<> <0C>H<EFBFBD> <0F>K<EFBFBD><13>Orr z*\x1b]8;([^;]*);([^\x07\x1b]*)(\x07|\x1b\\)c<01> <00>V^8<>dQhRRRR/#)<05><00>seqr<00>return<72>_HyperlinkState | Noner)<01>formats"r<00> __annotate__r"'s<00><00><10><10>s<EFBFBD><10>'=<3D>rc<05><><00>\PV4;p'd<\VP^4VP^4VP^4R7#R#)z0Parse OSC 8 open sequence, return state or None.<2E>rrrN)<04>_HYPERLINK_OPEN_RE<52>matchr <00>group)r<00>ms& r<00>_parse_hyperlink_openr)'sC<00><00> <1F> %<25> %<25>c<EFBFBD> *<2A>*<2A><01>*<2A><1E>1<EFBFBD>7<EFBFBD>7<EFBFBD>1<EFBFBD>:<3A>a<EFBFBD>g<EFBFBD>g<EFBFBD>a<EFBFBD>j<EFBFBD>Q<EFBFBD>W<EFBFBD>W<EFBFBD>UV<55>Z<EFBFBD>X<>X<> rc<01>(<00>V^8<>dQhRRRRRRRR/#)rrrrrrr)r!s"rr"r".s(<00><00>0<>0<>c<EFBFBD>0<>3<EFBFBD>0<>C<EFBFBD>0<>C<EFBFBD>0rc<05><00>RV RV V 2#)zGenerate OSC 8 open sequence.z]8;<3B>;rr$s&&&r<00>_make_hyperlink_openr-.s<00><00> <14>V<EFBFBD>H<EFBFBD>A<EFBFBD>c<EFBFBD>U<EFBFBD>:<3A>,<2C> /<2F>/rc<01> <00>V^8<>dQhRRRR/#)rrrrr)r!s"rr"r"3s<00><00>#<23>#<23>c<EFBFBD>#<23>c<EFBFBD>#rc<05> <00>RV 2#)zGenerate OSC 8 close sequence.z]8;;r)rs&r<00>_make_hyperlink_closer03s<00><00> <15>j<EFBFBD>\<5C> "<22>"rc<01><>a<00>]tRt^8tRtR!RRR^R^/RV3Rllllt]RR l4tR
R ltR R lt RRlt
RRlt RRlt RRlt RRltRRltRRltRRltRRltR tV;t#)"<22>SequenceTextWrappera<72>
Sequence-aware text wrapper extending :class:`textwrap.TextWrapper`.
This wrapper properly handles terminal escape sequences and Unicode grapheme clusters when
calculating text width for wrapping.
This implementation is based on the SequenceTextWrapper from the 'blessed' library, with
contributions from Avram Lubkin and grayjk.
The key difference from the blessed implementation is the addition of grapheme cluster support
via :func:`~.iter_graphemes`, providing width calculation for ZWJ emoji sequences, VS-16 emojis
and variations, regional indicator flags, and combining characters.
OSC 8 hyperlinks are handled specially: when a hyperlink must span multiple lines, each line
receives complete open/close sequences with a shared ``id`` parameter, ensuring terminals
treat the fragments as a single hyperlink for hover underlining. If the original hyperlink
already has an ``id`` parameter, it is preserved; otherwise, one is generated.
<EFBFBD> control_codes<65>parse<73>tabsize<7A>ambiguous_widthc <01>0<00>V^8<>dQhRRRRRRRRRRR R
/#) rr<00>intr3<00>$Literal['parse', 'strict', 'ignore']r5r6<00>kwargsr
r<00>Noner)r!s"rr"<00> SequenceTextWrapper.__annotate__LsA<00><00>/<2F>/<2F>c<EFBFBD>/<2F> D<>/<2F><1D>/<2F>#&<26>/<2F><1F> /<2F>$(<28> /rc <0A>P<<01>\SV`!RRV/VBW nW0nW@nR#)ag
Initialize the wrapper.
:param width: Maximum line width in display cells.
:param control_codes: How to handle control sequences (see :func:`~.width`).
:param tabsize: Tab stop width for tab expansion.
:param ambiguous_width: Width to use for East Asian Ambiguous (A) characters.
:param kwargs: Additional arguments passed to :class:`textwrap.TextWrapper`.
rNr)<05>super<65>__init__r3r5r6)<07>selfrr3r5r6r:<00> __class__s&&$$$,<2C>rr?<00>SequenceTextWrapper.__init__Ls+<00><><00> <0E><07><18>/<2F>u<EFBFBD>/<2F><06>/<2F>*<2A><1A><1E> <0C>.<2E>rc<01><00>V^8<>dQhRR/#)rrrr)r!s"rr"r<`s<00><00>$<24>$<24><03>$rc <0A>.<00>\P!^4#)z7Generate unique hyperlink id as 8-character hex string.)<02>secrets<74> token_hexrrr<00>_next_hyperlink_id<69>&SequenceTextWrapper._next_hyperlink_id_s<00><00><17> <20> <20><11>#<23>#rc<01> <00>V^8<>dQhRRRR/#<00>r<00>textrrr8r)r!s"rr"r<ds<00><00><<3C><<3C>3<EFBFBD><<3C>3<EFBFBD><rc <0A>Z<00>\WPVPVPR7#)z,Measure text width accounting for sequences.)r3r5r6)<04>_widthr3r5r6<00>r@rKs&&rrM<00>SequenceTextWrapper._widthds&<00><00><15>d<EFBFBD>*<<3C>*<<3C>d<EFBFBD>l<EFBFBD>l<EFBFBD>&*<2A>&:<3A>&:<3A><<3C> <rc<01> <00>V^8<>dQhRRRR/#<00>rrKrrr)r!s"rr"r<is<00><00><1F><1F>S<EFBFBD><1F>S<EFBFBD>rc <0A><><00>.p\V4F wr4V'dKVPV4K" RPV4#)z'Strip all terminal sequences from text.<2E><00>r<00>append<6E>join<69>r@rK<00>result<6C>segment<6E>is_seqs&& r<00>_strip_sequences<65>$SequenceTextWrapper._strip_sequencesis9<00><00><13><06>-<2D>d<EFBFBD>3<>O<EFBFBD>G<EFBFBD><19>6<EFBFBD><16> <0A> <0A>g<EFBFBD>&<26> 4<><12>w<EFBFBD>w<EFBFBD>v<EFBFBD><EFBFBD>rc<01> <00>V^8<>dQhRRRR/#rQr)r!s"rr"r<qs<00><00><1F><1F>s<EFBFBD><1F>s<EFBFBD>rc <0A><><00>.p\V4F wr4V'gKVPV4K" RPV4#)z*Extract only terminal sequences from text.rSrTrWs&& r<00>_extract_sequences<65>&SequenceTextWrapper._extract_sequencesqs9<00><00><13><06>-<2D>d<EFBFBD>3<>O<EFBFBD>G<EFBFBD><15>v<EFBFBD><16> <0A> <0A>g<EFBFBD>&<26> 4<><12>w<EFBFBD>w<EFBFBD>v<EFBFBD><EFBFBD>rc<01> <00>V^8<>dQhRRRR/#)rrKrr<00> list[str]r)r!s"rr"r<ys<00><00>\<16>\<16>3<EFBFBD>\<16>9<EFBFBD>\rc <0A><><00>.pRp^pRp\V4EFwrgV'gwV'd@V'd8V^,P4'gVR, pVPV4VF%pV^, pVPV4W8, pK' RpK<>VPR4p VPR4'dHV'd@VR,P4'g#V 'gVR, pVPV4V\ V4, pT pEK
VPV4\
P PW4p
V
'g V'dV.#.p ^p \ V
4p \V
4Fywr<>\ V4pV ^8Xd^MW,^,
,pW<>^,
8Xd VR,pMW,V,^,
,pVV8wdV PVVV4V V, p K{ V #)ae
Sequence-aware variant of :meth:`textwrap.TextWrapper._split`.
This method ensures that terminal escape sequences don't interfere with the text splitting
logic, particularly for hyphen-based word breaking. It builds a position mapping from
stripped text to original text, calls the parent's _split on stripped text, then maps chunks
back.
OSC hyperlink sequences are treated as word boundaries::
>>> wrap('foo \x1b]8;;https://example.com\x07link\x1b]8;;\x07 bar', 6)
['foo', '\x1b]8;;https://example.com\x07link\x1b]8;;\x07', 'bar']
Both BEL (``\x07``) and ST (``\x1b\\``) terminators are supported.
rSF<> z]<5D>z]8;;\z]8;;<07><><EFBFBD><EFBFBD><EFBFBD>) r<00>isspacerU<00>
startswith<EFBFBD>len<65>textwrap<61> TextWrapper<65>_split<69> enumerate)r@rK<00>char_end<6E> stripped_text<78> original_pos<6F>prev_was_hyperlink_closerYrZ<00>char<61>is_hyperlink_close<73>stripped_chunksrX<00> stripped_pos<6F>
num_chunks<EFBFBD>idx<64>chunk<6E> chunk_len<65>
start_orig<EFBFBD>end_origs&& rrl<00>SequenceTextWrapper._splitys<><00><00>0!<21><08><1A> <0A><18> <0C>#(<28> <20>-<2D>d<EFBFBD>3<>O<EFBFBD>G<EFBFBD><19>+<2B><07><07><01>
<EFBFBD>@R<>@R<>@T<>@T<>!<21>S<EFBFBD>(<28>M<EFBFBD><1C>O<EFBFBD>O<EFBFBD>L<EFBFBD>1<>#<23>D<EFBFBD> <20>A<EFBFBD>%<25>L<EFBFBD><1C>O<EFBFBD>O<EFBFBD>L<EFBFBD>1<>!<21>)<29>M<EFBFBD>$<24>,1<>(<28>%,<2C>%7<>%7<>8Z<38>%[<5B>"<22>
<1C>&<26>&<26>w<EFBFBD>/<2F>/<2F>M<EFBFBD>%<25>b<EFBFBD>)<29>1<>1<>3<>3<>-<2D>%<25><13>,<2C> <0A> <20><0F><0F> <0C>5<><1D><03>G<EFBFBD> <0C>,<2C> <0C>+=<3D>(<28>3 4<>8 <11><0F><0F> <0C>%<25>#<23>.<2E>.<2E>5<>5<>d<EFBFBD>J<><0F><1F>4<EFBFBD><18>6<EFBFBD>M<EFBFBD><1F><06><18> <0C><18><1F>)<29>
<EFBFBD>#<23>O<EFBFBD>4<>J<EFBFBD>C<EFBFBD><1B>E<EFBFBD>
<EFBFBD>I<EFBFBD>+<2B>a<EFBFBD>/<2F><11>X<EFBFBD>Q<EFBFBD>>N<>5O<35>J<EFBFBD><13>1<EFBFBD>n<EFBFBD>$<24>#<23>B<EFBFBD><<3C><08>#<23>9<EFBFBD>$<<3C>q<EFBFBD>$@<40>A<><08><1A>X<EFBFBD>%<25><16> <0A> <0A>d<EFBFBD>:<3A>h<EFBFBD>7<>8<> <18>I<EFBFBD> %<25>L<EFBFBD>#5<>&<16> rc<01> <00>V^8<>dQhRRRR/#)r<00>chunksrbrr)r!s"rr"r<<00>s<00><00>s<15>s<15>9<EFBFBD>s<15><19>src <0A><00>V'g.#VPe<>VP^8<>dVPpM VPpVPV4VPVPP 44,VP 8<>d \R4h.pRpRpRp\\V44pV'EdJ.p^pV'd VPM VPpVP VPV4,
p Ve>\VPVPVP4p
W<EFBFBD>R,,VR&VPVR,4p VP'ddV'd\V 'dTV P!4'g>VP#VR,4p VRV 'dV'dW<>R,,VR&V'dRVR,p VPV 4pW<>,V 8:d*VP%VP'44W<>, pKXV'dlVPVR,4V 8<>dOVP)WW<>4VPRP+V44pV'dVR,'gVRKV'dVPVR,4MRpVP'd<>V'd{V'dsVP!4'g]VP#VR,4p W<>PVR,4,pVRV 'dV'dVR,V ,VR&V'gEK<>V'*;'gVVP;'dB\-V4^8H;'d,VPV^,4P!4'*pVPe2\-V4^,VP8gV'Ed<>W<>8:Ed<>RP+V4pVP/VV4pVEeVfeRVP9dVPpMFVP'd"RVP14 RVP 2pMRVP14 2pV\3VP4, pRVP9d`\VPVPVP4p\VPVVP4pVP5VV^4p\7VPVVP4pMRpRpVP'dVP94pVP%VV,4RpEK<>VPVP4pV'd<>VPVR,4pVP!4'dVV,V 8:dqRP+V4pVP/VV4pVeV\3VP4, pVP%VV,VP,4V#W<>PVR,4,pVRK<>V'dYVP;VR,4pVPV4V,VP 8:dVVP,VR&V#VP%W PP 4,4V#V#) a
Wrap chunks into lines using sequence-aware width.
Override TextWrapper._wrap_chunks to use _width instead of len. Follows stdlib's algorithm:
greedily fill lines, handle long words. Also handle OSC hyperlink processing. When
hyperlinks span multiple lines, each line gets complete open/close sequences with matching
id parameters for hover underlining continuity per OSC 8 spec.
Nz#placeholder too large for max widthTrSzid=<3D>:Frf)<1E> max_lines<65>subsequent_indent<6E>initial_indentrM<00> placeholder<65>lstripr<00>
ValueError<EFBFBD>list<73>reversedr-rrrr[<00>drop_whitespace<63>stripr_rU<00>pop<6F>_handle_long_wordrVri<00>_track_hyperlink_staterGr0<00>replacer <00>rstrip<69>_rstrip_visible)r@r~<00>indent<6E>lines<65> is_first_line<6E>hyperlink_state<74>current_hyperlink_id<69> current_line<6E> current_width<74>
line_width<EFBFBD>open_seq<65>stripped<65> sequencesrx<00> chunk_width<74> stripped_last<73>no_more_content<6E> line_content<6E> new_state<74>old_open<65>new_open<65> placeholder_w<5F> last_text<78> prev_lines&& r<00> _wrap_chunks<6B> SequenceTextWrapper._wrap_chunks<6B>s<><00><00><16><15>I<EFBFBD> <0F>><3E>><3E> %<25><13>~<7E>~<7E><01>!<21><1D>/<2F>/<2F><06><1D>,<2C>,<2C><06><14> <0B> <0B>F<EFBFBD>#<23><1A>k<EFBFBD>k<EFBFBD>$<24>"2<>"2<>"9<>"9<>";<3B><<3C>=<3D><1A>j<EFBFBD>j<EFBFBD>!<21>!<21>!F<>G<>G<><1D><05><1C> <0A>26<32><0F>+/<2F><1C><16>h<EFBFBD>v<EFBFBD>&<26>'<27><06><14>f<EFBFBD>&(<28>L<EFBFBD><1D>M<EFBFBD>-:<3A>T<EFBFBD>(<28>(<28>t<EFBFBD>?U<>?U<>F<EFBFBD><1D><1A><1A>d<EFBFBD>k<EFBFBD>k<EFBFBD>&<26>&9<>9<>J<EFBFBD><1F>*<2A>/<2F>#<23>'<27>'<27><1F>)?<3F>)?<3F><1F>A[<5B>A[<5B>]<01><08>%<25>r<EFBFBD>
<EFBFBD>2<><06>r<EFBFBD>
<EFBFBD>
<1C>,<2C>,<2C>V<EFBFBD>B<EFBFBD>Z<EFBFBD>8<>H<EFBFBD><13>#<23>#<23>#<23><05>(<28>8<EFBFBD>><3E>><3E>CS<43>CS<43> <20>3<>3<>F<EFBFBD>2<EFBFBD>J<EFBFBD>?<3F> <09><1A>2<EFBFBD>J<EFBFBD><1C><16>!*<2A>B<EFBFBD>Z<EFBFBD>!7<>F<EFBFBD>2<EFBFBD>J<EFBFBD><19><1E>r<EFBFBD>
<EFBFBD><05>"<22>k<EFBFBD>k<EFBFBD>%<25>0<> <0B> <20>.<2E>*<2A><<3C> <20>'<27>'<27><06>
<EFBFBD>
<EFBFBD> <0C>5<>!<21>0<>M<EFBFBD><19><16>$<24>+<2B>+<2B>f<EFBFBD>R<EFBFBD>j<EFBFBD>1<>J<EFBFBD>><3E><14>&<26>&<26><1A>-<2D><12>!%<25> <0B> <0B>B<EFBFBD>G<EFBFBD>G<EFBFBD>L<EFBFBD>,A<> B<> <0A><1C>V<EFBFBD>B<EFBFBD>Z<EFBFBD>Z<EFBFBD><1E>r<EFBFBD>
<EFBFBD>
HT<01>D<EFBFBD>1<>1<>,<2C>r<EFBFBD>2B<32>C<>Y[<5B>M<EFBFBD><14>$<24>$<24>$<24><1C>!<21>-<2D>*=<3D>*=<3D>*?<3F>*?<3F> <20>3<>3<>L<EFBFBD><12>4D<34>E<> <09><1D><1B><1B>\<5C>"<22>-=<3D>!><3E>><3E> <0A> <20><12>$<24><1C><1C>'3<>B<EFBFBD>'7<>)<29>'C<>L<EFBFBD><12>$<24><1B>|<7C> <1F>J<EFBFBD>A<01>A<01><18>(<28>(<28>A<01>A<01><17><06>K<EFBFBD>1<EFBFBD>$<24>A<01>A<01><1C>-<2D>-<2D>f<EFBFBD>Q<EFBFBD>i<EFBFBD>8<>><3E>><3E>@<40>@<40>  <20> <19>N<EFBFBD>N<EFBFBD>*<2A><1B>E<EFBFBD>
<EFBFBD>Q<EFBFBD><0E><14><1E><1E>7<>'<27><0F>)<29>7<>#%<25>7<EFBFBD>7<EFBFBD><<3C>#8<>L<EFBFBD>!%<25> ;<3B> ;<3B>L<EFBFBD>/<2F> Z<>I<EFBFBD>!<21>,<2C>/<2F>7<>$<24> <09>(8<>(8<>8<>7@<40>7G<37>7G<37> 4<>!*<2A>!1<>!1<>!1<>'*<2A>$<24>*A<>*A<>*C<>)D<>A<EFBFBD>i<EFBFBD>FV<46>FV<46>EW<45>$X<>!5<>:=<3D>T<EFBFBD>=T<>=T<>=V<><W<>7X<37> 4<>$<24>(=<3D>i<EFBFBD>>R<>>R<>(S<>S<> <0C>!<21> <09>(8<>(8<>8<>';<3B> )<29> <0A> <0A>y<EFBFBD>/?<3F>/?<3F><19>AU<41>AU<41>(W<01>H<EFBFBD>';<3B> )<29> <0A> <0A>/C<>Y<EFBFBD>EY<45>EY<45>([<01>H<EFBFBD>+7<>+?<3F>+?<3F><08>(<28>TU<54>+V<>L<EFBFBD>+:<3A>%<25>M<EFBFBD>M<EFBFBD>+?<3F><19>AU<41>AU<41>+W<01><0F>+/<2F><0F>/3<>,<2C><1C>+<2B>+<2B>+<2B>'3<>':<3A>':<3A>'<<3C> <0C><19>L<EFBFBD>L<EFBFBD><16>,<2C>!6<>7<>$)<29>M<EFBFBD>%)<29>K<EFBFBD>K<EFBFBD><04>0@<40>0@<40>$A<>M<EFBFBD>&<26>$(<28>$9<>$9<>,<2C>r<EFBFBD>:J<>$K<> <09>%<25>O<EFBFBD>O<EFBFBD>-<2D>-<2D>$1<>M<EFBFBD>$A<>Z<EFBFBD>$O<>+-<2D>7<EFBFBD>7<EFBFBD><<3C>+@<40>L<EFBFBD>(,<2C>(C<>(C<> ,<2C>o<EFBFBD>)?<3F>I<EFBFBD>(<28>4<> ,<2C>0E<30>$-<2D>$8<>$8<>1:<3A>!:<3A> <0C>!<21>L<EFBFBD>L<EFBFBD><16>,<2C>)><3E><14>AQ<41>AQ<41>)Q<>R<>!<21><1A><14> <0C>&<26><1B><1B>\<5C>"<22>5E<35>)F<>F<> <0A>(<28><12>,<2C> <20>(,<2C>(<<3C>(<<3C>U<EFBFBD>2<EFBFBD>Y<EFBFBD>(G<>I<EFBFBD> $<24> <0B> <0B>I<EFBFBD> 6<><1D> F<>'+<2B>z<EFBFBD>z<EFBFBD>!2<>,5<><04>8H<38>8H<38>,H<><05>b<EFBFBD> <09> %<25><15> <0C><1E> <0C> <0C>V<EFBFBD>.><3E>.><3E>.E<>.E<>.G<>%G<>H<><19><14> <0C>u<EFBFBD> rc<01>$<00>V^8<>dQhRRRRRR/#)rrKr<00>stater rr)r!s"rr"r<<00>s$<00><00><15><15><1B><15>)<29><15>.D<>rc <0A><><00>\V4FOwr4V'gK\V4pVeVP'dTpK4VPR4'gKMRpKQ V#)z<>
Track hyperlink state through text.
:param text: Text to scan for hyperlink sequences.
:param state: Current state or None if outside hyperlink.
:returns: Updated state after processing text.
Nre)rr)rrh)r@rKr<>rYrZ<00> parsed_links&&& rr<><00>*SequenceTextWrapper._track_hyperlink_state<74>sU<00><00> .<2E>d<EFBFBD>3<>O<EFBFBD>G<EFBFBD><15>v<EFBFBD>3<>G<EFBFBD><<3C> <0B><1E>*<2A>{<7B><EFBFBD><EFBFBD><EFBFBD>'<27>E<EFBFBD><1C>'<27>'<27>(J<>K<>K<> <20>E<EFBFBD> 4<><15> rc
<01>,<00>V^8<>dQhRRRRRRRRRR/#) r<00>reversed_chunksrb<00>cur_line<6E>cur_lenr8rrr;r)r!s"rr"r<<00>s3<00><00>/3<>/3<><19>/3<>$-<2D>/3<>8;<3B>/3<>!$<24>/3<>)-<2D>/3rc <0A><><00>V^8d^pMWC,
pVR,pVP'EdRp^pVP'd<>VPV4p \V 4V8<>duV P R^V4p
V
^8<>d[\
;QJdRV RV
4F 'gK RM RM!RV RV
44'dVP Wj^,4pRpV'dTp M1VPWe4p V ^8XdV'gVPV4p VPVRV 4WkRVR&R#V'g"VPVP44R#R#)z<>
Sequence-aware :meth:`textwrap.TextWrapper._handle_long_word`.
This method ensures that word boundaries are not broken mid-sequence, and respects grapheme
cluster boundaries when breaking long words.
F<EFBFBD>-c3<01>*"<00>TF qR8gx<00>K R#5i)r<>Nr)<02>.0<EFBFBD>cs& r<00> <genexpr><3E>8SequenceTextWrapper._handle_long_word.<locals>.<genexpr><3E>s<00><00><00>-V<>@U<>1<EFBFBD>3<EFBFBD>h<EFBFBD>@U<>s<00>NTrf) <0B>break_long_words<64>break_on_hyphensr[ri<00>rfind<6E>any<6E>_map_stripped_pos_to_original<61>_find_break_position<6F>_find_first_grapheme_endrUr<>) r@r<>r<>r<>r<00>
space_leftrx<00>break_at_hyphen<65>
hyphen_endr<EFBFBD><00>
hyphen_pos<EFBFBD>
actual_ends &&&&& rr<><00>%SequenceTextWrapper._handle_long_word<72>s6<00><00> <11>1<EFBFBD>9<EFBFBD><1A>J<EFBFBD><1E><1F>J<EFBFBD><1F><02>#<23><05> <0F> <20> <20> <20>#<23>O<EFBFBD><1A>J<EFBFBD><14>$<24>$<24>$<24><1F>0<>0<><15>7<><08><16>x<EFBFBD>=<3D>:<3A>-<2D>!)<29><1E><1E><03>Q<EFBFBD>
<EFBFBD>!C<>J<EFBFBD>!<21>A<EFBFBD>~<7E>#<23>#<23>-V<><08><1B>*<2A>@U<>-V<>#<23>#<23>#<23>-V<><08><1B>*<2A>@U<>-V<>*V<>*V<>%)<29>%G<>%G<><05>\]<5D>~<7E>%^<5E>
<EFBFBD>*.<2E><0F><1F>'<27>
<EFBFBD>!<21>6<>6<>u<EFBFBD>I<>
<EFBFBD>
<1E><11>?<3F>8<EFBFBD>!%<25>!><3E>!><3E>u<EFBFBD>!E<>J<EFBFBD> <14>O<EFBFBD>O<EFBFBD>E<EFBFBD>+<2B>:<3A>.<2E> /<2F>"'<27> <0B>"4<>O<EFBFBD>B<EFBFBD> <1F><19> <14>O<EFBFBD>O<EFBFBD>O<EFBFBD>/<2F>/<2F>1<> 2<>rc<01>$<00>V^8<>dQhRRRRRR/#)rrKrrur8rr)r!s"rr"r<<00>s!<00><00><1C><1C>#<23><1C>S<EFBFBD><1C>S<EFBFBD>rc <0A><00>^p^p\V4FmwrVV'dV\V4, pK!V\V4,V8<>dWBV,
,u#V\V4, pV\V4, pKo V#)z?Map a position in stripped text back to original text position.)rri)r@rKru<00> stripped_idx<64> original_idxrYrZs&&& rr<><00>1SequenceTextWrapper._map_stripped_pos_to_original<61>sq<00><00><18> <0C><18> <0C>-<2D>d<EFBFBD>3<>O<EFBFBD>G<EFBFBD><15><1C><03>G<EFBFBD> <0C>,<2C> <0C><1D><03>G<EFBFBD> <0C>,<2C>|<7C>;<3B>#<23>l<EFBFBD>'B<>C<>C<><1C><03>G<EFBFBD> <0C>,<2C> <0C><1C><03>G<EFBFBD> <0C>,<2C> <0C> 4<><1C>rc<01>$<00>V^8<>dQhRRRRRR/#)rrKr<00> max_widthr8rr)r!s"rr"r<<00>s!<00><00><13><13><13><13><13><13><13>rc <0A>N<00>^p^pV\V48d<>W,pVR8Xd1\P!W4pV'dVP4pKO\ \ WR74pVP V4pWH,V8<>dV#WH, pV\V4, pK<>V#)z;Find string index in text that fits within max_width cells.<2E>)<01>start)rir r&<00>end<6E>nextrrM) r@rKr<>rw<00> width_so_farrrr&<00>grapheme<6D>grapheme_widths &&& rr<><00>(SequenceTextWrapper._find_break_position<6F>s<><00><00><0F><03><18> <0C><11>C<EFBFBD><04>I<EFBFBD>o<EFBFBD><17>9<EFBFBD>D<EFBFBD><14>v<EFBFBD>~<7E>*<2A>0<>0<><14>;<3B><05><18><1F>)<29>)<29>+<2B>C<EFBFBD><1C><1C>N<EFBFBD>4<EFBFBD>;<3B><<3C>H<EFBFBD>!<21>[<5B>[<5B><18>2<>N<EFBFBD><1B>,<2C>y<EFBFBD>8<><1A>
<EFBFBD> <18> *<2A>L<EFBFBD> <0F>3<EFBFBD>x<EFBFBD>=<3D> <20>C<EFBFBD><13>
rc<01> <00>V^8<>dQhRRRR/#rJr)r!s"rr"r<s<00><00>/<2F>/<2F>S<EFBFBD>/<2F>S<EFBFBD>/rc <0A><<00>\\\V444#)z,Find the end position of the first grapheme.)rir<>rrNs&&rr<><00>,SequenceTextWrapper._find_first_grapheme_ends<00><00><12>4<EFBFBD><0E>t<EFBFBD>,<2C>-<2D>.<2E>.rc<01> <00>V^8<>dQhRRRR/#rQr)r!s"rr"r<s<00><00><1F><1F>C<EFBFBD><1F>C<EFBFBD>rc <0A><><00>\\V44pRp\V4F,wpwrVV'dKVP4'gK*TpK. VR8XdR#.p\V4FcwpwrVWC8dVP V4K!WC8Xd"VP VP44KHV'gKRVP V4Ke RP V4#)zAStrip trailing visible whitespace, preserving trailing sequences.rSrf)r<>rrmr<>rUrV)r@rK<00>segments<74>last_vis<69>irYrZrXs&& rr<><00>#SequenceTextWrapper._rstrip_visibles<><00><00><17><0E>t<EFBFBD>,<2C>-<2D><08><15><08>$-<2D>h<EFBFBD>$7<> <20>A<EFBFBD> <20><07><19>6<EFBFBD>g<EFBFBD>n<EFBFBD>n<EFBFBD>.<2E>.<2E><1C><08>%8<> <14>r<EFBFBD>><3E><15><13><06>$-<2D>h<EFBFBD>$7<> <20>A<EFBFBD> <20><07><10>|<7C><16> <0A> <0A>g<EFBFBD>&<26><12><1D><16> <0A> <0A>g<EFBFBD>n<EFBFBD>n<EFBFBD>.<2E>/<2F><17><16><16> <0A> <0A>g<EFBFBD>&<26> %8<><12>w<EFBFBD>w<EFBFBD>v<EFBFBD><EFBFBD>r)r6r3r5<00><01>F)rrrrrr?<00> staticmethodrGrMr[r_rlr<>r<>r<>r<>r<>r<>r<>r<00> __classcell__)rAs@rr2r28s<><00><><00><08>&/<2F>GN<47>/<2F> !<21>/<2F>)*<2A>/<2F>/<2F>&<12>$<24><12>$<24><<3C>
<1F><1F>\<16>|s<15>j<15>&/3<>b<1C>&<13>:/<2F><1F>rr2r3r4r5<00> expand_tabsT<73>replace_whitespacer6r<>rSr<><00>fix_sentence_endingsFr<46>r<>r<>r<>r<>z [...]rc"<01>\<00>V^8<>dQhRRRRRRRRRR R
R R RR RR RRR RR RR RR RRRRRR RR/#)rrKrrr8r3r9r5r<><00>boolr<6C>r6r<>r<>r<>r<>r<>r<>r<>z
int | Noner<65>rrrbr)r!s"rr"r"s<><00><00>x<11>x<11>s<EFBFBD>x<11>3<EFBFBD>x<11><<3C>x<11><15>x<11><1B>x<11>"<22> x<11>
<1E> x<11> <1D> x<11> <20>x<11> $<24>x<11> <20>x<11> <20>x<11><1F>x<11><1F>x<11><1A>x<11><1D>x<11>)2<>xrc<05><><00>\VVVVVVVVV V
V V V VR7pVPV4pV'd \V4pV#)u
Wrap text to fit within given width, returning a list of wrapped lines.
Like :func:`textwrap.wrap`, but measures width in display cells rather than
characters, correctly handling wide characters, combining marks, and terminal
escape sequences.
:param text: Text to wrap, may contain terminal sequences.
:param width: Maximum line width in display cells.
:param control_codes: How to handle terminal sequences (see :func:`~.width`).
:param tabsize: Tab stop width for tab expansion.
:param expand_tabs: If True (default), tab characters are expanded
to spaces using ``tabsize``.
:param replace_whitespace: If True (default), each whitespace character
is replaced with a single space after tab expansion. When False,
control whitespace like ``\n`` has zero display width (unlike
:func:`textwrap.wrap` which counts ``len()``), so wrap points
may differ from stdlib for non-space whitespace characters.
:param ambiguous_width: Width to use for East Asian Ambiguous (A)
characters. Default is ``1`` (narrow). Set to ``2`` for CJK contexts.
:param initial_indent: String prepended to first line.
:param subsequent_indent: String prepended to subsequent lines.
:param fix_sentence_endings: If True, ensure sentences are always
separated by exactly two spaces.
:param break_long_words: If True, break words longer than width.
:param break_on_hyphens: If True, allow breaking at hyphens.
:param drop_whitespace: If True (default), whitespace at the beginning
and end of each line (after wrapping but before indenting) is dropped.
Set to False to preserve whitespace.
:param max_lines: If set, output contains at most this many lines, with
``placeholder`` appended to the last line if the text was truncated.
:param placeholder: String appended to the last line when text is
truncated by ``max_lines``. Default is ``' [...]'``.
:param propagate_sgr: If True (default), SGR (terminal styling) sequences
are propagated across wrapped lines. Each line ends with a reset
sequence and the next line begins with the active style restored.
:returns: List of wrapped lines without trailing newlines.
SGR (terminal styling) sequences are propagated across wrapped lines
by default. Each line ends with a reset sequence and the next line
begins with the active style restored::
>>> wrap('\x1b[1;34mHello world\x1b[0m', width=6)
['\x1b[1;34mHello\x1b[0m', '\x1b[1;34mworld\x1b[0m']
Set ``propagate_sgr=False`` to disable this behavior.
Like :func:`textwrap.wrap`, newlines in the input text are treated as
whitespace and collapsed. To preserve paragraph breaks, wrap each
paragraph separately::
>>> text = 'First line.\nSecond line.'
>>> wrap(text, 40) # newline collapsed to space
['First line. Second line.']
>>> [line for para in text.split('\n')
... for line in (wrap(para, 40) if para else [''])]
['First line.', 'Second line.']
.. seealso::
:func:`textwrap.wrap`, :class:`textwrap.TextWrapper`
Standard library text wrapping (character-based).
:class:`.SequenceTextWrapper`
Class interface for advanced wrapping options.
.. versionadded:: 0.3.0
.. versionchanged:: 0.5.0
Added ``propagate_sgr`` parameter (default True).
.. versionchanged:: 0.6.0
Added ``expand_tabs``, ``replace_whitespace``, ``fix_sentence_endings``,
``drop_whitespace``, ``max_lines``, and ``placeholder`` parameters.
Example::
>>> from wcwidth import wrap
>>> wrap('hello world', 5)
['hello', 'world']
>>> wrap('中文字符', 4) # CJK characters (2 cells each)
['中文', '字符']
)rr3r5r<>r<>r6r<>r<>r<>r<>r<>r<>r<>r<>)r2<00>wrap<61>_propagate_sgr)rKrr3r5r<>r<>r6r<>r<>r<>r<>r<>r<>r<>r<>r<00>wrapperr<72>s&&$$$$$$$$$$$$$$ rr<>r<>s[<00><00>F"<22><13>#<23><17><1F>-<2D>'<27>%<25>+<2B>1<>)<29>)<29>'<27><1B><1F><06>G<EFBFBD> <14>L<EFBFBD>L<EFBFBD><14> <1E>E<EFBFBD><14><1E>u<EFBFBD>%<25><05> <10>Lrr<>)r<00>
__future__r<00>rerErj<00>typingrr<00>wcwidthrrMrr<>r<00> sgr_staterr<><00>escape_sequencesr r
r r <00>compiler%r)r-r0rkr2r<>rrr<00><module>r<>s<00><01><04> #<23>
<EFBFBD><0E><0F>,<2C>%<25>#<23>$<24>6<>0<><10>#<23><14>j<EFBFBD><14><18>Z<EFBFBD>Z<EFBFBD> M<>N<><12><10>0<>
#<23>
]<1F>(<28>.<2E>.<2E>]<1F>@x<11>?F<>x<11><19>x<11>"<22>x<11>%)<29> x<11>
!"<22> x<11> "<22> x<11>#%<25>x<11>',<2C>x<11>#'<27>x<11>#'<27>x<11>"&<26>x<11>"&<26>x<11>%<25>x<11> $<24>x<11>xr