%PDF- %PDF-
Direktori : /usr/local/lib/python3.8/idlelib/__pycache__/ |
Current File : //usr/local/lib/python3.8/idlelib/__pycache__/squeezer.cpython-38.pyc |
U qa2 @ s d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m Z ddlmZ dd d Z G dd dejZG d d dZe edkrddlmZ 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) messagebox)idleConf) view_text)Hovertip)macosxP c C s d}d}d}d}t d| D ]}| | }||7 }||7 }| | dkrn||kr`||d | 7 }|d7 }d}n4| | dks~t|||| 7 }||kr|d7 }|}|d7 }q|t| | 7 }|dkr||d | 7 }n|d8 }|S )zCount 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] )refinditerstartAssertionErrorlen)sZ linewidthZtabwidthposZ linecountZcurrent_columnmnumchars r ,/usr/local/lib/python3.8/idlelib/squeezer.pycount_lines_with_wrapping s0 r c @ sJ e Zd ZdZdd Zdd ZdddZdd d ZdddZd 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 lineslinezSqueezed 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)offsetlengthr r r <lambda>z z*ExpandingButton.__init__.<locals>.<lambda>)r tags numoflinessqueezereditwinr perbottom base_texttkButton__init__r bindexpandr ZisAquaTkcontext_menu_eventZselection_handleis_dangerousZ after_idleset_is_dangerous) selfr r# r$ r% r&