Your IP : 216.73.216.85


Current Path : /opt/alt/python310/lib64/python3.10/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/idlelib/__pycache__/squeezer.cpython-310.opt-2.pyc

o

0�i"2�@s�	ddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZddd	�ZGd
d�dej
�ZGdd
�d
�Ze��edkrSddlmZedddd�dSdS)�N)�
messagebox)�idleConf)�	view_text)�Hovertip)�macosx�PcCs�	d}d}d}d}t�d|�D]?}|��|}||7}||7}||dkr8||kr1||d|7}|d7}d}n||||7}||krJ|d7}|}|d7}q|t|�|7}|dkre||d|7}|S|d8}|S)N�r�z[\t\n]�
)�re�finditer�start�len)�sZ	linewidthZtabwidth�posZ	linecountZcurrent_column�m�numchars�r�7/opt/alt/python310/lib64/python3.10/idlelib/squeezer.py�count_lines_with_wrappings2
�rc@sHeZdZ	dd�Zdd�Zddd�Zddd	�Zdd
d�ZdZd
d�Z	dS)�ExpandingButtonc
s��|_||_||_||_|j|_}|j|_}|jj|_|dkr#dnd}d|�d|�d�}t	j
j|||ddd	�d
}	t||	dd�|�
d
|j�t��rU|�
d|j�n|�
d|j�|��fdd��d|_|�|j�dS)Nr	�lines�linezSqueezed text (� z).z#FFFFC0z#FFFFE0)�textZ
backgroundZactivebackgroundz5Double-click to expand, right-click for more options.r)Zhover_delayz<Double-Button-1>z
<Button-2>z
<Button-3>cs�t|�t|�t|��S�N)�int)�offsetZlength�rrr�<lambda>zsz*ExpandingButton.__init__.<locals>.<lambda>)r�tags�
numoflines�squeezer�editwinr�per�bottom�	base_text�tk�Button�__init__rZbind�expandrZisAquaTk�context_menu_eventZselection_handle�is_dangerousZ
after_idle�set_is_dangerous)
�selfrr r!r"r#rZline_pluralityZbutton_textZbutton_tooltip_textrrrr)_s0
��
�zExpandingButton.__init__csLd|j���|jdkp"t|j�dkp"t�fdd�t�d|j�D��|_dS)N�2i�iP�c3s"�|]}t|�d���kVqdS)rN)r�group)�.0Z
line_match�Zdangerous_line_lenrr�	<genexpr>�s
��
�z3ExpandingButton.set_is_dangerous.<locals>.<genexpr>z[^\n]+)	rZwinfo_widthr!rr�anyrrr,)r.rr2rr-s
���z ExpandingButton.set_is_dangerousNcCs�	|jdur
|��|jr)tjdd�gd��|jt|j�ftj|j	d�}|s)dS|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-rZaskokcancel�joinr!rrZCANCELr�indexr&�insertr �deleter#Zon_squeezed_expandr"�expandingbuttons�remove)r.�eventZconfirmr;rrrr*�s&
��
zExpandingButton.expandcCs	|��|�|j�dSr)Zclipboard_clearZclipboard_appendr�r.r@rrr�copy�szExpandingButton.copycCs	t|jd|jddd�dS)NzSqueezed Output ViewerFZnone)ZmodalZwrap)rrrrArrr�view�s
�zExpandingButton.view))rBrB)rCrCcCsb|j�dd|j|jf�tj|jdd�}|jD]\}}|j|t||�d�q|�	|j
|j�dS)Nr<z@%d,%dr)Ztearoff)�labelZcommandr9)rZmark_set�x�yr'ZMenu�rmenu_specsZadd_command�getattrZtk_popupZx_rootZy_root)r.r@ZrmenurDZmethod_namerrrr+�sz"ExpandingButton.context_menu_eventr)
�__name__�
__module__�__qualname__r)r-r*rBrCrGr+rrrrrTs
 


rc@s2eZdZ	edd��Zdd�Zdd�Zdd�Zd	S)
�SqueezercCs	tjdddddd�|_dS)N�mainZPyShellzauto-squeeze-min-linesrr/)�typer7)rZ	GetOption�auto_squeeze_min_lines)�clsrrr�reload�s
�zSqueezer.reloadcsf	|�_|j�_�|jj�_dt��d��t��d���_g�_d|j	f��fdd�	}||_	dS)N�Zborder�padxrcs�|dkr	|||�S�j}t|�|kr|||�S��|�}||kr%|||�St|||��}��dtj��jd|ddd���d���	���dtj
��j�|�dS)N�stdoutZiomark���ZwindowrSZpady)
rOr�count_linesrZmark_gravityr'ZRIGHT�
window_createZsee�updateZLEFTr>�append)rr �writerOr!�expandingbutton�r.rrr�mywrite�s"



�
z"Squeezer.__init__.<locals>.mywrite)
r#rr$r%r&rZcgetZwindow_width_deltar>r\)r.r#r_rr^rr)�s	
��
zSqueezer.__init__cCs	t||jj�Sr)rr#�width)r.rrrrrXs
zSqueezer.count_linesc	Cs0	|j�tj�}dD]}||vrnq
|j��dS|j�|tjd�\}}|j�||�}t|�dkrG|ddkrG|j�d|�}|dd�}|j	�
||�|�|�}t||||�}|jj
||dd	d
�t|j�}|dkr�|j�|j|dd|�r�|d8}|dkr�|j�|j|dd|�sz|j�||�dS)
N)rT�stderrr9z+1cr���r
z%s-1crUrVrWr	�>)r�	tag_namesr'ZINSERTZbellZ
tag_prevrange�getrr;r&r=rXrrYr>Zcomparer<)	r.rdZtag_namer
�endrr!r]�irrr�squeeze_current_text"s:�


�
���zSqueezer.squeeze_current_textN)rIrJrK�classmethodrQr)rXrhrrrrrL�s
?
rL�__main__)rMzidlelib.idle_test.test_squeezerrRF)�	verbosity�exit)r)rZtkinterr'rZidlelib.configrZidlelib.textviewrZidlelib.tooltiprZidlelibrrr(rrLrQrIZunittestrMrrrr�<module>s"
8t