+
     Bi$                         R t ^ RIHt ^ RIHt RRRRRR/t^dt ! R	 R
4      t]P                  4        ]	R8X  d   ^ RI
Ht ]! R^R7       R# R# )zParenMatch -- for parenthesis matching.

When you hit a right paren, the cursor should move briefly to the left
paren.  Paren here is used generically; the matching applies to
parentheses, square brackets, and curly braces.
)HyperParser)idleConf)(][}{c                      a  ] tR t^t o RtRtRtR t]R 4       t	R t
R tR tR tR	 tRR ltR tR tR tR tR]R]R]R]/tR tR tRtV tR
# )
ParenMatcha  Highlight matching openers and closers, (), [], and {}.

There are three supported styles of paren matching.  When a right
paren (opener) is typed:

opener -- highlight the matching left paren (closer);
parens -- highlight the left and right parens (opener and closer);
expression -- highlight the entire expression from opener to closer.
(For back compatibility, 'default' is a synonym for 'opener').

Flash-delay is the maximum milliseconds the highlighting remains.
Any cursor movement (key press or click) before that removes the
highlight.  If flash-delay is 0, there is no maximum.

TODO:
- Augment bell() with mismatch warning in status window.
- Highlight when cursor is moved to the right of a closer.
  This might be too expensive to check.
z<<parenmatch-check-restore>>c                    Wn         VP                  V n        VP                  P                  V P                  V P                  4       ^ V n        ^ V n        R# )    N)editwintextbindRESTORE_VIRTUAL_EVENT_NAMErestore_eventcounteris_restore_active)selfr   s   &&)/usr/lib/python3.14/idlelib/parenmatch.py__init__ParenMatch.__init__(   sF    LL	 	$99,,	.!"    c                "   \         P                  ! R RRRR7      V n        \         P                  ! R RRRRR7      V n        \         P                  ! R RR	R
^R7      V n        \         P
                  ! \         P                  ! 4       R4      V n        R# )
