e,SrSSKrSSKJr SSKJrJrJr SSK J r J r SSK J r 1Skr\R"S54S jrS r"S S 5r\R'5 \S :XaSSKJr \"SSSS9 gg)acodecontext - 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)FrameTextTclError)NSEWSUNKEN)idleConf> ifdeffortryelifelsewithasyncclasswhileexceptfinallyz ^(\s*)(\w*)c@URU5R5$)z>Extract the beginning whitespace and first word from codeline.)matchgroups)codelinecs 9/opt/imh/python3.13/lib/python3.13/idlelib/codecontext.pyget_spaces_firstwordrs 778  # # %%c[U5up[U5n[U5U:XdXS:Xa[nU[;=(a UnX0U4$)zReturn 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. #)rlenINFINITY BLOCKOPENERS)rspaces firstwordindentopeners r get_line_infor'sO -X6F [F 8}("2c"9 , & 49F V ##rct\rSrSrSrSrSrSr\S5r Sr SS jr SS jr S r SS jrS rSrSrSrg) CodeContext-z,Display block context above the edit window.dcRXlURUlUR5 g)aInitialize 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)editwintext_reset)selfr-s r__init__CodeContext.__init__1s" LL  rcLSUlSUlSUlSUlS/Ulg)N)rF)contextcell00t1 topvisibleinfor0s rr/CodeContext._resetFs(  '( rc>[R"SSSSSS9Ulg)z!Load class variables from config. extensionsr)maxlinesint)typedefaultN)r GetOption context_depth)clss rreloadCodeContext.reloadMs#%..|]/979;rcURb.URRUR5 SUlgg![a Nf=f)zCancel scheduled events.N)r9r. after_cancelrr<s r__del__CodeContext.__del__TsI 77   &&tww/DG   s%= A  A Nc  URGcURRURR4nSnSnUHnXPRRLaUR 5OUR 5nX5R RUS5- nX5R RURS55- nXER RURS55- nM [URRSSSX4[SS9=oplUR5 UR5 URSUR5 UR5 UR!SS["S 9 [$R&"[$R("5S 5n[+URRUS S 9UlUR,R!SS["S 9 S n OyURR/5 SUlUR,R/5 SUlURR1UR25 UR55 Sn URR7SSU S3S9 g)zToggle 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. Nrpadxborderr4disabled)heightwidthhighlightthicknessrOrPreliefstatez)rowcolumnsticky linenumber backgroundbgHideShowoptionsz *ode*ontextz Code Context)menuindexlabelbreak)r7r-r. text_frame grid_info pack_infotkgetintcgetrr update_fontupdate_highlight_colorsbind jumptoline timer_eventgridrr GetHighlight CurrentThemerr8destroyrKr9r/update_menu_label) r0eventwidgetsrOrPwidgetr;r7line_number_colors menu_statuss rtoggle_code_context_event%CodeContext.toggle_code_context_event]s% <<  ll'')@)@@GDF!!\\%6%66((*#--/ ((f66 ((V)<==))**6;;x+@AA "&* ''#$z &K KGl      ( ( * LL,doo >     LLQqL 6!)!6!6x7L7L7N7C"E  7 7+=l+KMDK KK  1T  : K LL "DL KK   !DK II " "477 + KKM K &&I]0;}M-J ' LrcRUS:de/n[n[XS- S5HrnURRUS3US35n[ U5upn X:dM:UnU S;aUS- nU (aXa:aX:aUR XhX45 XS::dMr O UR 5 XE4$)aJReturn 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. rr4r5.0z.end)rr)r!ranger.getr'appendreverse) r0new_topvisiblestopline stopindentlines lastindentlinenumrr%r.r&s r get_contextCodeContext.get_contexts!|| ^aZEvent on editor text widget triggered every UPDATEINTERVAL ms.N)r7rr.afterUPDATEINTERVALror9r<s rroCodeContext.timer_events? << #  $ $ &iiood&9&94;K;KLDG $rcURb1[R"URSS5nXRS'gg)Nmain EditorWindowfont)r7r GetFontr.)r0rs rrkCodeContext.update_fonts5 << ###DIIv~FD#'LL  $rcbURbN[R"[R"5S5nUSURS'USURS'URbG[R"[R"5S5nURR USS9 gg)Nr7r[ foregroundrZr\)r7r rqrrr8config)r0colorsrxs rrl#CodeContext.update_highlight_colorss << #**8+@+@+BINF)/ )=DLL &)/ )=DLL & ;; "!)!6!6x7L7L7N7C"E  KK  "4\"B  C #r)r8r7r-r;r9r.r:)N)r4r)__name__ __module__ __qualname____firstlineno____doc__rr1r/ classmethodrHrLrzrrrnrorkrl__static_attributes__rrr)r)-sT2N*);; 6p!<&+P'*M ( Drr)__main__)rz"idlelib.idle_test.test_codecontextrF) verbosityexit)rresysrr!tkinterrrrtkinter.constantsrridlelib.configr r"compilerr'r)rHrunittestrrrrrsy  #))*#> &(ZZ%?& $WDWDt  z -Gr