<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
B
    YI~d(2                 @   s   d dl Z d dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ dddZG d	d
 d
ejZG dd dZe  edkrd dlmZ edddd dS )    N)idleConf)	view_text)Hovertip)macosxP   c             C   s   d}d}d}d}xt d| D ]~}| | }||7 }||7 }| | dkrp||krb||d | 7 }|d7 }d}n$||||  7 }||kr|d7 }|}|d7 }qW |t| | 7 }|dkr||d | 7 }n|d8 }|S )N   r      z[\t\n]
)refinditerstartlen)sZ	linewidthZtabwidthposZ	linecountZcurrent_columnmnumchars r   5/opt/alt/python37/lib64/python3.7/idlelib/squeezer.pycount_lines_with_wrapping   s.    r   c               @   sF   e Zd Zdd Zdd ZdddZddd	Zdd
dZdZdd Z	dS )ExpandingButtonc       
         s    | _ || _|| _|| _|j | _}|j | _}|jj| _|dkrFdnd}d| d| d}t	j
j| ||ddd	 d
}	t| |	dd | d| j t r| d| j n| d| j |  fdd d | _| | j d S )Nr   lineslinezSqueezed text ( z).z#FFFFC0z#FFFFE0)textZ
backgroundZactivebackgroundz5Double-click to expand, right-click for more options.r   )Zhover_delayz<Double-Button-1>z
<Button-2>z
<Button-3>c                s    t | t | t |  S )N)int)offsetlength)r   r   r   <lambda>z       z*ExpandingButton.__init__.<locals>.<lambda>)r   tags
numoflinessqueezereditwinr   perbottom	base_texttkButton__init__r   Zbindexpandr   ZisAquaTkcontext_menu_eventZselection_handleis_dangerousZ
after_idleset_is_dangerous)
selfr   r   r    r!   r"   r   Zline_pluralityZbutton_textZbutton_tooltip_textr   )r   r   r(   _   s*    

zExpandingButton.__init__c                sL   d| j    | jdkpDt| jdkpDt fddtd| jD | _d S )N2   i  iP  c             3   s    | ]}t |d  kV  qdS )r   N)r   group).0Z
line_match)dangerous_line_lenr   r   	<genexpr>   s   z3ExpandingButton.set_is_dangerous.<locals>.<genexpr>z[^\n]+)	r   Zwinfo_widthr    r   r   anyr
   r   r+   )r-   r   )r1   r   r,      s    

z ExpandingButton.set_is_dangerousNc             C   s   | j d kr|   | j rTtjddddddg| jt| jf tj| j	d}|sTdS | j
| j	| | j| j | j
|  | jj|  d S )	NzExpand 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.zReally expand?)titlemessagedefaultparentbreak)r+   r,   tkMessageBoxZaskokcanceljoinr    r   r   ZCANCELr   r%   insertindexr   deleter!   expandingbuttonsremove)r-   eventZconfirmr   r   r   r)      s$    	

zExpandingButton.expandc             C   s   |    | | j d S )N)Zclipboard_clearZclipboard_appendr   )r-   r@   r   r   r   copy   s    zExpandingButton.copyc             C   s   t | jd| jddd d S )NzSqueezed Output ViewerFZnone)Zmodalwrap)r   r   r   )r-   r@   r   r   r   view   s    zExpandingButton.view))rA   rA   )rC   rC   c             C   sf   | j dd|j|jf  tj| j dd}x&| jD ]\}}|j|t| |d q2W |	|j
|j dS )Nr;   z@%d,%dr   )Ztearoff)labelZcommandr8   )r   Zmark_setxyr&   ZMenurmenu_specsZadd_commandgetattrZtk_popupZx_rootZy_root)r-   r@   ZrmenurD   Zmethod_namer   r   r   r*      s    z"ExpandingButton.context_menu_event)N)N)N)
__name__
__module____qualname__r(   r,   r)   rA   rC   rG   r*   r   r   r   r   r   T   s    



r   c               @   s0   e Zd Zedd Zdd Zdd Zdd Zd	S )
Squeezerc             C   s   t jdddddd| _d S )NmainZPyShellzauto-squeeze-min-linesr   r.   )typer6   )r   Z	GetOptionauto_squeeze_min_lines)clsr   r   r   reload   s    zSqueezer.reloadc                sd   | _ |j  _|jj _dtdtd   _g  _d|j	f fdd	}||_	d S )N   Zborderpadxr   c                s   |dkr|| |S  j }t| |k r.|| |S  | }||k rJ|| |S t| || }dtj jd|ddd d 	  dtj
  j| d S )NstdoutZiomark      )windowrS   pady)rO   r   count_linesr   Zmark_gravityr&   ZRIGHTwindow_createZseeupdateZLEFTr>   append)r   r   writerO   r    expandingbutton)r-   r   r   r   mywrite   s     





z"Squeezer.__init__.<locals>.mywrite)
r"   r   r#   r$   r%   r   ZcgetZwindow_width_deltar>   r]   )r-   r"   r_   r   )r-   r   r   r(      s    

zSqueezer.__init__c             C   s   t || jjS )N)r   r"   width)r-   r   r   r   r   rY     s    zSqueezer.count_linesc       
      C   s  | j tj}x$dD ]}||krP qW | j   dS | j |tjd \}}| j ||}t|dkr|d dkr| j d| }|d d }| j	
|| | |}t|||| }| j j||dd	d
 t| j}	x2|	dkr| j | j|	d  d|r|	d8 }	qW | j|	| dS )N)rT   stderrr8   z+1cr   r	   z%s-1crU   rV   )rW   rS   rX   r   >)r   	tag_namesr&   ZINSERTZbellZtag_prevrangegetr   r<   r%   r=   rY   r   rZ   r>   Zcomparer;   )
r-   r@   rd   Ztag_namer   endr   r    r^   ir   r   r   squeeze_current_text_event   s,    	






z#Squeezer.squeeze_current_text_eventN)rI   rJ   rK   classmethodrQ   r(   rY   rh   r   r   r   r   rL      s   ?rL   __main__)rM   zidlelib.idle_test.test_squeezerrR   F)	verbosityexit)r   )r
   Ztkinterr&   Ztkinter.messageboxZ
messageboxr9   Zidlelib.configr   Zidlelib.textviewr   Zidlelib.tooltipr   Zidlelibr   r   r'   r   rL   rQ   rI   ZunittestrM   r   r   r   r   <module>   s   
8r 