AlkantarClanX12

Your IP : 18.221.52.77


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/CodeContext.cpython-35.pyc



��Yf� �@s�dZddlZddlmZmZmZmZmZddlZddl	m
Zddlm
Z
dddd	d
ddd
dddhZdZdZejd�dd�ZGdd�d�ZdS)aICodeContext - Extension to display the block context above the edit window

Once code has scrolled off the top of a window, it can be difficult to
determine which block you are in.  This extension implements a pane at the top
of each IDLE edit window which provides block structure hints.  These hints are
the lines which contain the block opening keywords, e.g. 'if', for the
enclosing block.  The number of hint lines is determined by the numlines
variable in the CodeContext section of config-extensions.def. Lines which do
not open blocks are not shown in the context hints pane.

�N)�TOP�LEFT�X�W�SUNKEN)�maxsize)�idleConf�class�def�elif�else�except�finally�for�if�try�while�with�di�z^(\s*)(\w*)cCs|j|�j�S)N)�match�groups)�s�c�r�8/opt/alt/python35/lib64/python3.5/idlelib/CodeContext.py�<lambda>src@s�eZdZdd gfgZejddddddd	�Zejddd
dddd�Zejddd
dddd�Zdd�Z	ddd�Z
dd�Zdddd�Zdd�Z
dd�Zdd�ZdS)!�CodeContextZoptions�!Code Conte_xt�<<toggle-code-context>>�
extensionsZnumlines�type�int�default��bgcolor�strZ	LightGray�fgcolorZBlackcCs�||_|j|_|jd|_d|_dg|_d|_tjdddd	d
dd�}|r�|j�|jj	dd
�|jj
t|j�|jj
t
|j�dS)N�fontr��Frr�visibler �boolr"z<<toggle-code-context>>T���)rr,r)F)�editwin�text�textfont�label�info�
topvisibler�	GetOption�toggle_code_context_eventZsetvar�after�UPDATEINTERVAL�timer_event�FONTUPDATEINTERVAL�font_timer_event)�selfr-r*rrr�__init__"s			
zCodeContext.__init__NcCs�|jsC|jj|jjf}d}xM|D]E}||jj|j�d�7}||jj|jd��7}q.Wd}x-|D]%}||jj|jd��7}q�Wtj	|jj
dd|jddtdt
d	|jd
|jd|jddd|d|d
t�
|_|jjdtdtddd|jj�n|jj�d|_tjdddt|jdk	��tj�dS)Nr�padx�borderr.�
r(ZanchorZjustifyr'ZbgZfg�widthZreliefZsideZfill�expandFZbeforerrr*)r0r-r.Z
text_frameZtkZgetintZ	pack_infoZcget�tkinterZLabel�top�
context_depthrrr/r$r&rZpackrrZdestroyrZ	SetOptionr%ZSaveUserCfgFiles)r:ZeventZwidgetsr<Zwidgetr=rrrr47s0	
 #
#	
	z%CodeContext.toggle_code_context_eventcCs�|jjd|d|�}t|�\}}|tko>|}t|�t|�kso|t|�dkrxt}nt|�}|||fS)z�Get the line indent value, text, and any block start keyword

        If the line does not start a block, the keyword value is False.
        The indentation of empty lines (or comment lines) is INFINITY.

        z%d.0z%d.end�#)r.�get�getspacesfirstword�BLOCKOPENERS�len�INFINITY)r:�linenumr.ZspacesZ	firstword�opener�indentrrr�
get_line_info[s.	zCodeContext.get_line_infor(rc
Cs�|dkst�g}t}x�t||dd�D]�}|j|�\}}}	||kr5|}|	dkr{|d7}|	r�||kr�||kr�|j||||	f�||kr5Pq5W|j�||fS)z�Get context lines, starting at new_topvisible and working backwards.

        Stop when stopline or stopindent is reached. Return a tuple of context
        data and the indent level at the top of the region inspected.

        rr(rrr,)rr)�AssertionErrorrI�rangerM�append�reverse)
r:�new_topvisibleZstopline�
stopindent�lines�
lastindentrJrLr.rKrrr�get_contextks

zCodeContext.get_contextcCs�t|jjd�jd�d�}|j|kr8dS|j|kr�|j||j�\}}x�|jdd|kr�|jd=qeWn�|j|kr|jd
dd}x6|jdd|kr�|jdd}|jd=q�W|j||jddd|�\}}|jj|�||_dgtd|j	t
|j��}|dd�|j|j	d�D�7}d	j|�|jd
<dS)zKUpdate context information and lines visible in the context pane.

        z@0,0�.rNr(r)cSsg|]}|d�qS)�r)�.0�xrrr�
<listcomp>�s	z3CodeContext.update_code_context.<locals>.<listcomp>r>r.r,r,r,r,r,r,r,)
r!r.�index�splitr2rVr1�extend�maxrCrH�joinr0)r:rRrTrUrSZcontext_stringsrrr�update_code_context�s*%			&(zCodeContext.update_code_contextcCs-|jr|j�|jjt|j�dS)N)r0rar.r5r6r7)r:rrrr7�s	
zCodeContext.timer_eventcCsX|jd}|jr>||jkr>||_|j|jd<|jjt|j�dS)Nr')r.r0r/r5r8r9)r:Znewtextfontrrrr9�s

	zCodeContext.font_timer_event)rr)�__name__�
__module__�__qualname__Zmenudefsrr3rCr$r&r;r4rMrVrar7r9rrrrrs$ r)�__doc__rAZtkinter.constantsrrrrr�re�sysrrIZidlelib.configHandlerrrGr6r8�compilerFrrrrr�<module>s(