Ë ÷¿æt+´2ãóæ—dZddlZddlmZddlmZmZmZddl m Z m Z ddl m Z hd£Zejd«fd „Zd „ZGd „d «Zej'«ed k(rddlmZeddd¬«yy)a¡codecontext - 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 maxlines variable in the codecontext section of config-extensions.def. Lines which do not open blocks are not shown in the context hints pane. For EditorWindows, <> is bound to CodeContext(self). toggle_code_context_event. éN)Úmaxsize)ÚFrameÚTextÚTclError)ÚNSEWÚSUNKEN)ÚidleConf> ÚifÚdefÚforÚtryÚelifÚelseÚwithÚasyncÚclassÚwhileÚexceptÚfinallyz ^(\s*)(\w*)có@—|j|«j«S)z>Extract the beginning whitespace and first word from codeline.)ÚmatchÚgroups)ÚcodelineÚcs ú*/usr/lib/python3.12/idlelib/codecontext.pyÚget_spaces_firstwordrs€à �7‰7�8Ó × #Ñ #Ó %Ð%ócóŽ—t|«\}}t|«}t|«|k(s||dk(rt}|tvxr|}|||fS)zÐReturn tuple of (line indent value, codeline, block start keyword). The indentation of empty lines (or comment lines) is INFINITY. If the line does not start a block, the keyword value is False. Ú#)rÚlenÚINFINITYÚ BLOCKOPENERS)rÚspacesÚ firstwordÚindentÚopeners rÚ get_line_infor'sU€ô -¨XÓ6Ñ€FˆIÜ �‹[€FÜ ˆ8ƒ}˜Ò (¨6Ñ"2°cÒ"9ÜˆØ œ,Ð &Ò 4¨9€FØ �8˜VÐ #Ð#rcóf—eZdZdZdZd„Zd„Zed„«Zd„Z dd„Z dd „Z d „Z dd „Z d „Zd „Zd„Zy)Ú CodeContextz,Display block context above the edit window.édcóT—||_|j|_|j«y)a Initialize settings for context block. editwin is the Editor window for the context block. self.text is the editor window text widget. self.context displays the code context text above the editor text. Initially None, it is toggled via <>. self.topvisible is the number of the top text line displayed. self.info is a list of (line number, indent level, line text, block keyword) tuples for the block structure above topvisible. self.info[0] is initialized with a 'dummy' line which starts the toplevel 'block' of the module. self.t1 and self.t2 are two timer events on the editor text widget to monitor for changes to the context text or editor font. N)ÚeditwinÚtextÚ_reset)Úselfr,s rÚ__init__zCodeContext.__init__1s€ð"ˆŒ Ø—L‘LˆŒ Ø � ‰ � rcóL—d|_d|_d|_d|_dg|_y)Né)réÿÿÿÿÚF)ÚcontextÚcell00Út1Ú topvisibleÚinfo©r/s rr.zCodeContext._resetFs(€ØˆŒ ؈Œ ؈ŒØˆŒØ'Ð(ˆ� rcóB—tjddddd¬«|_y)z!Load class variables from config.Ú extensionsr)ÚmaxlinesÚinté)ÚtypeÚdefaultN)r Ú GetOptionÚ context_depth)Úclss rÚreloadzCodeContext.reloadMs#€ô%×.Ñ.¨|¸]Ø/9ÀØ79ô;ˆÕrcó–—|j�. |jj|j«d|_yy#t$rYŒwxYw)zCancel scheduled events.N)r7r-Ú after_cancelrr:s rÚ__del__zCodeContext.__del__TsI€à �7‰7Ð ð Ø— ‘ ×&Ñ& t§w¡wÔ/ðˆD�Gð øôò Ùð úsŽ%<¼ AÁANc ó>—|j�€ö|jj|jjf}d}d}|D]µ}||jjur|j «n|j «}||j j|d«z }||j j|jd««z }||j j|jd««z }Œ·t|jjddd||td¬«x}|_|j«|j«|jd|j«|j«|j!ddt"¬ «t%j&t%j(«d «}t+|jj|d ¬ «|_|j,j!ddt"¬ «d } ny|jj/«d|_|j,j/«d|_|jj1|j2«|j5«d} |jj7dd| ›d�¬«y)aToggle code context display. If self.context doesn't exist, create it to match the size of the editor window text (toggle on). If it does exist, destroy it (toggle off). Return 'break' to complete the processing of the binding. NrÚpadxÚborderr2Údisabled)ÚheightÚwidthÚhighlightthicknessrJrKÚreliefÚstatez)ÚrowÚcolumnÚstickyÚ linenumberÚ background©ÚbgÚHideÚShowÚoptionsz *ode*ontextz Code Context)ÚmenuÚindexÚlabelÚbreak)r5r,r-Ú text_frameÚ grid_infoÚ pack_infoÚtkÚgetintÚcgetrrÚ update_fontÚupdate_highlight_colorsÚbindÚ jumptolineÚ timer_eventÚgridrr Ú GetHighlightÚ CurrentThemerr6ÚdestroyrGr7r.Úupdate_menu_label) r/ÚeventÚwidgetsrJrKÚwidgetr9r5Úline_number_colorsÚ menu_statuss rÚtoggle_code_context_eventz%CodeContext.toggle_code_context_event]s1€ð �<‰<Ñ ð —l‘l×'Ñ'¨¯©×)@Ñ)@Ð@ˆGàˆD؈FÛ!�à! T§\¡\×%6Ñ%6Ñ6ð×(Ñ(Ô*à#×-Ñ-Ó/ð𘟠™ ×(Ñ(¨¨f©Ó6Ñ6�ؘŸ ™ ×(Ñ(¨¯©°VÓ)<Ó=Ñ=�ؘ&Ÿ)™)×*Ñ*¨6¯;©;°xÓ+@ÓAÑA‘ð "ô&*Ø— ‘ ×'Ñ'ØØØ#$Ø &´¸zô &Kð KˆG�d”lð × Ñ Ô Ø × (Ñ (Ô *Ø �L‰LÐ,¨d¯o©oÔ >à × Ñ Ô à �L‰L˜Q q´ˆLÔ 6ä!)×!6Ñ!6´x×7LÑ7LÓ7NØ7Có"EÐ ä § ¡ × 7Ñ 7Ø+=¸lÑ+KôMˆDŒKà �K‰K× Ñ  ¨1´TÐ Ô :Ø ‰Kà �L‰L× Ñ Ô "؈DŒLØ �K‰K× Ñ Ô !؈DŒKØ �I‰I× "Ñ " 4§7¡7Ô +Ø �K‰KŒMØ ˆKØ � ‰ ×&Ñ&¨I¸]Ø0;¨}¸MÐ-Jð 'ô LàrcóF—|dkDsJ‚g}t}t||dz d«D]l}|jj|›d�|›d�«}t |«\}} } ||ksŒ:|}| dvr|dz }| r||kr||k\r|j ||| | f«||ksŒln|j «||fS)azReturn a list of block line tuples and the 'last' indent. The tuple fields are (linenum, indent, text, opener). The list represents header lines from new_topvisible back to stopline with successively shorter indents > stopindent. The list is returned ordered by line number. Last indent returned is the smallest indent observed. rr2r3ú.0z.end)rr)r!Úranger-Úgetr'ÚappendÚreverse) r/Únew_topvisibleÚstoplineÚ stopindentÚlinesÚ lastindentÚlinenumrr%r-r&s rÚ get_contextzCodeContext.get_context•sË€ð˜!Š|Ј|Øˆäˆ ô˜^¨X°a©Z¸Ö<ˆGØ—y‘y—}‘}¨ y° ^¸°yÀÐ5EÓFˆHÜ#0°Ó#:Ñ ˆF�D˜&ؘ Ó"Ø#� ØÐ-Ñ-à !‘O�JÙ˜g¨Ò6¸6ÀZÒ;OØ—L‘L '¨6°4¸Ð!@ÔAØ Ó+Ùð=ð � ‰ ŒØ�jÐ Ð rcóò—|jjd«}|j|k(ry|j|krX|j||j«\}}|jdd|k\r¬|jd=|jdd|k\rŒ#nˆ|jdddz}|jdd|k\r5|jdd}|jd=|jdd|k\rŒ5|j||jdddz|«\}}|jj |«||_|j|j dD�cgc]}|d‘Œ }}|drdnd}t|«|z |jd<d|jd <|jjd d «|jjd d j||d««d |jd <ycc}w)aLUpdate context information and lines visible in the context pane. No update is done if the text hasn't been scrolled. If the text was scrolled, the lines that should be shown in the context will be retrieved and the context area will be updated with the code, up to the number of maxlines. z@0,0Nr3r2rérMÚnormalrQz1.0ÚendÚ rL) r,Ú getlinenor8r‚r9ÚextendrCr r5ÚdeleteÚinsertÚjoin)r/r|rr€r~ÚxÚcontext_stringsÚ showfirsts rÚupdate_code_contextzCodeContext.update_code_context³sê€ðŸ™×/Ñ/°Ó7ˆØ �?‰?˜nÒ ,Ø Ø �?‰?˜^Ò +Ø $× 0Ñ 0°Ø15·±ó!BÑ ˆE�:ð—)‘)˜B‘- Ñ" jÒ0Ø—I‘I˜b�Mð—)‘)˜B‘- Ñ" jÔ0🙠2™ qÑ)¨AÑ-ˆJð—)‘)˜B‘- Ñ" nÒ4Ø!ŸY™Y r™]¨1Ñ-� Ø—I‘I˜b�Mð—)‘)˜B‘- Ñ" nÓ4ð!%× 0Ñ 0°Ø15·±¸2±¸qÑ1AÀ!Ñ1CØ1;ó!=Ñ ˆE�:ð � ‰ ×Ñ˜ÔØ(ˆŒà)-¯©°D×4FÑ4FÐ3FÐ3GÑ)HÓIÑ)H A˜1˜Q›4Ð)HˆÐIØ(¨Ò+‘A°ˆ ä!$ _Ó!5¸ Ñ!Aˆ� ‰ �XÑØ (ˆ� ‰ �WÑØ � ‰ ×јE 5Ô)Ø � ‰ ×јE 4§9¡9¨_¸Y¸ZÐ-HÓ#IÔJØ *ˆ� ‰ �WÒùòJsÅ G4có¬— |jjd«y#t$r¬t|j«}|dk(rd}n^t t |jjd«««}td||jz «dz }|j||zd}|jj|›d�«|j«YywxYw)z° Show clicked context line at top of editor. If a selection was made, don't jump; allow copying. If no visible context, show the top line of the file. z sel.firstr2r‹rrwN) r5r]rr r9r>ÚfloatÚmaxrCr-Úyviewr�)r/rprÚnewtopÚ contextlineÚoffsets rrizCodeContext.jumptolineÛs·€ð 'Ø �L‰L× Ñ ˜{Õ +øÜò 'ܘŸ ™ “NˆEؘŠzØ‘ô"¤%¨¯ © ×(:Ñ(:¸8Ó(DÓ"EÓF� ä˜Q ¨×(:Ñ(:Ñ :Ó;¸aÑ?�ØŸ™ 6¨KÑ#7Ñ8¸Ñ;�Ø �I‰I�O‰O˜v˜h b˜MÔ *Ø × $Ñ $Ö &ð 'ús‚žB2CÃCcó¨—|j�F|j«|jj|j|j «|_yy)z>Event on editor text widget triggered every UPDATEINTERVAL ms.N)r5r�r-ÚafterÚUPDATEINTERVALrjr7r:s rrjzCodeContext.timer_eventðs?€à �<‰<Ð #Ø × $Ñ $Ô &Ø—i‘i—o‘o d×&9Ñ&9¸4×;KÑ;KÓLˆD�Gð $rcó~—|j�1tj|jdd«}||jd<yy)NÚmainÚ EditorWindowÚfont)r5r ÚGetFontr-)r/ržs rrfzCodeContext.update_fontös7€Ø �<‰<Ð #Ü×#Ñ# D§I¡I¨v°~ÓFˆDØ#'ˆD�L‰L˜Ò ð $rcó\—|j�Ltjtj«d«}|d|jd<|d|jd<|j�Htjtj«d«}|jj |d¬«yy)Nr5rVÚ foregroundrUrW)r5r rlrmr6Úconfig)r/Úcolorsrss rrgz#CodeContext.update_highlight_colorsûs—€Ø �<‰<Ð #Ü×*Ñ*¬8×+@Ñ+@Ó+BÀIÓNˆFØ)/° Ñ)=ˆD�L‰L˜Ñ &Ø)/° Ñ)=ˆD�L‰L˜Ñ &à �;‰;Ð "Ü!)×!6Ñ!6´x×7LÑ7LÓ7NØ7Có"EÐ à �K‰K× Ñ Ð"4°\Ñ"BÐ Õ Cð #r)N)r2r)Ú__name__Ú __module__Ú __qualname__Ú__doc__ršr0r.Ú classmethodrErHrur‚r�rirjrfrg©rrr)r)-sT„Ù2Ø€Nòò*)ðñ;óð;ò ó6óp!ò<&+óP'ò*Mò (ó Drr)Ú__main__)rœz"idlelib.idle_test.test_codecontextr„F)Ú verbosityÚexit)r§ÚreÚsysrr!ÚtkinterrrrÚtkinter.constantsrrÚidlelib.configr r"Úcompilerr'r)rEr¤Úunittestrœr©rrÚr´s{ðñ ó Ý#ç)Ñ)ß*å#ò>€ ð&0 R§Z¡Z°Ó%?ó&ò $÷WDñWDðt ×ÑÔð ˆzÒÝÙÐ -¸ÀÖGðr