Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/idlelib/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/idlelib/__pycache__/squeezer.cpython-39.opt-2.pyc

a

��g2�@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�,/usr/local/lib/python3.9/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)�offset�length�rrr�<lambda>z�z*ExpandingButton.__init__.<locals>.<lambda>)r�tags�
numoflines�squeezer�editwinr�per�bottom�	base_text�tk�Button�__init__r�bind�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���|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/)r1rr5rr0s
���z ExpandingButton.set_is_dangerousNcCs�|jdur|��|jrPtjdd�gd��|jt|j�ftj|j	d�}|sPdS|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/r0rZaskokcancel�joinr#rrZCANCELrr(�insert�indexr"�deleter$�expandingbuttons�remove)r1�eventZconfirmrrrr-�s 	
��
zExpandingButton.expandcCs|��|�|j�dSr)Zclipboard_clearZclipboard_appendr�r1rCrrr�copy�szExpandingButton.copycCst|jd|jddd�dS)NzSqueezed Output ViewerFZnone)Zmodal�wrap)rrrrDrrr�view�s�zExpandingButton.view))rErE)rGrGcCsb|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)r1rCZrmenurHZmethod_namerrrr.�sz"ExpandingButton.context_menu_event)N)N)N)
�__name__�
__module__�__qualname__r+r0r-rErGrKr.rrrrrTs 


rc@s0eZdZedd��Zdd�Zdd�Zdd�Zd	S)
�SqueezercCstjdddddd�|_dS)N�mainZPyShellzauto-squeeze-min-linesrr2)�typer:)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���ZwindowrWZpady)
rSr�count_linesrZmark_gravityr)ZRIGHT�
window_createZsee�updateZLEFTrA�append)rr"�writerSr#�expandingbutton�r1rrr�mywrite�s"



�
z"Squeezer.__init__.<locals>.mywrite)
r%rr&r'r(rZcgetZwindow_width_deltarAr`)r1r%rcrrbrr+�s

��zSqueezer.__init__cCst||jj�Sr)rr%�width)r1rrrrr\szSqueezer.count_linesc
Cs|j�tj�}dD]}||vrq2q|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)rX�stderrr<z+1cr���r
z%s-1crYrZr[r	�>)r�	tag_namesr)ZINSERTZbellZ
tag_prevrange�getrr?r(r@r\rr]rAZcomparer>)
r1rCrhZtag_namer
�endrr#ra�irrr�squeeze_current_text_event s0	


�
�
z#Squeezer.squeeze_current_text_eventN)rMrNrO�classmethodrUr+r\rlrrrrrP�s

?
rP�__main__)rQzidlelib.idle_test.test_squeezerrVF)�	verbosity�exit)r)r�tkinterr)rZidlelib.configrZidlelib.textviewrZidlelib.tooltiprZidlelibrrr*rrPrUrMZunittestrQrrrr�<module>s
8r


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists