HEX
Server: Apache/2.4.65 (Unix) OpenSSL/1.1.1k
System: Linux vps109042.inmotionhosting.com 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: cisa (1010)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //opt/imh/python3.13/lib/python3.13/idlelib/__pycache__/format.cpython-313.pyc
�

��e�=���SrSSKrSSKJr SSKJr SSKJr "SS5r\R5 Sr
S	rS
rSr
SrS
r\R "S5rSr"SS5r"SS5r"SS5r\S:XaSSKJr \"SSSS9 gg)z�Format 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)
�FormatParagraph�a�Format 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 :-)
c��Xlg�N��editwin��selfrs  �4/opt/imh/python3.13/lib/python3.13/idlelib/format.py�__init__�FormatParagraph.__init__�����c�>�[R"SSSSSS9Ulg)N�
extensionsrz	max-width�int�H)�type�default)r�	GetOption�	max_width)�clss r�reload�FormatParagraph.reload"s!�� �*�*�<�9J�+6�U�B�P��
rc��SUlgr
r�rs r�close�FormatParagraph.close's	����rNc�x�UcUROUnURRnURR5upEU(a$U(aUR	XE5n[U5nO[
X3RS55upEpvU(a
[XbU5nO[Xb5nURSSS5 X�:waUURSU5 UR5 URXE5 URXH5 UR5 OURSU5 UR!S5 g)a�Formats 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.
�insert�sel�1.0�end�break)rr�text�get_selection_indices�get�get_comment_header�find_paragraph�index�reformat_comment�reformat_paragraph�
tag_remove�mark_set�undo_block_start�deleter$�undo_block_stop�see)	r�event�limitr)�first�last�data�comment_header�newdatas	         r�format_paragraph_event�&FormatParagraph.format_paragraph_event*s���#(�-����U���|�|� � ���l�l�8�8�:����T��8�8�E�(�D�/��5�N�#�4���H�)=�>�
.�E���&�t�N�C�G�(��5�G�����u�e�,��?��M�M�(�E�*��!�!�#��K�K��$��K�K��'�� � �"��M�M�(�D�)������rrr
)�__name__�
__module__�__qualname__�__firstlineno__�__doc__r�classmethodrr!r>�__static_attributes__�rrrrs,��� ��P��P��$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	X�X`RX�54$)	z�Returns 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�<r'�Nr)�mapr�splitr+�compare�is_all_whiter,�len)
r)�mark�lineno�col�line�first_linenor<�comment_header_lenr:r9s
          rr-r-Ss����c�4�:�:�c�?�+�K�F��8�8�F�V�O�X��%6�7�D��,�,�v����U�
3�
3��T�8J�8J��!����x�x�����F�):�;���,�,�v����U�
3�
3��T�8J�8J��L�'��-�N��^�,���T�
"�N�
2��t�$7�8�9�9��!����x�x�����F�):�;���T�
"�N�
2��t�$7�8�9�9��F�?�D��A�
�F��8�8�F�V�O�X��%6�7�D�
�1�*� ��&��6��t�$7�8�9�9��!����x�x�����F�):�;��	�1�*� ��&��6��t�$7�8�9�9�
�f�Q�h��E������(=�=�=rc��URS5nSn[U5nX4:a0[X#5(aUS-nX4:a[X#5(aMX4:�aU$[X#5nUS-U:a&[X#S-5(d[X#S-5nOUnUSUnUnX4:a�[X#5(d�[R"SX#5n	[S[U	5S5H�n
X�nU(dM[X�-R
55U:�a&X�:wa!URUR55 UnX�-S-nU
S-[U	5:dMpX�S-S:wdM}US-nM� US-nX4:a[X#5(dM�URUR55 URX#S5 SRU5$)z3Return data reformatted to specified width (limit).�
rrKNz(\s+)�� )rMrPrO�
get_indent�re�range�
expandtabs�append�rstrip�extend�join)r;r8�lines�i�n�indent1�indent2�new�partial�words�j�words            rr0r0xs����J�J�t��E�	�A��E�
�A�
�%�L���*�*�
�a�C���%�L���*�*��v������"�G���s�Q�w�|�E�A�#�J�/�/��U�Q�3�Z�(����
���)�C��G�
�%��U�X�.�.�����5�8�,���q�#�e�*�a�(�A��8�D����G�N�.�.�0�1�E�9��%��
�
�7�>�>�+�,�!���n�s�*�G���s�S��Z��E�A�#�J�#�$5�!�C�-��)�
�a�C���%��U�X�.�.��J�J�w�~�~�� ��J�J�u�R�y���9�9�S�>�rc�:^^�[T5mSRU4SjURS555n[U[T5-
S5n[	X5nURS5nSnUS(dSnUSSnSRU4SjU55U-$)z?Return data reformatted to specified width with comment header.rXc3�,># �UH	oTSv� M g7fr
rG)�.0rT�lcs  �r�	<genexpr>�#reformat_comment.<locals>.<genexpr>�s����<�+;�4�"�#�Y�+;�s������Nc3�.># �UH
nTU-v� M g7fr
rG)rorTr<s  �rrqrr�s����=�W�T�^�D�(�W�s�)rPrbrM�maxr0)r;r8r<�format_widthr=�block_suffixrps  `   @rr/r/�s����

�^�	�B��9�9�<�4�:�:�d�+;�<�<�D��u�s�>�2�2�B�7�L� ��4�G��m�m�D�!�G�
�L��2�;����#�2�,���9�9�=�W�=�=��L�Lrc�4�[R"SU5SL$)z/Return True if line is empty or all whitespace.z^\s*$N)r\�match�rTs rrOrO�s���8�8�H�d�#�4�/�/rc�L�[R"SU5R5$)z/Return the initial space or tab indent of line.z	^([ \t]*)�r\r{�groupr|s rr[r[�s��
�8�8�L�$�'�-�-�/�/rc�Z�[R"SU5nUcgURS5$)z�Return 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~)rT�ms  rr,r,�s)��	�����&�A��y���7�7�1�:�rz[ \t]*c��[RU5nUR5[UR	5RU554$)z�Return 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^)rT�tabwidthr�s   r�get_line_indentr��s;��	���d�#�A��5�5�7�C����	�,�,�X�6�7�7�7rc�l�\rSrSrSrSrSrSrSSjrSSjr	SS	jr
SS
jrSSjrSSjr
S
rSrg)�FormatRegion��zFormat selected text (region).c��Xlgr
rr
s  rr�FormatRegion.__init__�rrc�d�URRnURR5up#U(a0U(a)URUS-5nURUS-5nO"URS5nURS5nUR	XE5nURS5nXEXg4$)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:�head�tail�charsrcs        r�
get_region�FormatRegion.get_region�s����|�|� � ���l�l�8�8�:����T��:�:�e�l�2�3�D��:�:�d�%6�6�7�D��:�:�0�1�D��:�:�2�3�D�����$�����D�!���5�'�'rc�r�URRnSRU5nXc:XaUR5 gUR	SSS5 URSU5 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)rb�bellr1r2r3r4r$r5�tag_add)rr�r�r�rcr)�newcharss       r�
set_region�FormatRegion.set_region�s����|�|� � ���9�9�U�#�����I�I�K������u�e�,��
�
�h��%��������D�����D�#��������U�D�(�+rNc�T�UR5up#pE[[U55HknXVnU(dM[XpRR
5up�X�RR-n	URRU	5XxS-XV'Mm URX#XE5 g)z$Indent region by indentwidth spaces.Nr()	r�r]rPr�rr��indentwidth�_make_blanksr��
rr7r�r�r�rc�posrT�raw�	effectives
          r�indent_region_event� FormatRegion.indent_region_events���#'�?�?�#4� ��E���U��$�C��:�D��t�!0��|�|�7L�7L�!M���%���(@�(@�@�	�!�\�\�6�6�y�A�D��J�N��
