Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/idlelib/__pycache__/codecontext.cpython-310.opt-2.pyc

o

0�i�,�@s�	ddlZddlmZddlmZmZmZddlm	Z	m
Z
ddlmZhd�Z
e�d�fdd	�Zd
d�ZGdd
�d
�Ze��edkrRddlmZedddd�dSdS)�N)�maxsize)�Frame�Text�TclError)�NSEW�SUNKEN)�idleConf>�async�class�def�with�while�for�if�finally�else�except�elif�tryz^(\s*)(\w*)cCs	|�|���S�N)�match�groups)�codeline�c�r�:/opt/alt/python310/lib64/python3.10/idlelib/codecontext.py�get_spaces_firstwordsrcCsH	t|�\}}t|�}t|�|ks||dkrt}|tvo|}|||fS)N�#)r�len�INFINITY�BLOCKOPENERS)r�spacesZ	firstword�indent�openerrrr�
get_line_infos
r$c@steZdZ	dZdd�Zdd�Zedd��Zdd	�Zddd�Z	ddd�Z
dd�Zddd�Zdd�Z
dd�Zdd�Zd
S)�CodeContext�dcCs	||_|j|_|��dSr)�editwin�text�_reset)�selfr'rrr�__init__1szCodeContext.__init__cCs$d|_d|_d|_d|_dg|_dS)N�)r����F)�context�cell00�t1�
topvisible�info�r*rrrr)Fs
zCodeContext._resetcCs	tjdddddd�|_dS)N�
extensionsr%Zmaxlines�int�)�type�default)rZ	GetOption�
context_depth)�clsrrr�reloadMs
�zCodeContext.reloadcCs@	|jdurz	|j�|j�Wn	tyYnwd|_dSdSr)r1r(�after_cancelrr4rrr�__del__Ts
�
�zCodeContext.__del__Nc

Csv	|jdur�|jj|jjf}d}d}|D]0}||jjur |��n|��}||j�|d�7}||j�|�d��7}||j�|�d��7}qt	|jjddd||t
dd�}|_|��|��|�
d|j�|��|jddtd�t�t��d	�}t|jj|d
d�|_|jjddtd�d}	n|j��d|_|j��d|_|j�|j�|��d
}	|jjdd|	�d�d�dS)Nr�padx�borderr,�disabled)�height�widthZhighlightthicknessr?r@Zrelief�statez<ButtonRelease-1>)�row�columnZsticky�
linenumber�
background�ZbgZHideZShowZoptionsz*ode*ontextz
 Code Context)Zmenu�indexZlabel�break)r/r'r(Z
text_frameZ	grid_infoZ	pack_infoZtkZgetintZcgetrr�update_font�update_highlight_colorsZbind�
jumptoline�timer_eventZgridrr�GetHighlight�CurrentThemerr0Zdestroyr=r1r)Zupdate_menu_label)
r*�eventZwidgetsr?r@Zwidgetr3r/�line_number_colorsZmenu_statusrrr�toggle_code_context_event]sX
���
��


�z%CodeContext.toggle_code_context_eventr,rcCs�	g}t}t||dd�D]=}|j�|�d�|�d��}t|�\}}	}
||krJ|}|
dvr1|d7}|
rD||krD||krD|�|||	|
f�||krJnq
|��||fS)Nr,r-�.0z.end)rr)r�ranger(�getr$�append�reverse)r*�new_topvisibleZstopline�
stopindent�lines�
lastindentZlinenumrr"r(r#rrr�get_context�s"	�zCodeContext.get_contextcCsd	|j�d�}|j|krdS|j|kr3|�||j�\}}|jdd|kr2|jd=|jdd|ks%n6|jddd}|jdd|krY|jdd}|jd=|jdd|ksE|�||jddd|�\}}|j�|�||_dd�|j|jd�D�}|dr�dnd}t|�||jd<d|jd	<|j�	d
d�|j�
dd�||d���d
|jd	<dS)Nz@0,0r-r,rcSsg|]}|d�qS)�r)�.0�xrrr�
<listcomp>�sz3CodeContext.update_code_context.<locals>.<listcomp>rBZnormalrDz1.0�end�
rA)r'Z	getlinenor2r^r3�extendr:rr/�delete�insert�join)r*rZr\r]r[Zcontext_stringsZ	showfirstrrr�update_code_context�s<

�����
zCodeContext.update_code_contextcCs�	z	|j�d�WdStyJt|j�}|dkrd}ntt|j�d���}td||j�d}|j||d}|j	�
|�d��|��YdSw)Nz	sel.firstr,rgrrU)r/rJrrr3r6�float�maxr:r(Zyviewri)r*rRr\ZnewtopZcontextline�offsetrrrrN�s
�zCodeContext.jumptolinecCs0	|jdur|��|j�|j|j�|_dSdSr)r/rir(Zafter�UPDATEINTERVALrOr1r4rrrrO�s

�zCodeContext.timer_eventcCs,|jdurt�|jdd�}||jd<dSdS)N�mainZEditorWindow�font)r/rZGetFontr()r*rorrrrL�s
�zCodeContext.update_fontcCsj|jdurt�t��d�}|d|jd<|d|jd<|jdur3t�t��d�}|jj|dd�dSdS)Nr/rHZ
foregroundrGrI)r/rrPrQr0Zconfig)r*ZcolorsrSrrrrM�s


��z#CodeContext.update_highlight_colorsr)r,r)�__name__�
__module__�__qualname__rmr+r)�classmethodr<r>rTr^rirNrOrLrMrrrrr%-s

	
8
(r%�__main__)rnz"idlelib.idle_test.test_codecontextr_F)�	verbosity�exit)�re�sysrrZtkinterrrrZtkinter.constantsrrZidlelib.configrr �compilerr$r%r<rpZunittestrnrrrr�<module>s 
[