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__/colorizer.cpython-310.pyc
o

�i�9�@s�ddlZddlZddlZddlZddlmZddlmZdZdd�Z	dd�Z
e
�Ze�d	�Z
d
d
d
d
d�Zdd
�Zdd�ZGdd�de�Zdd�ZedkrfddlmZedddd�ddlmZee�dSdS)�N)�idleConf)�	DelegatorFcCsd|d�|�dS)z9Return a named group pattern matching list of alternates.z(?P<%s>�|�))�join)�nameZ
alternates�r�./usr/local/lib/python3.10/idlelib/colorizer.py�any�r
cCsdtdtj�d}dd�ddd�tj�dg�d}d	}d
d�dddd�tj�dg�d}dd
�tt�D�}dtd|�d}tddg�}d}|d}|d}	|d}
|d}td|
|||	g�}t�d�|||||||tddg�g�tjtj	B�}
|
S)Nz\b�KEYWORDz,^[ \t]*(?P<MATCH_SOFTKW>match)\b(?![ \t]*(?:rz[:,;=^&|@~)\]}]z\b(?:z)\bz))zB^[ \t]*(?P<CASE_SOFTKW>case)[ \t]+(?P<CASE_DEFAULT_UNDERSCORE>_\b)z+^[ \t]*(?P<CASE_SOFTKW2>case)\b(?![ \t]*(?:z_\bcSs(g|]}|�d�s|tjvrt|��qS)�_)�
startswith�keyword�kwlist�str)�.0rrrr	�
<listcomp>-s�
�zmake_pat.<locals>.<listcomp>z([^.'\"\\#]\b|^)�BUILTIN�COMMENTz#[^\n]*z(?i:r|u|f|fr|rf|b|br|rb)?z'[^'\\\n]*(\\.[^'\\\n]*)*'?z"[^"\\\n]*(\\.[^"\\\n]*)*"?z''''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?z'"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?�STRING�SYNCz\n)
r
rrr�dir�builtins�re�compile�DOTALL�	MULTILINE)�kwZmatch_softkwZcase_defaultZcase_softkw_and_patternZbuiltinlist�builtin�commentZstringprefixZsqstringZdqstringZ	sq3stringZ	dq3string�string�progrrr	�make_patsP���������
�
�r#z\s+(\w+)r)ZMATCH_SOFTKWZCASE_SOFTKWZCASE_DEFAULT_UNDERSCOREZCASE_SOFTKW2cCsdd�|����D�S)z<Get only the non-empty named groups from an re.Match object.css �|]\}}|r||fVqdS�Nr)r�k�vrrr	�	<genexpr>Ns�z'matched_named_groups.<locals>.<genexpr>)�	groupdict�items)Zre_matchrrr	�matched_named_groupsLrr*cCs^t��}t�|d�}t�|d�d}t�|d�}|j|d|d||d|d|dd�dS)zcSet color options of Text widget.

    If ColorDelegator is used, this should be called first.
    ZnormalZcursor�
foregroundZhilite�
background)r+r,ZinsertbackgroundZselectforegroundZselectbackgroundZinactiveselectbackgroundN)r�CurrentTheme�GetHighlightZconfig)�text�themeZ
normal_colorsZcursor_colorZ
select_colorsrrr	�color_configQs
�r1c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zd!d
d�Z	d!dd�Z
d!dd�Zdd�Zd!dd�Z
dd�Zdd�Zdd�Zdd�Zdd �ZdS)"�ColorDelegatora-Delegator for syntax highlighting (text coloring).

    Instance variables:
        delegate: Delegator below this one in the stack, meaning the
                one this one delegates to.

        Used to track state:
        after_id: Identifier for scheduled after event, which is a
                timer for colorizing the text.
        allow_colorizing: Boolean toggle for applying colorizing.
        colorizing: Boolean flag when colorizing is in process.
        stop_colorizing: Boolean flag to end an active colorizing
                process.
    cCs*t�|�|��t|_t|_|��dSr$)r�__init__�
init_stater"�idprog�LoadTagDefs��selfrrr	r3vs

zColorDelegator.__init__cCsd|_d|_d|_d|_dS)z1Initialize variables that track colorizing state.NTF)�after_id�allow_colorizing�stop_colorizing�
colorizingr7rrr	r4}s
zColorDelegator.init_statecCs^|jdur
|�d�t�||�|dur'|��|�d|j�|�dd�dSd|_d|_	dS)a�Set the delegate for this instance.

        A delegate is an instance of a Delegator class and each
        delegate points to the next delegator in the stack.  This
        allows multiple delegators to be chained together for a
        widget.  The bottom delegate for a colorizer is a Text
        widget.

        If there is a delegate, also start the colorizing process.
        Nz<<toggle-auto-coloring>>�1.0�endTF)
�delegateZunbindr�setdelegate�
config_colors�bind�toggle_colorize_event�notify_ranger;r:)r8r?rrr	r@�s


zColorDelegator.setdelegatecCs4|j��D]
\}}|j|fi|��q|�d�dS)z4Configure text widget tags with colors from tagdefs.ZselN)�tagdefsr)Z
tag_configureZ	tag_raise)r8�tagZcnfrrr	rA�szColorDelegator.config_colorscCs~t��}t�|d�t�|d�t�|d�t�|d�t�|d�ddd�ddd�t�|d�t�|d	�d
�	|_tr=td|j�dSdS)z.Create dictionary of tag names to text colors.r rrr!Z
definitionN)r,r+�error�hit)	rrrr�
DEFINITIONr�TODO�ERRORrHrE)rr-r.rE�DEBUG�print)r8r0rrr	r6�s






�zColorDelegator.LoadTagDefsNcCs6|�|�}|j�|||�|�||dt|��dS)z:Insert chars into widget at index and mark for colorizing.z+%dcN)�indexr?�insertrD�len)r8rN�chars�tagsrrr	rO�s
zColorDelegator.insertcCs&|�|�}|j�||�|�|�dS)z5Delete chars between indexes and mark for colorizing.N)rNr?�deleterD�r8Zindex1�index2rrr	rS�s
zColorDelegator.deletecCsb|�d||�|jrtrtd�dS|jrd|_trtd�|jr/tr'td�|�d|j�|_dS)zCMark text changes for processing and restart colorizing, if active.rJzcolorizing already scheduledNT�stop colorizingzschedule colorizing�)	�tag_addr9rLrMr<r;r:�after�
recolorizerTrrr	rD�szColorDelegator.notify_rangecCs8|jr|j}d|_trtd�|�|�d|_d|_dS)N�cancel scheduled recolorizerFT)r9rLrM�after_cancelr:r;)r8r9rrr	�close�s

zColorDelegator.closecCs�|jr|j}d|_trtd�|�|�|jr#|jr#tr td�d|_|j|_|jr6|js6|�d|j�|_trBtd|jr?dnd�d	S)
z�Toggle colorizing on and off.

        When toggling off, if colorizing is scheduled or is in
        process, it will be cancelled and/or stopped.

        When toggling on, colorizing will be scheduled.
        Nr[rVTrWzauto colorizing turnedZonZoff�break)	r9rLrMr\r:r<r;rYrZ)r8�eventr9rrr	rC�s 

�z$ColorDelegator.toggle_colorize_eventcCs�d|_|jstrtd�dS|jstrtd�dS|jr$tr"td�dSz'd|_d|_tr1td�t��}|�	�t��}trGtd||�Wd|_nd|_w|jri|�
d	d
�rktr_td�|�d|j�|_dSdSdS)
aSTimer event (every 1ms) to colorize text.

        Colorizing is only attempted when the text widget exists,
        when colorizing is toggled on, and when the colorizing
        process is not already running.

        After colorizing is complete, some cleanup is done to
        make sure that all the text has been colorized.
        Nzno delegatezauto colorizing is offzalready colorizingFTz
colorizing...z%.3f secondsrJr=zreschedule colorizingrW)
r9r?rLrMr:r<r;�time�perf_counter�recolorize_main�
tag_nextrangerYrZ)r8�t0�t1rrr	rZ�s0
��zColorDelegator.recolorizecCs@d}|�d|�}r�|�d|d|d�|�d|d�}|r#|dnd}d}|}d}d}|s�|}|�|d|�}t|d	d
�}d|�|d�v}|�||�}	|	sTdS|jD]	}
|�|
||�qW||	7}|�||�d|�|d�vry|}d}nd}|s�|�	d|�|�
�|jr�tr�t
d
�dS|r/|�d|�}s
dSdS)z(Evaluate text and apply colorizing tags.r=rJrrrW�Fz+%d lines linestart��dz-1cNzcolorizing stopped)rc�
tag_removeZ
tag_prevrangerN�minZ	tag_names�getrE�_add_tags_in_sectionrX�updater;rLrM)r8�nextZtodo_tag_rangeZsync_tag_range�headrQZlines_to_get�okZmark�linerFrrr	rbsF�
��zColorDelegator.recolorize_maincCs:t�||�}|�||�d|d�d�|�d|d�d��dS)a�Add a tag to a given range in the text widget.

        This is a utility function, receiving the range as `start` and
        `end` positions, each of which is a number of characters
        relative to the given `head` index in the text widget.

        The tag to add is determined by `matched_group_name`, which is
        the name of a regular expression "named group" as matched by
        by the relevant highlighting regexps.
        �+�d�cN)�prog_group_name_to_tagrkrX)r8�startr>roZmatched_group_namerFrrr	�_add_tag>s��zColorDelegator._add_tagc	Cs~|j�|�D]6}t|�D]/\}}|�|�\}}|�||||�|dvr;|j�||�}r;|�d�\}}|�|||d�qqdS)z�Parse and add highlighting tags to a given part of the text.

        `chars` is a string with the text to parse and to which
        highlighting is to be applied.

            `head` is the index in the text widget where the text is found.
        )�def�classrWrIN)r"�finditerr*�spanrwr5�match)	r8rQro�mrZmatched_text�a�bZm1rrr	rlOs���z#ColorDelegator._add_tags_in_sectioncCs|jD]	}|�|dd�qdS)zRemove all colorizing tags.r=r>N)rEri)r8rFrrr	�removecolors`s
�zColorDelegator.removecolorsr$)�__name__�
__module__�__qualname__�__doc__r3r4r@rAr6rOrSrDr]rCrZrbrwrlr�rrrr	r2fs"



	",r2cCs�ddlm}m}ddlm}ddlm}||�}|�d�tt	|�
��d�dd��\}}|�
d|d	|d
f�||dd�}|jdd
d�|�
d|�|��t|�||�}	t�}
|	�|
�dS)Nr)�Toplevel�Text)�source)�
PercolatorzTest ColorDelegatorrrrWz
700x550+%d+%d��Zwhite)r,Zboth)�expand�fillrO)�tkinterr�r�Z idlelib.idle_test.test_colorizerr�Zidlelib.percolatorr��title�map�intZgeometry�split�packrOZ	focus_setr1r2Zinsertfilter)�parentr�r�r�r��top�x�yr/�prsrrr	�_color_delegatorfs
 r��__main__)�mainz idlelib.idle_test.test_colorizerrg)�	verbosity�exit)�run)rrrr`Zidlelib.configrZidlelib.delegatorrrLr
r#r"rr5rur*r1r2r�r�Zunittestr�Zidlelib.idle_test.htestr�rrrr	�<module>s81
��