�%�	
����E�1�rc�h�UR5up#pE[[U55HunXVnU(dM[XpRR
5up�[
X�RR-
S5n	URRU	5XxS-XV'Mw URX#XE5 g)z$Dedent region by indentwidth spaces.rNr()
r�r]rPr�rr�rwr�r�r�r�s
          r�dedent_region_event� FormatRegion.dedent_region_events���#'�?�?�#4� ��E���U��$�C��:�D��t�!0��|�|�7L�7L�!M����	�L�L�,D�,D� D�a�H�	�!�\�\�6�6�y�A�D��J�N��
�%�	
����E�1�rc��UR5up#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(�r�r]rPr��rr7r�r�r�rcr�rTs        r�comment_region_event�!FormatRegion.comment_region_event sQ��
$(�?�?�#4� ��E���U��a��(�C��:�D����E�J�)�	
����E�1�rc���UR5up#pE[[U55H1nXVnU(dMUSSS:XaUSSnOUSSS:XaUSSnXuU'M3 URX#XE5 g)z�Uncomment 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.
NrYr�rK�#r(r�r�s        r�uncomment_region_event�#FormatRegion.uncomment_region_event,s���$(�?�?�#4� ��E���U��$�C��:�D����B�Q�x�4���A�B�x���b�q��S���A�B�x���#�J�%�	
����E�1�rc��UR5up#pEUR5nUcg[[U55H<nXWnU(dM[	X�5up�[X�5up�SU-SU--X�S-XW'M> UR
X#XE5 g)z@Convert leading spaces to tabs for each line in selected region.N�	rZr()r��_asktabwidthr]rPr��divmodr�)
rr7r�r�r�rcr�r�rTr�r��ntabs�nspacess
             r�tabify_region_event� FormatRegion.tabify_region_event?s���#'�?�?�#4� ��E��$�$�&�������U��$�C��:�D��t�!0��!@���!'�	�!<���!�E�\�C�'�M�9�D��J�F��
�%�	
����E�1�rc���UR5up#pEUR5nUcg[[U55HnXWR	U5XW'M URX#XE5 g)z.Expand tabs to spaces for each line in region.Nr()r�r�r]rPr^r�)rr7r�r�r�rcr�r�s        r�untabify_region_event�"FormatRegion.untabify_region_eventNsb��#'�?�?�#4� ��E��$�$�&�������U��$�C���.�.�x�8�E�J�%�����E�1�rc	�n�[SSURRURRSSS9$)zReturn value for tab width.z	Tab widthzColumns per tab? (2-16)rY���parent�initialvalue�minvalue�maxvalue)rrr)r�r s rr��FormatRegion._asktabwidthYs5����%��<�<�$�$����1�1���
�	rrr
)r@rArBrCrDrr�r�r�r�r�r�r�r�r�rFrGrrr�r��s7��$��(�,,�0
�
�
��&
�	�rr�c�*�\rSrSrSrSrSrSrSrg)�IndentsidzChange future indents.c��Xlgr
rr
s  rr�Indents.__init__grrc��URnURn[SSSU-S-SU-S-S-URS9(aU(+UlS	Ulg
)NzToggle tabsz
Turn tabs )�on�offz?
Indent width )zwill bez
remains atz 8.z!
 Note: a tab is always 8 columns)r��r()r�usetabsrr)r�)rr7rr�s    r�toggle_tabs_event�Indents.toggle_tabs_eventjst���,�,���/�/�����]�7�3�3� �!�'��0�1�38�9�3�3��\�\�
