관리-도구
편집 파일: squeezer.cpython-37.pyc
B � f(2 � @ s� d Z ddlZddlZddlmZ ddlmZ ddl m Z ddlmZ ddl mZ ddd �ZG d d� dej�ZG dd � d �Ze�� 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-clicking 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)�idleConf)� view_text)�Hovertip)�macosx�P c C s� d}d}d}d}x�t �d| �D ]�}|�� | }||7 }||7 }| | dkrp||krb||d | 7 }|d7 }d}n4| | dks�t�|||| 7 }||kr�|d7 }|}|d7 }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�len)�sZ linewidthZtabwidth�posZ linecountZcurrent_column�m�numchars� r �5/opt/alt/python37/lib64/python3.7/idlelib/squeezer.py�count_lines_with_wrapping s0 r c @ sJ e Zd ZdZdd� Zdd� Zddd�Zdd d �Zddd�Zd Z 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| _|dkrFdnd}d|� d|� d�}t j j| ||ddd � d } t| | dd� | � d | j� t�� r�| � d| j� n| � d| j� | �� fdd�� d | _| �| j� d S )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>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 Zbind�expandr ZisAquaTk�context_menu_eventZselection_handle�is_dangerousZ after_idle�set_is_dangerous) �selfr r! r"