HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/idlelib/__pycache__/squeezer.cpython-310.opt-2.pyc
o

�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�-/usr/local/lib/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)�offset�length�rrr�<lambda>zsz*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���|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.)r0rr4rr/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)r0�eventZconfirmr=rrrr,�s&
��
zExpandingButton.expandcCs	|��|�|j�dSr)Zclipboard_clearZclipboard_appendr�r0rBrrr�copy�szExpandingButton.copycCs	t|jd|jddd�dS)NzSqueezed Output ViewerFZnone)Zmodal�wrap)rrrrCrrr�view�s
�zExpandingButton.view))rDrD)rFrFcCsb|j�dd|j|jf�tj|jdd�}|jD]\}}|j|t||�d�q|�	|j
|j�dS)Nr>z@%d,%dr)Ztearoff)�labelZcommandr;)rZmark_set�x�yr(ZMenu�rmenu_specsZadd_command�getattrZtk_popupZx_rootZy_root)r0rBZrmenurGZmethod_namerrrr-�sz"ExpandingButton.context_menu_eventr)
�__name__�
__module__�__qualname__r*r/r,rDrFrJr-rrrrrTs
 


rc@s2eZdZ	edd��Zdd�Zdd�Zdd�Zd	S)
�SqueezercCs	tjdddddd�|_dS)N�mainZPyShellzauto-squeeze-min-linesrr1)�typer9)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���ZwindowrVZpady)
rRr�count_linesrZmark_gravityr(ZRIGHT�
window_createZsee�updateZLEFTr@�append)rr!�writerRr"�expandingbutton�r0rrr�mywrite�s"



�
z"Squeezer.__init__.<locals>.mywrite)
r$rr%r&r'rZcgetZwindow_width_deltar@r_)r0r$rbrrarr*�s	
��
zSqueezer.__init__cCs	t||jj�Sr)rr$�width)r0rrrrr[s
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)rW�stderrr;z+1cr���r
z%s-1crXrYrZr	�>)r�	tag_namesr(ZINSERTZbellZ
tag_prevrange�getrr=r'r?r[rr\r@Zcomparer>)	r0rgZtag_namer
�endrr"r`�irrr�squeeze_current_text"s:�


�
���zSqueezer.squeeze_current_textN)rLrMrN�classmethodrTr*r[rkrrrrrO�s
?
rO�__main__)rPzidlelib.idle_test.test_squeezerrUF)�	verbosity�exit)r)r�tkinterr(rZidlelib.configrZidlelib.textviewrZidlelib.tooltiprZidlelibrrr)rrOrTrLZunittestrPrrrr�<module>s"
8t