u@kMdZddlmZddlmZddddZdZGd d Zeje d k(rdd l m Z e d dyy)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([{)]}dceZdZdZdZdZdZedZdZ dZ dZ d Z d Z dd Zd ZdZdZdZeeeedZdZdZy ) 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<>)z z z zc||_|j|_|jj|j|jd|_d|_y)Nr)editwintextbindRESTORE_VIRTUAL_EVENT_NAME restore_eventcounteris_restore_active)selfrs 9/opt/alt/python312/lib64/python3.12/idlelib/parenmatch.py__init__zParenMatch.__init__(sH LL   $99,, . !"ctjdddd|_tjddddd |_tjddd d d |_tj tj d |_y)N extensionsrstyleopener)defaultz flash-delayinti)typerbellboolhilite)r GetOptionSTYLE FLASH_DELAYBELL GetHighlight CurrentTheme HILITE_CONFIG)clss rreloadzParenMatch.reload3s{&& gxA ",,\-eCQ%%\&vqJ$11(2G2G2I2:<rc|js?|jD](}|jj|j|*d|_yy)z5Activate mechanism to restore text from highlighting.TN)rRESTORE_SEQUENCESr event_addrrseqs ractivate_restorezParenMatch.activate_restore>sB%%-- ##D$C$CSI.%)D "&rc|jr?|jD](}|jj|j|*d|_yy)zRemove restore event bindings.FN)rr0r event_deleterr2s rdeactivate_restorezParenMatch.deactivate_restoreEsB  ! !-- &&t'F'FL.%*D " "rcnt|jdj}|j|y)zAHandle editor 'show surrounding parens' event (menu or shortcut).insertbreak)rrget_surrounding_bracketsfinish_paren_event)reventindicess rflash_paren_eventzParenMatch.flash_paren_eventLs/t||X6,,.  (rc|jjd}|tvryt|jd}|j sy|j t|d}|j|y)zHandle user input of closer.z insert-1cNT)rget_openersrr is_in_coder;r<)rr=closerhpr>s rparen_closed_eventzParenMatch.paren_closed_eventSse{+  !  { 3}} --hv.>E (rc@|'|jr|jjy|j|jj |j |j|||jr|jy|jyN) r)rr"r4tagfuncsrAr'create_tag_expressionr(set_timeout_lastset_timeout_nonerr>s rr<zParenMatch.finish_paren_event`sy ?tyy IINN   A $**d&@&@A$P 2$"2"2   5 11 5rNc|jjd|j|xjdz c_y)zRemove effect of doing match.parenr$N)r tag_deleter7r)rr=s rrzParenMatch.restore_eventks. W% !  rcD||jk(r|jyyrH)rr)r timer_counts rhandle_restore_timerzParenMatch.handle_restore_timerqs $,, &     'rc|jjd|d|jjd|jy)z'Highlight the single paren that matchesrOrN)rtag_add tag_configr,rMs rcreate_tag_openerzParenMatch.create_tag_openerxs4 '71:. Wd&8&89rc|jj|ddvr |ddz}n|d}|jjd|d|ddz|dz||jjd|jy)z#Highlight the left and right parensr$r+1crOrz-1cNrrArUrVr,rr> rightindexs rcreate_tag_parenszParenMatch.create_tag_parens}sy 99== $ 7 E)J J '71:wqz%/?EAQS]^ Wd&8&89rc|jj|ddvr |ddz}n|d}|jjd|d||jjd|jy)zHighlight the entire expressionr$rrYrOrNrZr[s rrJz ParenMatch.create_tag_expressionsf 99== $ 7 E)J J '71:z: Wd&8&89r)rrparens expressionc|xjdz c_||j|jjdfd}|jjj t ||y)zSHighlight will remain until user input turns it off or the insert has movedr$r9c||jjdk7r|j|y|jjj t ||y)Nr9)rindexrSr text_frameafter CHECK_DELAY)callmercrcs rrgz+ParenMatch.set_timeout_none..callmesA 11))!, ''--k66JrN)rrrcrrdrerf)rrgs rrLzParenMatch.set_timeout_nonesO  $ 2 K %%k66Brc|xjdz c_|jjj|j||jfdy)zFThe last highlight created will be removed after FLASH_DELAY millisecsr$c$|j|SrH)rS)rrhs rz-ParenMatch.set_timeout_last..sd.G.G.JrN)rrrdrer()rs rrKzParenMatch.set_timeout_lasts@   %%    J LrrH)__name__ __module__ __qualname____doc__rr0r classmethodr.r4r7r?rFr<rrSrWr]rJrIrLrKrrrr s("@< #<<*+  5 !: ::$$#+  H CLrr__main__)mainz!idlelib.idle_test.test_parenmatch) verbosityN) roidlelib.hyperparserridlelib.configrrBrfrr.rlunittestrsrqrrrys] ,# $ bLbLJ  z ,:r