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__/squeezer.cpython-313.pyc
�

��e"2����SrSSKrSSKrSSKJr SSKJr SSKJr SSK	J
r
 SSKJr SSjr
"S	S
\R5r"SS5r\R#5 \S
:XaSSKJr \"SSSS9 gg)aAn IDLE extension to avoid having very long texts printed in the shell.

A common problem in IDLE's interactive shell is printing of large amounts of
text into the shell. This makes looking at the previous history difficult.
Worse, this can cause IDLE to become very slow, even to the point of being
completely unusable.

This extension will automatically replace long texts with a small button.
Double-clicking this button will remove it and insert the original text instead.
Middle-clicking will copy the text to the clipboard. Right-clicking will open
the text in a separate viewing window.

Additionally, any output can be manually "squeezed" by the user. This includes
output written to the standard error stream ("stderr"), such as exception
messages and their tracebacks.
�N)�
messagebox)�idleConf)�	view_text)�Hovertip)�macosxc�^�SnSnSnSn[R"SU5HanUR5U-
nX7-
nXW-
nXS:XaXQ:�a
XES-
U--
nUS-
nSnOXS:XdeXRXR--
-
nXQ:�aUS-
nUnUS-
nMc U[U5U-
-
nUS:�aXES-
U--
nU$US-nU$)z�Count the number of lines in a given string.

Lines are counted as if the string was wrapped so that lines are never over
linewidth characters long.

Tabs are considered tabwidth characters long.
�r�z[\t\n]�
�	)�re�finditer�start�len)�s�	linewidth�tabwidth�pos�	linecount�current_column�m�numcharss        �6/opt/imh/python3.13/lib/python3.13/idlelib/squeezer.py�count_lines_with_wrappingrs���H�
�C��I��N�
�[�[��A�
&���7�7�9�s�?������"��
�6�T�>��)��q�0�Y�>�>�	���N�I��N��6�T�>�!�>��.�*C�D�D�N��)��Q��	�!)���q���;'�@�c�!�f�s�l�"�N�����q�(�Y�6�6�	�
��	�Q��	���c�L�\rSrSrSrSrSrSSjrSSjrSSjr	S	r
S
rSrg)
�ExpandingButton�Ta�Class for the "squeezed" text buttons used by Squeezer

These buttons are displayed inside a Tk Text widget in place of text. A
user can then use the button to replace it with the original text, copy
the original text to the clipboard or view the original text in a separate
window.

