HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/idlelib/__pycache__/codecontext.cpython-310.opt-2.pyc
o

�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>�while�elif�class�for�try�finally�async�except�if�with�else�defz^(\s*)(\w*)cCs	|�|���S�N)�match�groups)�codeline�c�r�0/usr/local/lib/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��bgZHideZShow�optionsz*ode*ontextz
 Code Context)Zmenu�indexZlabel�break)r/r'r(Z
text_frameZ	grid_infoZ	pack_infoZtkZgetintZcgetrr�update_font�update_highlight_colors�bind�
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	getlinenor2rar3�extendr:rr/�delete�insert�join)r*r]r_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,rjrrX)r/rLrrr3r6�float�maxr:r(Zyviewrl)r*rUr_ZnewtopZcontextline�offsetrrrrQ�s
�zCodeContext.jumptolinecCs0	|jdur|��|j�|j|j�|_dSdSr)r/rlr(Zafter�UPDATEINTERVALrRr1r4rrrrR�s

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


��z#CodeContext.update_highlight_colorsr)r,r)�__name__�
__module__�__qualname__rpr+r)�classmethodr<r>rWrarlrQrRrNrOrrrrr%-s

	
8
(r%�__main__)rqz"idlelib.idle_test.test_codecontextrbF)�	verbosity�exit)�re�sysrr�tkinterrrrZtkinter.constantsrrZidlelib.configrr �compilerr$r%r<rsZunittestrqrrrr�<module>s 
[