#�#*�k�G�O�#$�G��rc	��URn[SSURURSSS9nU(a&X2R:waUR(dX2lg)NzIndent widthz6New indent width (2-16)
(Always use 8 when using tabs)rYr�r�r()rrr)r�r�)rr7rrhs    r�change_indentwidth_event� Indents.change_indentwidth_eventzsP���,�,��� �K� ���&�2�2���
���3�-�-�-�g�o�o�"%��rrN)	r@rArBrCrDrr�r�rFrGrrr�r�ds����� rr�c�$�\rSrSrSrSSjrSrg)�Rstripi�c��Xlgr
rr
s  rr�Rstrip.__init__�rrNc���URRnURRnUR5 [	[UR
S555n[SU5H_nURSU-SU-5n[U5n[UR55nX�:dMFURSXX4-SU-5 Ma URS5S:Xa�[URS5(dgUR
S	5S
:�aRURS5S:Xa=URS5 UR
S	5S
:�aURS5S:XaM=UR5 g)Nr'rKz%i.0z%i.endz%i.%izend-2crX�interpzend-1cr&zend-3c)rr)�undor3r�floatr.r]r+rPr`r4�hasattrr5)	rr7r)r��end_line�cur�txtr��cuts	         r�	do_rstrip�Rstrip.do_rstrip�s*���|�|� � ���|�|� � �������u�T�Z�Z��.�/�0����H�%�C��(�(�6�C�<��C��8�C��c�(�C��c�j�j�l�#�C��y����G�s�j�0�(�S�.�A�&�
�H�H�X��$�&��D�L�L�(�3�3��:�:�h�'�%�/��x�x��)�T�1����H�%��:�:�h�'�%�/��x�x��)�T�1�	
���rrr
)r@rArBrCrr�rFrGrrr�r��s���rr��__main__)�mainzidlelib.idle_test.test_formatrYF)�	verbosity�exit)rDr\�tkinter.messageboxr�tkinter.simpledialogr�idlelib.configrrrr-r0r/rOr[r,�compiler�r�r�r�r�r@�unittestr�rGrr�<module>r�s����
�'�+�#�@�@�F����">�J"�HM�,0�
0�	��*�*�Y�'��8�M�M�`!�!�H��@�z����	(�A�E�B�r