<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
 f,                 @   s   d dl Z d dlZd dlZd dlZd dlmZ d dlmZ dZdd Z	dd Z
eje
 ejZejd	ejZd
d ZG dd deZdd Zedkrd dlmZ edddd d dlmZ ee dS )    N)idleConf)	DelegatorFc             C   s   d|  dj | d S )z9Return a named group pattern matching list of alternates.z(?P<%s>|))join)nameZ
alternates r   6/opt/alt/python36/lib64/python3.6/idlelib/colorizer.pyany   s    r
   c        
      C   s   dt dtjddg  d } dd ttD }dt d| d }t d	d
g}d}|d }|d }|d }|d }t d||||g}	| d | d | d |	 d t ddg S )Nz\bKEYWORDasyncawaitc             S   s*   g | ]"}|j d  r|tjkrt|qS )_)
startswithkeywordkwliststr).0r   r   r   r	   
<listcomp>   s    zmake_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'"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?STRINGr   SYNCz\n)r
   r   r   dirbuiltins)
kwZbuiltinlistbuiltincommentZstringprefixZsqstringZdqstringZ	sq3stringZ	dq3stringstringr   r   r	   make_pat   s    r   z\s+(\w+)c             C   s^   t j }t j|d}t j|ddd}t j|d}| j|d |d ||d |d |d d d	S )
zcSet color options of Text widget.

    If ColorDelegator is used, this should be called first.
    ZnormalZcursorZfg)ZfgBgZhilite
foreground
background)r    r!   ZinsertbackgroundZselectforegroundZselectbackgroundZinactiveselectbackgroundN)r   CurrentThemeGetHighlightconfig)textthemeZnormal_colorsZcursor_colorZselect_colorsr   r   r	   color_config"   s    r'   c               @   s   e Zd Zdd Zdd Zdd Zdd Zdd
dZdddZd	Z	dZ
dZdddZd	ZdddZdd Zdd Zdd Zdd Zd	S ) ColorDelegatorc             C   s"   t j|  t| _t| _| j  d S )N)r   __init__progidprogLoadTagDefs)selfr   r   r	   r)   9   s    
zColorDelegator.__init__c             C   s\   | j d k	r| jd tj| | |d k	rL| j  | jd| j | jdd nd| _d| _	d S )Nz<<toggle-auto-coloring>>z1.0endTF)
delegateZunbindr   setdelegateconfig_colorsZbindtoggle_colorize_eventnotify_rangestop_colorizingallow_colorizing)r-   r/   r   r   r	   r0   ?   s    

zColorDelegator.setdelegatec             C   s8   x(| j j D ]\}}|r| j|f| qW | jd d S )NZsel)tagdefsitemsZtag_configureZ	tag_raise)r-   tagZcnfr   r   r	   r1   L   s    zColorDelegator.config_colorsc             C   sz   t j }t j|dt j|dt j|dt j|dt j|dd d dd d dt j|dt j|dd		| _trvtd
| j d S )Nr   r   r   r   Z
definition)r!   r    errorhit)	r   r   r   r   
DEFINITIONr   TODOZERRORr:   r6   )r   r"   r#   r6   DEBUGprint)r-   r&   r   r   r	   r,   R   s    





 zColorDelegator.LoadTagDefsNc             C   s6   | j |}| jj||| | j||dt|   d S )Nz+%dc)indexr/   insertr3   len)r-   r?   charsZtagsr   r   r	   r@   c   s    
zColorDelegator.insertc             C   s&   | j |}| jj|| | j| d S )N)r?   r/   deleter3   )r-   index1index2r   r   r	   rC   h   s    
zColorDelegator.deleteTFc             C   sb   | j d|| | jr$tr td d S | jr<d| _tr<td | jr^trNtd | jd| j| _d S )Nr<   zcolorizing already scheduledTzstop colorizingzschedule colorizing   )	tag_addafter_idr=   r>   
colorizingr4   r5   after
recolorize)r-   rD   rE   r   r   r	   r3   q   s       zColorDelegator.notify_rangec             C   sR   | j r(| j }d | _ trtd | j| d| _d| _|rN| jsH|j  n|| _d S )Nzcancel scheduled recolorizerFT)	rH   r=   r>   after_cancelr5   r4   rI   destroyclose_when_done)r-   rN   rH   r   r   r	   close   s     

