ž ©’f” c @sĪdZddlZddlmZmZmZmZmZddlZddl m Z ddl m Z edddd d d d d dddg ƒZdZdZejdƒdd„ZGdd„dƒZdS(uICodeContext - Extension to 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 numlines variable in the CodeContext section of config-extensions.def. Lines which do not open blocks are not shown in the context hints pane. iN(uTOPuLEFTuXuWuSUNKEN(umaxsize(uidleConfuclassudefuelifuelseuexceptufinallyuforuifutryuwhileuwithidiču ^(\s*)(\w*)cCs|j|ƒjƒS(N(umatchugroups(usuc((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyusucBsę|EeZdZdd gfgZejddddddd ƒZejddd dd dd ƒZejddd dd ddƒZdd„Z ddd„Z dd„Z dddd„Z dd„Zdd„Zdd„ZdS(!u CodeContextuoptionsu!Code Conte_xtu<>u extensionsunumlinesutypeuintudefaultiubgcolorustru LightGrayufgcoloruBlackcCsŗ||_|j|_|jd|_d|_dg|_d|_tj ddddd d d ƒ}|rŠ|j ƒ|jj d dƒn|jj t|jƒ|jj t|jƒdS(Nufontiiuu extensionsu CodeContextuvisibleutypeubooludefaultu<>i’’’’F(ii’’’’uFT(ueditwinutextutextfontuNoneulabeluFalseuinfou topvisibleuidleConfu GetOptionutoggle_code_context_eventusetvaruTrueuafteruUPDATEINTERVALu timer_eventuFONTUPDATEINTERVALufont_timer_event(uselfueditwinuvisible((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu__init__"s       uCodeContext.__init__cCsŒ|jsC|jj|jjf}d}xM|D]E}|tt|jƒdƒƒ7}|tt|jdƒƒƒ7}q.Wd}x-|D]%}|tt|jdƒƒƒ7}q„Wtj |jj dd|j ddt dt d |jd |jd |jd dd|d|d tƒ |_|jjdtdtddd|jjƒn|jjƒd|_tjdddt|jdk ƒƒtjƒdS(Niupadxuborderutextu iuanchorujustifyufontubgufguwidthureliefusideufilluexpandubeforeu extensionsu CodeContextuvisibleF(ulabelueditwinutextu text_frameuintustru pack_infoucgetutkinteruLabelutopu context_depthuWuLEFTutextfontubgcolorufgcoloruSUNKENupackuTOPuXuFalseudestroyuNoneuidleConfu SetOptionuSaveUserCfgFiles(uselfueventuwidgetsupadxuwidgetuborder((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyutoggle_code_context_event7s0   # #      u%CodeContext.toggle_code_context_eventcCs‘|jjd|d|ƒ}t|ƒ\}}|tko>|}t|ƒt|ƒkso|t|ƒdkrxt}n t|ƒ}|||fS(uÖGet the line indent value, text, and any block start keyword If the line does not start a block, the keyword value is False. The indentation of empty lines (or comment lines) is INFINITY. u%d.0u%d.endu#(utextugetugetspacesfirstwordu BLOCKOPENERSulenuINFINITY(uselfulinenumutextuspacesu firstworduopeneruindent((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu get_line_info[s.  uCodeContext.get_line_infoiic CsŃg}t}x®t||ddƒD]–}|j|ƒ\}}} ||kr#|}| dkrl|d7}n| r¦||kr¦||kr¦|j|||| fƒn||kr¹Pq¹q#q#W|jƒ||fS(uäGet context lines, starting at new_topvisible and working backwards. Stop when stopline or stopindent is reached. Return a tuple of context data and the indent level at the top of the region inspected. iuelseuelifi’’’’(uelseuelif(uINFINITYurangeu get_line_infouappendureverse( uselfunew_topvisibleustoplineu stopindentulinesu lastindentulinenumuindentutextuopener((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu get_contextks      uCodeContext.get_contextcCs˜t|jjdƒjdƒdƒ}|j|kr8dS|j|kr|j||jƒ\}}x²|jd d|kr‰|jd =qeWnŠ|j|kr|jd dd}x6|jdd|kré|jdd}|jd=q“W|j||jddd|ƒ\}}n|jj|ƒ||_dgtd|j t |jƒƒ}|dd„|j|j d…Dƒ7}d j |ƒ|j d £s u3CodeContext.update_code_context..u utexti’’’’i’’’’i’’’’i’’’’i’’’’i’’’’i’’’’( uintutextuindexusplitu topvisibleu get_contextuinfouextendumaxu context_depthulenujoinulabel(uselfunew_topvisibleulinesu lastindentu stopindentucontext_strings((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyuupdate_code_context†s*%   &(uCodeContext.update_code_contextcCs0|jr|jƒn|jjt|jƒdS(N(ulabeluupdate_code_contextutextuafteruUPDATEINTERVALu timer_event(uself((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu timer_event¦s  uCodeContext.timer_eventcCs[|jd}|jrA||jkrA||_|j|jd>(u__name__u __module__u __qualname__umenudefsuidleConfu GetOptionu context_depthubgcolorufgcoloru__init__uNoneutoggle_code_context_eventu get_line_infou get_contextuupdate_code_contextu timer_eventufont_timer_event(u __locals__((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu CodeContexts    $  u CodeContext(u__doc__utkinterutkinter.constantsuTOPuLEFTuXuWuSUNKENureusysumaxsizeuINFINITYuidlelib.configHandleruidleConfusetu BLOCKOPENERSuUPDATEINTERVALuFONTUPDATEINTERVALucompileugetspacesfirstwordu CodeContext(((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu s (