oyMa c @sdZddlZddlmZmZmZmZmZddlZddl m Z ddl m Z edddd d d d d dddg ZdZdZejdddZGdddZdS(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(uidleConfuclassudefuelifuelseuexceptufinallyuforuifutryuwhileuwithidiu ^(\s*)(\w*)cCs|j|jS(N(umatchugroups(usuc((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyusucBs|EeZdZdd gfgZejddddddd Zejddd dd dd Zejddd dd ddZddZ dddZ ddZ ddddZ ddZddZddZdS(!u CodeContextuoptionsu!Code Conte_xtu<>u extensionsunumlinesutypeuintudefaultiubgcolorustru LightGrayufgcoloruBlackcCs||_|j|_|jd|_d|_dg|_d|_tj ddddd d d }|r|j |jj d dn|jj t|j|jj t|jdS(Nufontiiuu extensionsu CodeContextuvisibleutypeubooludefaultu<>iF(iiuFT(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|jd7}|tt|jd7}q.Wd}x-|D]%}|tt|jd7}qWtj |jj dd|j ddt dt d |jd |jd |jd dd|d|d t |_|jjdtdtddd|jjn|jjd|_tjdddt|jdk tjdS(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(uGet 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|dkstg}t}xt||ddD]}|j|\}}} ||kr5|}| dkr~|d7}n| r||kr||kr|j|||| fn||krPqq5q5W|j||fS(uGet 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. iiuelseuelifi(uelseuelif(uAssertionErroruINFINITYurangeu get_line_infouappendureverse( uselfunew_topvisibleustoplineu stopindentulinesu lastindentulinenumuindentutextuopener((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu get_contextks      uCodeContext.get_contextcCst|jjdjdd}|j|kr8dS|j|kr|j||j\}}x|jd d|kr|jd =qeWn|j|kr|jd dd}x6|jdd|kr|jdd}|jd=qW|j||jddd|\}}n|jj|||_dgtd|j t |j}|dd|j|j dD7}d j ||j d s u3CodeContext.update_code_context..u utextiiiiiii( uintutextuindexusplitu topvisibleu get_contextuinfouextendumaxu context_depthulenujoinulabel(uselfunew_topvisibleulinesu lastindentu stopindentucontext_strings((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyuupdate_code_contexts*%   &(uCodeContext.update_code_contextcCs0|jr|jn|jjt|jdS(N(ulabeluupdate_code_contextutextuafteruUPDATEINTERVALu timer_event(uself((u8/opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu timer_events  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 (