Each button is tied to a Squeezer instance, and it knows to update the
Squeezer instance when it is expanded (and therefore removed).
c�^�TUlX lX0lX@lUR=UlnUR
=UlnURRUlUS:waSOSnSUSUS3n[RRXUSSS	9 S
n	[X	SS9 URS
UR5 [R "5(aURSUR"5 OURSUR"5 UR%U4Sj5 SUlUR)UR*5 g)Nr
�lines�linezSqueezed text (� z).z#FFFFC0z#FFFFE0)�text�
background�activebackgroundz5Double-click to expand, right-click for more options.�P)�hover_delayz<Double-Button-1>z
<Button-2>z
<Button-3>c�J>�T[U5[U5[U5-$�N)�int)�offset�lengthrs  �r�<lambda>�*ExpandingButton.__init__.<locals>.<lambda>zs���1�S��[��V��s�6�{�1J�#Kr)r�tags�
numoflines�squeezer�editwinr#�per�bottom�	base_text�tk�Button�__init__r�bind�expandr�isAquaTk�context_menu_event�selection_handle�is_dangerous�
after_idle�set_is_dangerous)
�selfrr/r0r1r2r#�line_plurality�button_text�button_tooltip_texts
 `        rr8�ExpandingButton.__init___s�������	�$�� �
�!)�!1�!1�1���w�"�<�<�'��	�D� ���+�+���$.�!�O����'�
�|�1�^�4D�B�G��
�	�	���4�K�&/�)�	�	M�
D�	�	���;��	�	�%�t�{�{�3��?�?����I�I�l�D�$;�$;�<��I�I�l�D�$;�$;�<����K�	M�!�������-�-�.rc�^�SURR5-mURS:�=(dS [UR5S:�=(d4 [U4Sj[R"SUR555Ulg)N�2i�iP�c3�^># �UH"n[URS55T:�v� M$ g7f)rN)r�group)�.0�
line_match�dangerous_line_lens  �r�	<genexpr>�3ExpandingButton.set_is_dangerous.<locals>.<genexpr>�s.�����"@�J��J�$�$�Q�'�(�,>�>�"@�s�*-z[^\n]+)	r#�winfo_widthr0rr�anyr
rr>)rArLs @rr@� ExpandingButton.set_is_dangeroussm����$�)�)�"7�"7�"9�9���O�O�d�"�
�����K�%��
���"$�+�+�i����"@��
�	
�rNc��URcUR5 UR(aj[R"SSR	/SQ5UR
[
UR54-[RURS9nU(dgURRU5nURRX0RUR5 URRU5 URR!X0RUR5 UR"R$R'U5 g)aexpand event handler

This inserts the original text in place of the button in the Text
widget, removes the button and updates the Squeezer instance.

If the original text is dangerously long, i.e. expanding it could
cause a performance degradation, ask the user for confirmation.
NzExpand huge output?z

)z5The squeezed output is very long: %d lines, %d chars.z2Expanding it could make IDLE slow or unresponsive.z5It is recommended to view or copy the output instead.zReally expand?)�title�message�default�parent�break)r>r@r�askokcancel�joinr0rr�CANCELr#�indexr5�insertr/�deleter2�on_squeezed_expandr1�expandingbuttons�remove)rA�event�confirmr[s    rr:�ExpandingButton.expand�s������$��!�!�#���� �,�,�+����%��
�o�o�s�4�6�6�{�3�4�#�)�)��y�y�	"�G����	�	����%�������e�V�V�T�Y�Y�7������d�#����'�'��v�v�t�y�y�A��
�
�&�&�-�-�d�3rc�Z�UR5 URUR5 g)z=copy event handler

Copy the original text to the clipboard.
N)�clipboard_clear�clipboard_appendr�rAras  r�copy�ExpandingButton.copy�s"��
	
�������d�f�f�%rc�F�[URSURSSS9 g)zMview event handler

View the original text in a separate text viewer window.
zSqueezed Output ViewerF�none)�modal�wrapN)rr#rrgs  r�view�ExpandingButton.view�s ��
	�$�)�)�5�t�v�v��F�	,r))rhrh)rnrnc�T�URRSSURUR4-5 [R
"URSS9nURHup4URU[X5S9 M  URURUR5 g)Nr\z@%d,%dr)�tearoff)�label�commandrW)r#�mark_set�x�yr6�Menu�rmenu_specs�add_command�getattr�tk_popup�x_root�y_root)rAra�rmenurr�method_names     rr<�"ExpandingButton.context_menu_event�s����	�	���8�X����%�'�'�0B�%B�C�����	�	�1�-��"&�"2�"2��E����E�7�4�3M��N�#3�
���u�|�|�U�\�\�2�r)r5r2r>r0rr1r/r#r))
�__name__�
__module__�__qualname__�__firstlineno__�__doc__r8r@r:rhrnrxr<�__static_attributes__�rrrrTs-��	�/�@	
�4�>&�,��K�rrc�:�\rSrSrSr\S5rSrSrSr	Sr
g)	�Squeezer��z�Replace long outputs in the shell with a simple button.

This avoids IDLE's shell slowing down considerably, and even becoming
completely unresponsive, when very long outputs are written.
c�>�[R"SSSSSS9Ulg)z!Load class variables from config.�main�PyShellzauto-squeeze-min-linesr*rG)�typerUN)r�	GetOption�auto_squeeze_min_lines)�clss r�reload�Squeezer.reload�s$��&.�%7�%7��I�7���&
��"rc�0^^�UTlUR=TlmURRTlS[TR
S55[TR
S55--Tl/TlSUR4UU4SjjnX!l	g)a-Initialize settings for Squeezer.

editwin is the shell's Editor window.
self.text is the editor window text widget.
self.base_test is the actual editor window Tk text widget, rather than
    EditorWindow's wrapper.
self.expandingbuttons is the list of all buttons representing
    "squeezed" output.
��border�padxr�c��>�US:waU"X5$TRn[U5U:aU"X5$TRU5nXC:aU"X5$[XUT5nTR	S[
R5 TRSUSSS9 TRS5 TR5 TR	S[
R5 TRRU5 g)N�stdout�iomark����windowr��pady)
r�r�count_linesr�mark_gravityr6�RIGHT�
window_create�see�update�LEFTr_�append)rr/�writer�r0�expandingbuttonrAr#s      ��r�mywrite�"Squeezer.__init__.<locals>.mywrite�s�����x���Q�~�%�&*�%@�%@�"��1�v�.�.��Q�~�%��)�)�!�,�J��2��Q�~�%�.�a�z�4�H�O�
���h����1����x��$%�A�
�
/��H�H�X���K�K�M����h����0�
�!�!�(�(��9rN)
r2r#r3r4r5r*�cget�window_width_deltar_r�)rAr2r�r#s`  @rr8�Squeezer.__init__�s�������"�<�<�'��	�D�!���+�+���#$���	�	�(�#�$���	�	�&�!�"�
#�#
���
!#����g�m�m�	:�	:�< �
rc�@�[XRR5$)a2Count the number of lines in a given text.

Before calculation, the tab width and line length of the text are
fetched, so that up-to-date values are used.

Lines are counted as if the string was wrapped so that lines are never
over linewidth characters long.

Tabs are considered tabwidth characters long.
)rr2�width)rArs  rr��Squeezer.count_liness��)��L�L�,>�,>�?�?rc��URR[R5nSH
nX!;dM
 O URR	5 gURRU[RS-5up4URR
X45n[U5S:�a,USS:Xa#URRSU-5nUSSnURRX45 URU5n[XRX`5nURRX7S	S
S9 [UR5nUS:�aqURRURUS-
S
U5(a?US-nUS:�a4URRURUS-
S
U5(aM?URR!X�5 g)z�Squeeze the text block where the insertion cursor is.

If the cursor is not in a squeezable block of text, give the
user a small warning and do nothing.
)r��stderrrWz+1cr���rz%s-1cNr�r�r�r
�>)r#�	tag_namesr6�INSERT�bell�
tag_prevrange�getrr[r5r]r�rr�r_�comparer\)	rAr��tag_namer�endrr0r��is	         r�squeeze_current_text�Squeezer.squeeze_current_text"s����I�I�'�'��	�	�2�	�,�H��$��-�

�I�I�N�N����Y�Y�,�,�X�r�y�y�5�7H�I�
���I�I�M�M�%�%���q�6�A�:�!�B�%�4�-��)�)�/�/�'�C�-�0�C��#�2��A�	
�����e�)��%�%�a�(�
�)�!�z�H��	
�	�	����%&�Q�	 �	0�
��%�%�&���!�e��	�	�)�)�$�*?�*?��!��*D�*-��@�@�
��F�A��!�e��	�	�)�)�$�*?�*?��!��*D�*-��@�@�	
���$�$�Q�8�r)r5r2r_r#r�N)r�r�r�r�r��classmethodr�r8r�r�r�r�rrr�r��s,���
�
��
�= �~@�-rr��__main__)r�zidlelib.idle_test.test_squeezerr�F)�	verbosity�exit)r&)r�r
�tkinterr6r�idlelib.configr�idlelib.textviewr�idlelib.tooltipr�idlelibrrr7rr�r�r��unittestr�r�rr�<module>r�sr��� 
���#�&�$��5�pq�b�i�i�q�hG�G�T	�����z����	*�a�e�D�r