ok

Mini Shell

Direktori : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/squeezer.cpython-36.opt-2.pyc

3

��2a�3�@s�ddlZddlZddlmZddljZddlm	Z	ddl
mZddlm
Z
ddlmZdd	d
�ZGdd�dej�ZGd
d�d�Zej�edkr�ddlmZedddd�dS)�N)�Font)�idleConf)�	view_text)�Hovertip)�macosx�P�c
Cs�d}d}d}x�tjd|�D]�}|j�|}||7}||7}||dkrT|d7}d}n$||||7}||krx|d7}|}|d7}|dkrt|d|�\}}	||7}|	d}qW|t|�|7}|dkr�||d|7}n|d8}|S)Nr�z[\t\n]�
)�re�finditer�start�divmod�len)
�s�	linewidth�tabwidth�posZ	linecountZcurrent_column�m�numchars�lines�column�r�-/opt/alt/python36/lib64/python3.6/squeezer.py�count_lines_with_wrappings0rc@sFeZdZdd�Zdd�Zddd�Zddd	�Zdd
d�ZdZdd�Z	dS)�ExpandingButtonc	s��|_||_||_||_|j|_}|j|_}|jj|_d|j}t	j
j|||ddd�d}t||dd�|j
d|j�tj�r�|j
d	|j�n|j
d
|j�|j�fdd��d|_|j|j�dS)
NzSqueezed text (%d lines).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>}sz*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#rZbutton_textZbutton_tooltip_textr)rrr)as(


zExpandingButton.__init__csLd|jj��|jdkpDt|j�dkpDt�fdd�tjd|j�D��|_dS)N�2i�iP�c3s |]}t|jd���kVqdS)rN)r�group)�.0Z
line_match)�dangerous_line_lenrr�	<genexpr>�sz3ExpandingButton.set_is_dangerous.<locals>.<genexpr>z[^\n]+)	r�winfo_widthr!rr�anyrrr,)r.r)r2rr-�s

z ExpandingButton.set_is_dangerousNcCs�|jdkr|j�|jrTtjddjddddg�|jt|j�ftj|j	d�}|sTdS|j
j|j	j|�|j|j
�|j
j|�|jjj|�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-�tkMessageBoxZaskokcancel�joinr!rrZCANCELrr&�insert�indexr �deleter"�expandingbuttons�remove)r.�eventZconfirmrrrr*�s$	

zExpandingButton.expandcCs|j�|j|j�dS)N)Zclipboard_clearZclipboard_appendr)r.rBrrr�copy�szExpandingButton.copycCst|jd|jddd�dS)NzSqueezed Output ViewerFZnone)Zmodal�wrap)rrr)r.rBrrr�view�szExpandingButton.viewrCrEcCsf|jjdd|j|jf�tj|jdd�}x&|jD]\}}|j|t||�d�q2W|j	|j
|j�dS)Nr=z@%d,%dr)Ztearoff)�labelZcommandr:)rZmark_set�x�yr'ZMenu�rmenu_specsZadd_command�getattrZtk_popupZx_rootZy_root)r.rBZrmenurFZmethod_namerrrr+�sz"ExpandingButton.context_menu_event)N)N)N�rCrC�rErE)rKrL)
�__name__�
__module__�__qualname__r)r-r*rCrErIr+rrrrrVs!



rc@s0eZdZedd��Zdd�Zdd�Zdd�Zd	S)
�SqueezercCstjdddddd�|_dS)N�main�PyShellzauto-squeeze-min-linesrr/)�typer8)rZ	GetOption�auto_squeeze_min_lines)�clsrrr�reload�szSqueezer.reloadcsX|�_|j�_�|jj�_g�_ddlm}t||�rTf|j	f��fdd�	}||_	dS)Nr)rRcs�|dkr|||�S�j|�}|�jkr0|||�St|||��}�jdtj��jd|ddd��jd��j��jdtj	��j
j|�dS)N�stdoutZiomark��)�window�padx�pady)�count_linesrTrZmark_gravityr'ZRIGHT�
window_createZsee�updateZLEFTr@�append)rr �writer!�expandingbutton)r.rrr�mywrite�s





z"Squeezer.__init__.<locals>.mywrite)
r#rr$r%r&r@Zidlelib.pyshellrR�
isinstancera)r.r#rRrcr)r.rrr)�s


zSqueezer.__init__csh�jj�}�jjj�}|dt�fdd�d	D��8}t�jj�jjjd�d�}||jd�}t|||�S)
N�csg|]}t�jjj|���qSr)rr#r�cget)r1�opt)r.rr�
<listcomp>sz(Squeezer.count_lines.<locals>.<listcomp>�borderr[�font)�name�0)rir[)	r#Zget_tk_tabwidthrr4�sumrrfZmeasurer)r.rrrrjr)r.rr]s
zSqueezer.count_linesc
Cs|jjtj�}x$d
D]}||krPqW|jj�dS|jj|tjd�\}}|jj||�}t|�dkr�|ddkr�|jjd|�}|dd�}|j	j
||�|j|�}t||||�}|jj
||d	d
d�t|j�}	x0|	dko�|jj|j|	dd|��r|	d8}	q�W|jj|	|�dS)NrW�stderrr:z+1crr	r
z%s-1crXrY)rZr[r\�>)rWrn���rp)r�	tag_namesr'ZINSERTZbellZ
tag_prevrange�getrr>r&r?r]rr^r@Zcomparer=)
r.rBrqZtag_namer
�endrr!rb�irrr�squeeze_current_text_event*s,	






z#Squeezer.squeeze_current_text_eventN)rMrNrO�classmethodrVr)r]rurrrrrP�s4rP�__main__)rQzidlelib.idle_test.test_squeezerreF)�	verbosity�exit)rr)rZtkinterr'Ztkinter.fontrZtkinter.messageboxZ
messageboxr;Zidlelib.configrZidlelib.textviewrZidlelib.tooltiprZidlelibrrr(rrPrVrMZunittestrQrrrr�<module>s

9s

Zerion Mini Shell 1.0