Hacked By AnonymousFox
3
� f�3 � @ s� d Z ddlZddlZddlmZ ddljZddl m
Z
ddlmZ ddl
mZ ddlmZ dd
d�ZG dd
� d
ej�ZG dd� d�Zej� edkr�ddlmZ edddd� dS )a
An IDLE extension to avoid having very long texts printed in the shell.
A common problem in IDLE's interactive shell is printing of large amounts of
text into the shell. This makes looking at the previous history difficult.
Worse, this can cause IDLE to become very slow, even to the point of being
completely unusable.
This extension will automatically replace long texts with a small button.
Double-cliking this button will remove it and insert the original text instead.
Middle-clicking will copy the text to the clipboard. Right-clicking will open
the text in a separate viewing window.
Additionally, any output can be manually "squeezed" by the user. This includes
output written to the standard error stream ("stderr"), such as exception
messages and their tracebacks.
� N)�Font)�idleConf)� view_text)�Hovertip)�macosx�P � c
C s� d}d}d}x�t jd| �D ]�}|j� | }||7 }||7 }| | dkrT|d7 }d}n4| | dksdt�|||| 7 }||kr�|d7 }|}|d7 }|dkrt|d |�\}} ||7 }| d }qW |t| �| 7 }|dkr�||d | 7 }n|d8 }|S )z�Count the number of lines in a given string.
Lines are counted as if the string was wrapped so that lines are never over
linewidth characters long.
Tabs are considered tabwidth characters long.
r � z[\t\n]�
� )�re�finditer�start�AssertionError�divmod�len)
�s� linewidth�tabwidth�posZ linecountZcurrent_column�m�numchars�lines�column� r �5/opt/alt/python36/lib64/python3.6/idlelib/squeezer.py�count_lines_with_wrapping s2 r c @ sJ e Zd ZdZdd� Zdd� Zddd�Zdd d
�Zddd�ZdZ dd� Z
dS )�ExpandingButtona� Class for the "squeezed" text buttons used by Squeezer
These buttons are displayed inside a Tk Text widget in place of text. A
user can then use the button to replace it with the original text, copy
the original text to the clipboard or view the original text in a separate
window.
Each button is tied to a Squeezer instance, and it knows to update the
Squeezer instance when it is expanded (and therefore removed).
c 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� d S )
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>c s � t | �t | �t |� � S )N)�int)�offsetZlength)r r r �<lambda>} s z*ExpandingButton.__init__.<locals>.<lambda>)r �tags�
numoflines�squeezer�editwinr �per�bottom� base_text�tk�Button�__init__r Zbind�expandr ZisAquaTk�context_menu_eventZselection_handle�is_dangerousZ
after_idle�set_is_dangerous) �selfr r"