Current File : //usr/local/apps/python3/lib/python3.11/idlelib/__pycache__/squeezer.cpython-311.opt-2.pyc
�

�Ke"2���	ddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZdd�ZGd	�d
ej
��ZGd�d��Ze���ed
krddlmZeddd���dSdS)�N)�
messagebox)�idleConf)�	view_text)�Hovertip)�macosx�Pc�f�	d}d}d}d}tjd|��D]e}|���|z
}||z
}||z
}||dkr||kr||dz
|zz
}|dz
}d}n||||zz
z
}||kr|dz
}|}|dz
}�f|t|��|z
z
}|dkr||dz
|zz
}n|dz}|S)N�r�z[\t\n]�
)�re�finditer�start�len)�s�	linewidth�tabwidth�pos�	linecount�current_column�m�numcharss        �:/usr/local/apps/python3/lib/python3.11/idlelib/squeezer.py�count_lines_with_wrappingrs"����H�
�C��I��N�
�[��A�
&�
&�����7�7�9�9�s�?���x����(�"��
�S�6�T�>�>��	�)�)��n�q�0�Y�>�>�	���N�I��N�N�
�h�.�8�*C�D�D�N��	�)�)��Q��	�!)���q�����c�!�f�f�s�l�"�N������n�q�(�Y�6�6�	�	�	�Q��	���c�>�eZdZ	d�Zd�Zd	d�Zd	d�Zd	d�ZdZd�Z	dS)
�ExpandingButtonc�l���|_||_||_||_|jx|_}|jx|_}|jj|_|dkrdnd}d|�d|�d�}tj
�|||dd�	��d
}	t||	d���|�
d
|j��tj��r|�
d|j��n|�
d|j��|��fd���d|_|�|j��dS)Nr�lines�linezSqueezed text (� z).z#FFFFC0z#FFFFE0)�text�
background�activebackgroundz5Double-click to expand, right-click for more options.r)�hover_delayz<Double-Button-1>z
<Button-2>z
<Button-3>c�l���t|��t|��t|��z�S�N)�int)�offset�lengthrs  �r�<lambda>z*ExpandingButton.__init__.<locals>.<lambda>zs(���1�S��[�[��V���s�6�{�{�1J�%J�#K�r)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,r-r.r/r"�line_plurality�button_text�button_tooltip_texts
 `        rr5zExpandingButton.__init___se��������	�$��� ��
�!)�!1�1���w�"�<�'��	�D� ��+���$.�!�O�O�����G�
�G�G�^�G�G�G��
�	���4��K�&/�)�	�	M�	M�	M�
D�	�	��*��;�;�;�;��	�	�%�t�{�3�3�3��?���	=��I�I�l�D�$;�<�<�<�<��I�I�l�D�$;�<�<�<����K�K�K�K�	M�	M�	M�!�������-�.�.�.�.�.rc���d|j���z�|jdkpJt|j��dkp2t�fd�t
jd|j��D����|_dS)N�2i�iP�c3�d�K�|]*}t|�d�����kV��+dS)rN)r�group)�.0�
line_match�dangerous_line_lens  �r�	<genexpr>z3ExpandingButton.set_is_dangerous.<locals>.<genexpr>�sS���������J�$�$�Q�'�'�(�(�,>�>������rz[^\n]+)	r"�winfo_widthr-rr�anyr
rr;)r>rHs @rr=z ExpandingButton.set_is_dangerouss�����$�)�"7�"7�"9�"9�9���O�d�"�
����K�K�%��
������"$�+�i���"@�"@����
�
�	
���rNc�B�	|j�|���|jr\tjdd�gd���|jt
|j��fztj|j	���}|sdS|j	�
|��}|j�||j|j
��|j�|��|j�||j|j
��|jj�|��dS)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�joinr-rr�CANCELr"�indexr2�insertr,�deleter/�on_squeezed_expandr.�expandingbuttons�remove)r>�event�confirmrUs    rr7zExpandingButton.expand�s"��	���$��!�!�#�#�#���	� �,�+����%�%�%���
�o�s�4�6�{�{�3�4�#�)��y�	"�	"�	"�G��
��w��	����%�%������e�T�V�T�Y�7�7�7�����d�#�#�#���'�'��t�v�t�y�A�A�A��
�&�-�-�d�3�3�3�3�3rc�d�	|���|�|j��dSr')�clipboard_clear�clipboard_appendr�r>r[s  r�copyzExpandingButton.copy�s7��	�	
���������d�f�%�%�%�%�%rc�D�	t|jd|jdd���dS)NzSqueezed Output ViewerF�none)�modal�wrap)rr"rr`s  r�viewzExpandingButton.view�s:��	�	�$�)�5�t�v��F�	,�	,�	,�	,�	,�	,r))rara)rfrfc�4�|j�dd|j|jfz��t	j|jd���}|jD]*\}}|�|t||������+|�	|j
|j��dS)NrVz@%d,%dr)�tearoff)�label�commandrQ)r"�mark_set�x�yr3�Menu�rmenu_specs�add_command�getattr�tk_popup�x_root�y_root)r>r[�rmenuri�method_names     rr9z"ExpandingButton.context_menu_event�s����	���8�X���%�'�0B�%B�C�C�C����	�1�-�-�-��"&�"2�	O�	O��E�;����E�7�4��3M�3M��N�N�N�N�
���u�|�U�\�2�2�2��wrr')
�__name__�
__module__�__qualname__r5r=r7rarfror9�rrrrTs�������	�/�/�/�@	
�	
�	
�4�4�4�4�>&�&�&�&�,�,�,�,��K�����rrc�8�eZdZ	ed���Zd�Zd�Zd�ZdS)�Squeezerc�D�	tjddddd���|_dS)N�main�PyShellzauto-squeeze-min-linesr(rC)�typerO)r�	GetOption�auto_squeeze_min_lines)�clss r�reloadzSqueezer.reload�s2��/�%-�%7��I�7���&
�&
�&
��"�"�"rc�*���	|�_|jx�_�|jj�_dt��d����t��d����zz�_g�_d|j	f��fd�	}||_	dS)N��border�padxrzc�"��|dkr|||��S�j}t|��|kr|||��S��|��}||kr|||��St|||���}��dt
j����d|dd�����d����	����dt
j
���j�|��dS)N�stdout�iomark����windowr��pady)
r�r�count_linesr�mark_gravityr3�RIGHT�
window_create�see�update�LEFTrY�append)rr,�writer�r-�expandingbuttonr>r"s      ��r�mywritez"Squeezer.__init__.<locals>.mywrite�s%����x����u�Q��~�~�%�&*�%@�"��1�v�v�.�.�.��u�Q��~�~�%��)�)�!�,�,�J��2�2�2��u�Q��~�~�%�.�a��z�4�H�H�O�
���h���1�1�1����x��$%�A�
�
/�
/�
/��H�H�X�����K�K�M�M�M����h���0�0�0�
�!�(�(��9�9�9�9�9r)
r/r"r0r1r2r(�cget�window_width_deltarYr�)r>r/r�r"s`  @rr5zSqueezer.__init__�s�����	����"�<�'��	�D�!��+���#$���	�	�(�#�#�$�$���	�	�&�!�!�"�"�
#�#
���
!#����g�m�	:�	:�	:�	:�	:�	:�	:�< ��
�
�
rc�8�	t||jj��Sr')rr/�width)r>rs  rr�zSqueezer.count_liness��		�)��D�L�,>�?�?�?rc��	|j�tj��}dD]}||vrn�	|j���dS|j�|tjdz��\}}|j�||��}t|��dkr3|ddkr'|j�d|z��}|dd�}|j	�
||��|�|��}t||||��}|j�
||dd	�
��t|j��}|dkr_|j�|j|dz
d|��r5|dz}|dkr*|j�|j|dz
d|���5|j�||��dS)
N)r��stderrrQz+1cr���rz%s-1cr�r�r�r�>)r"�	tag_namesr3�INSERT�bell�
tag_prevrange�getrrUr2rWr�rr�rY�comparerV)	r>r��tag_namer�endrr-r��is	         r�squeeze_current_textzSqueezer.squeeze_current_text"s���	��I�'�'��	�2�2�	�,�	�	�H��9�$�$���%�
�I�N�N�����7��Y�,�,�X�r�y�5�7H�I�I�
��s��I�M�M�%��%�%���q�6�6�A�:�:�!�B�%�4�-�-��)�/�/�'�C�-�0�0�C��#�2�#��A�	
����e�S�)�)�)��%�%�a�(�(�
�)�!�X�z�4�H�H��	
�	����o�%&�Q�	 �	0�	0�	0�
��%�&�&���!�e�e��	�)�)�$�*?��!��*D�*-��@�@�e�
��F�A��!�e�e��	�)�)�$�*?��!��*D�*-��@�@�e�	
��$�$�Q��8�8�8��wrN)rwrxry�classmethodr�r5r�r�rzrrr|r|�se�������
�
�
��[�
�= �= �= �~@�@�@�-�-�-�-�-rr|�__main__)r~zidlelib.idle_test.test_squeezerr�F)�	verbosity�exit)r)r
�tkinterr3r�idlelib.configr�idlelib.textviewr�idlelib.tooltipr�idlelibrrr4rr|r�rw�unittestr~rzrr�<module>r�sM��� 
�	�	�	�����������#�#�#�#�#�#�&�&�&�&�&�&�$�$�$�$�$�$�������5�5�5�5�pq�q�q�q�q�b�i�q�q�q�hG�G�G�G�G�G�G�G�T	�������z����������D�	*�a�e�D�D�D�D�D�D��r