Your IP : 216.73.216.52


Current Path : /opt/alt/python38/lib64/python3.8/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/idlelib/__pycache__/squeezer.cpython-38.opt-2.pyc

U

i�f2�@s�ddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZddd	�ZGd
d�dej
�ZGdd
�d
�Ze��edkr�ddlmZedddd�dS)�N)�
messagebox)�idleConf)�	view_text)�Hovertip)�macosx�PcCs�d}d}d}d}t�d|�D]~}|��|}||7}||7}||dkrn||kr`||d|7}|d7}d}n$||||7}||kr�|d7}|}|d7}q|t|�|7}|dkr�||d|7}n|d8}|S)N�r�z[\t\n]�
)�re�finditer�start�len)�sZ	linewidthZtabwidth�posZ	linecountZcurrent_column�m�numchars�r�5/opt/alt/python38/lib64/python3.8/idlelib/squeezer.py�count_lines_with_wrappings.
rc@sFeZdZdd�Zdd�Zddd�Zddd	�Zdd
d�ZdZd
d�Z	dS)�ExpandingButtonc
s��|_||_||_||_|j|_}|j|_}|jj|_|dkrFdnd}d|�d|�d�}t	j
j|||ddd	�d
}	t||	dd�|�
d
|j�t��r�|�
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>z�z*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*_s2
��
�zExpandingButton.__init__csLd|j���|jdkpDt|j�dkpDt�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/rr3rr.s
���z ExpandingButton.set_is_dangerousNcCs�|jdkr|��|jrTtjdd�ddddg�|jt|j�ftj|j	d�}|sTdS|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"rrZCANCELrr'�insert�indexr!�deleter#�expandingbuttons�remove)r/�eventZconfirmrrrr+�s*	
���
zExpandingButton.expandcCs|��|�|j�dSr)Zclipboard_clearZclipboard_appendr�r/rArrr�copy�szExpandingButton.copycCst|jd|jddd�dS)NzSqueezed Output ViewerFZnone)ZmodalZwrap)rrrrBrrr�view�s�zExpandingButton.view))rCrC)rDrDcCsb|j�dd|j|jf�tj|jdd�}|jD]\}}|j|t||�d�q0|�	|j
|j�dS)Nr<z@%d,%dr)Ztearoff)�labelZcommandr:)rZmark_set�x�yr(ZMenu�rmenu_specsZadd_command�getattrZtk_popupZx_rootZy_root)r/rAZrmenurEZmethod_namerrrr,�sz"ExpandingButton.context_menu_event)N)N)N)
�__name__�
__module__�__qualname__r*r.r+rCrDrHr,rrrrrTs 


rc@s0eZdZedd��Zdd�Zdd�Zdd�Zd	S)
�SqueezercCstjdddddd�|_dS)N�mainZPyShellzauto-squeeze-min-linesrr0)�typer8)rZ	GetOption�auto_squeeze_min_lines)�clsrrr�reload�s�zSqueezer.reloadcsd|�_|j�_�|jj�_dt��d��t��d���_g�_d|j	f��fdd�	}||_	dS)N�Zborder�padxrcs�|dkr|||�S�j}t|�|kr.|||�S��|�}||krJ|||�St|||��}��dtj��jd|ddd���d���	���dtj
��j�|�dS)N�stdoutZiomark���ZwindowrTZpady)
rPr�count_linesrZmark_gravityr(ZRIGHT�
window_createZsee�updateZLEFTr?�append)rr!�writerPr"�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__cCst||jj�Sr)rr$�width)r/rrrrrYszSqueezer.count_linesc
Cs|j�tj�}dD]}||krq2q|j��dS|j�|tjd�\}}|j�||�}t|�dkr�|ddkr�|j�d|�}|dd�}|j	�
||�|�|�}t||||�}|jj
||dd	d
�t|j�}	|	dkr�|j�|j|	dd|�r�|	d8}	q�|j�|	|�dS)
N)rU�stderrr:z+1cr���r
z%s-1crVrWrXr	�>)r�	tag_namesr(ZINSERTZbellZ
tag_prevrange�getrr=r'r>rYrrZr?Zcomparer<)
r/rAreZtag_namer
�endrr"r^�irrr�squeeze_current_text_event s4	


�
�
z#Squeezer.squeeze_current_text_eventN)rJrKrL�classmethodrRr*rYrirrrrrM�s

?
rM�__main__)rNzidlelib.idle_test.test_squeezerrSF)�	verbosity�exit)r)rZtkinterr(rZidlelib.configrZidlelib.textviewrZidlelib.tooltiprZidlelibrrr)rrMrRrJZunittestrNrrrr�<module>s
8r