zColorDelegator.closec             C   s   | j r(| j }d | _ trtd | j| | jrF| jrFtr@td d| _| j | _| jrn| j rn| jd| j| _ trtd| jrdpd dS )	Nzcancel scheduled recolorizerzstop colorizingTrF   zauto colorizing turnedZonZoffbreak)	rH   r=   r>   rL   r5   rI   r4   rJ   rK   )r-   ZeventrH   r   r   r	   r2      s"     
 
z$ColorDelegator.toggle_colorize_eventc             C   s   d | _ | jstrtd d S | js2tr.td d S | jrHtrDtd d S zHd| _d| _trbtd tj }| j	  tj }trtd||   W d d| _X | jr| j
dd	rtrtd
 | jd| j| _ | jr| j}d | _|j  d S )Nzno delegatezauto colorizing is offzalready colorizingFTzcolorizing...z%.3f secondsr<   z1.0zreschedule colorizingrF   )rH   r/   r=   r>   r5   rI   r4   timeZperf_counterrecolorize_maintag_nextrangerJ   rK   rN   rM   )r-   Zt0Zt1topr   r   r	   rK      s@          zColorDelegator.recolorizec             C   s  d}x| j d|}|sP |\}}| jd|| | jd|}|rJ|d }nd}d}|}d}d}x|s|}| j|d|  }t|d d	}d| j|d
 k}| j||}	|	sd S x| jD ]}
| j|
|| qW ||	 }| jj	|}x|rx|j
 j D ]\}}| r|j|\}}| j||d|  |d|   |dk r| jj||}| r|jd\}}| jd|d|  |d|    qW | jj	||j }qW d| j|d
 kr|}d}nd}|s| jd| | j  | jrbtrtd d S qbW qW d S )Nz1.0r<   r   rF    Fz+%d lines linestart   d   z-1cz+%dcdefclassr;   zcolorizing stopped)rX   rY   )rS   
tag_removeZtag_prevranger?   minZ	tag_namesgetr6   r*   search	groupdictr7   spanrG   r+   matchr.   updater4   r=   r>   )r-   nextitemheadtailrB   Zlines_to_getokZmarkliner8   mkeyvalueabm1r   r   r	   rR      sl    





 zColorDelegator.recolorize_mainc             C   s"   x| j D ]}| j|dd qW d S )Nz1.0r.   )r6   rZ   )r-   r8   r   r   r	   removecolors   s    zColorDelegator.removecolors)N)N)N)N)__name__
__module____qualname__r)   r0   r1   r,   r@   rC   rH   r5   rI   r3   rN   rO   r2   rK   rR   rn   r   r   r   r	   r(   7   s    



Ar(   c             C   s   ddl m}m} ddlm} || }|jd tt| j j	ddd  \}}|jd|d |d	 f  d
}||dd}|j
ddd |jd| |j  t| ||}	t }
|	j|
 d S )Nr   )ToplevelText)
PercolatorzTest ColorDelegator+rF   z700x250+%d+%d      aa  if True: int ('1') # keyword, builtin, string, comment
elif False: print(0)
else: float(None)
if iF + If + IF: 'keyword matching must respect case'
if'': x or''  # valid string-keyword no-space combinations
async def f(): await g()
# All valid prefixes for unicode and byte strings should be colored.
'x', '''x''', "x", """x"""
r'x', u'x', R'x', U'x', f'x', F'x'
fr'x', Fr'x', fR'x', FR'x', rf'x', rF'x', Rf'x', RF'x'
b'x',B'x', br'x',Br'x',bR'x',BR'x', rb'x'.rB'x',Rb'x',RB'x'
# Invalid combinations of legal characters should be half colored.
ur'x', ru'x', uf'x', fu'x', UR'x', ufr'x', rfu'x', xf'x', fx'x'
Zwhite)r!   Zboth)expandZfillr@   )Ztkinterrr   rs   Zidlelib.percolatorrt   titlemapintZgeometrysplitZpackr@   Z	focus_setr'   r(   Zinsertfilter)parentrr   rs   rt   rT   xysourcer%   pdr   r   r	   _color_delegator  s    
 r   __main__)mainz idlelib.idle_test.test_colorizerrV   )	verbosityexit)run)r   r   rerQ   Zidlelib.configr   Zidlelib.delegatorr   r=   r
   r   compileSr*   r+   r'   r(   r   ro   Zunittestr   Zidlelib.idle_test.htestr   r   r   r   r	   <module>   s&    K"