e=SrSSKrSSKJr SSKJr SSKJr "SS5r\R5 Sr S r S r S r S rS r\R "S5rSr"SS5r"SS5r"SS5r\S:XaSSKJr \"SSSS9 gg)zFormat all or a selected region (line slice) of text. Region formatting options: paragraph, comment block, indent, deindent, comment, uncomment, tabify, and untabify. File renamed from paragraph.py with functions added from editor.py. N)askyesno) askinteger)idleConfc>\rSrSrSrSr\S5rSrS Sjr Sr g) FormatParagraphaFormat a paragraph, comment block, or selection to a max width. Does basic, standard text formatting, and also understands Python comment blocks. Thus, for editing Python source code, this extension is really only suitable for reformatting these comment blocks or triple-quoted strings. Known problems with comment reformatting: * If there is a selection marked, and the first line of the selection is not complete, the block will probably not be detected as comments, and will have the normal "text formatting" rules applied. * If a comment block has leading whitespace that mixes tabs and spaces, they will not be considered part of the same block. * Fancy comments, like this bulleted list, aren't handled :-) cXlgNeditwinselfr s 4/opt/imh/python3.13/lib/python3.13/idlelib/format.py__init__FormatParagraph.__init__ c>[R"SSSSSS9Ulg)N extensionsrz max-widthintH)typedefault)r GetOption max_width)clss rreloadFormatParagraph.reload"s! **<9J+6UBP rcSUlgr r rs rcloseFormatParagraph.close's  rNcxUc UROUnURRnURR5upEU(a$U(aUR XE5n[ U5nO[ X3RS55upEpvU(a [XbU5nO [Xb5nURSSS5 X:waUURSU5 UR5 URXE5 URXH5 UR5 OURSU5 UR!S5 g)aFormats paragraph to a max width specified in idleConf. If text is selected, format_paragraph_event will start breaking lines at the max width, starting from the beginning selection. If no text is selected, format_paragraph_event uses the current cursor location to determine the paragraph (lines of text surrounded by blank lines) and formats it. The length limit parameter is for testing with a known value. insertsel1.0endbreak)rr textget_selection_indicesgetget_comment_headerfind_paragraphindexreformat_commentreformat_paragraph tag_removemark_setundo_block_startdeleter$undo_block_stopsee) reventlimitr)firstlastdatacomment_headernewdatas rformat_paragraph_event&FormatParagraph.format_paragraph_event*s#(-U||  ll88:  T88E(D/5N#4H)=> .E &tNCG(5G ue, ? MM(E *  ! ! # KK $ KK '  " MM(D ) rr r ) __name__ __module__ __qualname____firstlineno____doc__r classmethodrr!r>__static_attributes__rrrrs, PP$rrc[[URS55up#URSU-SU-5nUR SU-SS5(aZ[ U5(aJUS-nURSU-SU-5nUR SU-SS5(a[ U5(aMJUn[ U5n[U5n[ U5U:XaR[ XGS5(d@US-nURSU-SU-5n[ U5U:Xa[ XGS5(dM@SU-nUS- nURSU-SU-5nUS:ag[ U5U:XaX[ XGS5(dFUS- nURSU-SU-5nUS:a#[ U5U:Xa[ XGS5(dMFSUS--n XX`RX54$) zReturns the start/stop indices enclosing the paragraph that mark is in. Also returns the comment format string, if any, and paragraph of text between the start/stop indices. .z%d.0z%d.end>+,!ns*GsSZEA#J#$5!C-) aC % UX..JJw~~ JJuRy 99S>rc:^^[T5mSRU4SjURS555n[U[T5- S5n[ X5nURS5nSnUS(dSnUSSnSRU4SjU55U-$)z?Return data reformatted to specified width with comment header.rXc3,># UH oTSv M g7fr rG).0rTlcs r #reformat_comment..s<+;4"#Y+;sNc3.># UH nTU-v M g7fr rG)rorTr<s rrqrrs=WT^D(Ws)rPrbrMmaxr0)r;r8r< format_widthr= block_suffixrps ` @rr/r/s ^ B 99<4::d+;< 22B7L 4GmmD!G L 2; #2, 99=W= = LLrc4[R"SU5SL$)z/Return True if line is empty or all whitespace.z^\s*$N)r\matchrTs rrOrOs 88Hd #4 //rcL[R"SU5R5$)z/Return the initial space or tab indent of line.z ^([ \t]*)r\r{groupr|s rr[r[s 88L$ ' - - //rcZ[R"SU5nUcgURS5$)zReturn string with leading whitespace and '#' from line or ''. A null return indicates that the line is not a comment line. A non- null return, such as ' #', will be used to find the other lines of a comment block with the same indent. z ^([ \t]*#*)rtrKr~)rTms rr,r,s) &Ay 771:rz[ \t]*c[RU5nUR5[UR 5R U554$)zReturn a line's indentation as (# chars, effective # of spaces). The effective # of spaces is the length after properly "expanding" the tabs into spaces, as done by str.expandtabs(tabwidth). )_line_indent_rer{r'rPrr^)rTtabwidthrs rget_line_indentrs; d#A 557C ,,X67 77rcl\rSrSrSrSrSrSrSSjrSSjr SS jr SS jr SS jr SS jr S rSrg) FormatRegionzFormat selected text (region).cXlgr r r s rrFormatRegion.__init__rrcdURRnURR5up#U(a0U(a)URUS-5nURUS-5nO"URS5nURS5nUR XE5nUR S5nXEXg4$)aAReturn line information about the selected text region. If text is selected, the first and last indices will be for the selection. If there is no text selected, the indices will be the current cursor location. Return a tuple containing (first index, last index, string representation of text, list of text lines). z linestartz-1c lineend +1czinsert linestartzinsert lineend +1crX)r r)r*r.r+rM)rr)r9r:headtailcharsrcs r get_regionFormatRegion.get_regions||  ll88:  T::el23D::d%667D::01D::23D$ D!5''rcrURRnSRU5nXc:XaUR5 gUR SSS5 UR SU5 UR 5 URX5 URX5 UR5 URSUS5 g)a!Replace the text between the given indices. Args: head: Starting index of text to replace. tail: Ending index of text to replace. chars: Expected to be string of current text between head and tail. lines: List of new lines to insert between head and tail. rXNr%r&r'r$) r r)rbbellr1r2r3r4r$r5tag_add)rrrrrcr)newcharss r set_regionFormatRegion.set_regions||  99U#   IIK  ue, h%  D D#  UD(+rNcTUR5up#pE[[U55HknXVnU(dM[XpRR 5upXRR -n URRU 5XxS-XV'Mm URX#XE5 g)z$Indent region by indentwidth spaces.Nr() rr]rPrr r indentwidth _make_blanksr rr7rrrrcposrTraw effectives rindent_region_event FormatRegion.indent_region_events#'??#4 EU$C:Dt!0||7L7L!M% (@(@@ !\\66yADJN % E1rchUR5up#pE[[U55HunXVnU(dM[XpRR 5up[ XRR- S5n URRU 5XxS-XV'Mw URX#XE5 g)z$Dedent region by indentwidth spaces.rNr() rr]rPrr rrwrrrrs rdedent_region_event FormatRegion.dedent_region_events#'??#4 EU$C:Dt!0||7L7L!M LL,D,D DaH !\\66yADJN % E1rcUR5up#pE[[U5S- 5HnXVnSU-XV'M URX#XE5 g)zbComment out each line in region. ## is appended to the beginning of each line to comment it out. rK##r(rr]rPrrr7rrrrcrrTs rcomment_region_event!FormatRegion.comment_region_event sQ $(??#4 EUa(C:DEJ) E1rcUR5up#pE[[U55H1nXVnU(dMUSSS:XaUSSnOUSSS:XaUSSnXuU'M3 URX#XE5 g)zUncomment each line in region. Remove ## or # in the first positions of a line. If the comment is not in the beginning position, this command will have no effect. NrYrrK#r(rrs runcomment_region_event#FormatRegion.uncomment_region_event,s $(??#4 EU$C:DBQx4ABxbqSABx#J% E1rcUR5up#pEUR5nUcg[[U55H<nXWnU(dM[ X5up[ X5upSU -SU --XS-XW'M> UR X#XE5 g)z@Convert leading spaces to tabs for each line in selected region.N rZr()r _asktabwidthr]rPrdivmodr) rr7rrrrcrrrTrrntabsnspacess rtabify_region_event FormatRegion.tabify_region_event?s#'??#4 E$$&   U$C:Dt!0!@!' !<!E\C'M9DJF % E1rcUR5up#pEUR5nUcg[[U55HnXWR U5XW'M UR X#XE5 g)z.Expand tabs to spaces for each line in region.Nr()rrr]rPr^r)rr7rrrrcrrs runtabify_region_event"FormatRegion.untabify_region_eventNsb#'??#4 E$$&   U$C..x8EJ% E1rc n[SSURRURRSSS9$)zReturn value for tab width.z Tab widthzColumns per tab? (2-16)rYparent initialvalueminvaluemaxvalue)rr r)rr s rrFormatRegion._asktabwidthYs5  %<<$$11  rr r )r@rArBrCrDrrrrrrrrrrrFrGrrrrs7$(,,0   &  rrc*\rSrSrSrSrSrSrSrg)IndentsidzChange future indents.cXlgr r r s rrIndents.__init__grrcURnURn[SSSU-S-SU-S-S-URS9(aU(+UlS Ulg ) Nz Toggle tabsz Turn tabs )onoffz? Indent width )zwill bez remains atz 8.z! Note: a tab is always 8 columns)rr()r usetabsrr)r)rr7r rs rtoggle_tabs_eventIndents.toggle_tabs_eventjst,,// ]733 !'0138933\\  ##*kGO#$G rc URn[SSURURSSS9nU(a&X2R:waUR(dX2lg)Nz Indent widthz6New indent width (2-16) (Always use 8 when using tabs)rYrrr()r rr)rr)rr7r rhs rchange_indentwidth_event Indents.change_indentwidth_eventzsP,, K &22  3---goo"% rr N) r@rArBrCrDrrrrFrGrrrrds rrc$\rSrSrSrSSjrSrg)RstripicXlgr r r s rrRstrip.__init__rrNcURRnURRnUR5 [ [ UR S555n[SU5H_nURSU-SU-5n[U5n[UR55nX:dMFURSXX4-SU-5 Ma URS5S:Xa[URS5(dgUR S 5S :aRURS 5S:Xa=URS 5 UR S 5S :aURS 5S:XaM=UR5 g) Nr'rKz%i.0z%i.endz%i.%izend-2crXinterpzend-1cr&zend-3c)r r)undor3rfloatr.r]r+rPr`r4hasattrr5) rr7r)rend_linecurtxtrcuts r do_rstripRstrip.do_rstrips*||  ||   uTZZ./0H%C((6C<C8Cc(Ccjjl#Cy Gsj0(S.A& HHX $ &DLL(33::h'%/xx)T1 H%::h'%/xx)T1 rr r )r@rArBrCrrrFrGrrrrs rr__main__)mainzidlelib.idle_test.test_formatrYF) verbosityexit)rDr\tkinter.messageboxrtkinter.simpledialogridlelib.configrrrr-r0r/rOr[r,compilerrrrrr@unittestrrGrrrs '+#@@F">J"HM,0 0 **Y'8MM`!!H@ z (AEBr