extensionsr   styleopener)defaultzflash-delayinti  )typer   bellboolhiliteN)r   	GetOptionSTYLEFLASH_DELAYBELLGetHighlightCurrentThemeHILITE_CONFIG)clss   &r   reloadParenMatch.reload3   s{    &&gxA	",,\-eCQ%%\&vqJ$11(2G2G2I2:<r   c                    V P                   '       gC   V P                   F)  pV P                  P                  V P                  V4       K+  	  RV n         R# R# )z5Activate mechanism to restore text from highlighting.TN)r   RESTORE_SEQUENCESr   	event_addr   r   seqs   & r   activate_restoreParenMatch.activate_restore>   sE    %%%--		##D$C$CSI .%)D" &r   c                    V P                   '       dC   V P                   F)  pV P                  P                  V P                  V4       K+  	  RV n         R# R# )zRemove restore event bindings.FN)r   r/   r   event_deleter   r1   s   & r   deactivate_restoreParenMatch.deactivate_restoreE   sE    !!!--		&&t'F'FL .%*D" "r   c                p    \        V P                  R4      P                  4       pV P                  V4       R# )zAHandle editor 'show surrounding parens' event (menu or shortcut).insertbreak)r   r   get_surrounding_bracketsfinish_paren_event)r   eventindicess   && r   flash_paren_eventParenMatch.flash_paren_eventL   s/    t||X6,,. 	(r   c                   V P                   P                  R4      pV\        9  d   R# \        V P                  R4      pVP                  4       '       g   R# VP                  \        V,          R4      pV P                  V4       R# )zHandle user input of closer.z	insert-1cNT)r   get_openersr   r   
is_in_coder<   r=   )r   r>   closerhpr?   s   &&   r   paren_closed_eventParenMatch.paren_closed_eventS   sg     {+!{3}}--hv.>E(r   c                T   Vf/   V P                   '       d   V P                  P                  4        R # V P                  4        V P                  P                  V P                  V P                  4      ! W4       V P                  '       d   V P                  MV P                  ! 4        R # N)r'   r   r!   r3   tagfuncsrC   r%   create_tag_expressionr&   set_timeout_lastset_timeout_noner   r?   s   &&r   r=   ParenMatch.finish_paren_event`   sv    ?tyyyIINN$**d&@&@A$P"&"2"2"2		 11
2 	5r   Nc                    V P                   P                  R4       V P                  4        V ;P                  ^,          un        R# )zRemove effect of doing match.parenN)r   
tag_deleter7   r   )r   r>   s   &&r   r   ParenMatch.restore_eventk   s.    		W%!r   c                J    WP                   8X  d   V P                  4        R # R # rK   )r   r   )r   timer_counts   &&r   handle_restore_timerParenMatch.handle_restore_timerq   s    ,,&  'r   c                    V P                   P                  RV^ ,          4       V P                   P                  RV P                  4       R# )z'Highlight the single paren that matchesrS   N)r   tag_add
tag_configr*   rP   s   &&r   create_tag_openerParenMatch.create_tag_openerx   s4    		'71:.		Wd&8&89r   c                J   V P                   P                  V^,          4      R9   d   V^,          R,           pM	V^,          pV P                   P                  RV^ ,          V^ ,          R,           VR,           V4       V P                   P                  RV P                  4       R# )z#Highlight the left and right parens+1crS   z-1cNr   r   r   r   rC   r[   r\   r*   r   r?   
rightindexs   && r   create_tag_parensParenMatch.create_tag_parens}   sy    99==$7 E)J J		'71:wqz%/?EAQS]^		Wd&8&89r   c                   V P                   P                  V^,          4      R9   d   V^,          R,           pM	V^,          pV P                   P                  RV^ ,          V4       V P                   P                  RV P                  4       R# )zHighlight the entire expressionr`   rS   Nra   rb   rc   s   && r   rM    ParenMatch.create_tag_expression   sf    99==$7 E)J J		'71:z:		Wd&8&89r   r   r   parens
expressionc                    V ;P                   ^,          un         W P                   V P                  P                  R4      3R lpV P                  P                  P                  \        W4       R# )zKHighlight will remain until user input turns it off
or the insert has movedr:   c                     W1P                   P                  R 4      8w  d   VP                  V4       R# VP                  P                  P                  \        W 4       R# )r:   N)r   indexrX   r   
text_frameafterCHECK_DELAY)callmer   crm   s   &&&&r   rq   +ParenMatch.set_timeout_none.<locals>.callme   s=    		11))!,''--k6Jr   N)r   r   rm   r   rn   ro   rp   )r   rq   s   & r   rO   ParenMatch.set_timeout_none   sK     	 $2	K 	%%k6Br   c                    V ;P                   ^,          un         V P                  P                  P                  V P                  W P                   3R l4       R# )zFThe last highlight created will be removed after FLASH_DELAY millisecsc                 $    V P                  V4      # rK   )rX   )r   rr   s   &&r   <lambda>-ParenMatch.set_timeout_last.<locals>.<lambda>   s    d.G.G.Jr   N)r   r   rn   ro   r&   )r   s   &r   rN   ParenMatch.set_timeout_last   s>     	%%J	Lr   )r   r   r   r   )z
<KeyPress>z<ButtonPress>z<Key-Return>z<Key-BackSpace>rK   )__name__
__module____qualname____firstlineno____doc__r   r/   r   classmethodr,   r3   r7   r@   rH   r=   r   rX   r]   re   rM   rL   rO   rN   __static_attributes____classdictcell__)__classdict__s   @r   r   r      s     ( "@<	# < <*+	5!:
:: 	#$#+	
HCL Lr   r   __main__)mainz!idlelib.idle_test.test_parenmatch)	verbosityN)r~   idlelib.hyperparserr   idlelib.configr   rD   rp   r   r,   rz   unittestr    r   r   <module>r      sc    , #CC$bL bLJ     z	,: r   