7ec @sdZddlZddlmZmZmZmZmZddlZddl m Z ddl m Z dddd d d d d dddh ZdZdZejddZdddYZdS(sICodeContext - 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(tTOPtLEFTtXtWtSUNKEN(tmaxint(tidleConftclasstdefteliftelsetexcepttfinallytfortifttrytwhiletwithidis ^(\s*)(\w*)cCs|j|jS(N(tmatchtgroups(tstc((s+/usr/lib64/python2.7/idlelib/CodeContext.pyttt CodeContextcBseZddgfgZejddddddd Zejddd dd dd Zejddd dd ddZdZddZ dZ dddZ dZ dZdZRS(toptionss!Code Conte_xts<>t extensionsRtnumlinesttypetinttdefaultitbgcolortstrt LightGraytfgcolortBlackcCs||_|j|_|jd|_d|_dddtfg|_d|_tj dddd d d t}|r|j |jj d t n|jj t|j|jj t|jdS( NtfontiiRiRRtvisibleRtboolRs<>(teditwinttextttextfonttNonetlabeltFalsetinfot topvisibleRt GetOptionttoggle_code_context_eventtsetvartTruetaftertUPDATEINTERVALt timer_eventtFONTUPDATEINTERVALtfont_timer_event(tselfR'R%((s+/usr/lib64/python2.7/idlelib/CodeContext.pyt__init__"s      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 |_|jjdtdtdtd|jjn|jjd|_tjdddt|jdk tjdS(NitpadxtborderR(s itanchortjustifyR$tbgtfgtwidthtrelieftsidetfilltexpandtbeforeRRR%(R+R'R(t text_frameRR t pack_infotcgettTkintertLabelttopt context_depthRRR)RR"RtpackRRR,tdestroyR*Rt SetOptiontSaveUserCfgFiles(R8teventtwidgetsR:twidgetR;((s+/usr/lib64/python2.7/idlelib/CodeContext.pyR07s0   # #      cCs|jjd|d|}t|\}}|tko>|}t|t|kso|t|dkrxt}n t|}|||fS(sGet 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. s%d.0s%d.endt#(R(tgettgetspacesfirstwordt BLOCKOPENERStlentINFINITY(R8tlinenumR(tspacest firstwordtopenertindent((s+/usr/lib64/python2.7/idlelib/CodeContext.pyt get_line_info[s.  iic Csg}t}xt||ddD]}|j|\}}} ||kr#|}| dkrl|d7}n| r||kr||kr|j|||| fn||krPqq#q#W|j||fS(sGet 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. iiR R (R R (RYtxrangeR_tappendtreverse( R8tnew_topvisibletstoplinet stopindenttlinest lastindentRZR^R(R]((s+/usr/lib64/python2.7/idlelib/CodeContext.pyt get_contextks      cCst|jjdjdd}|j|kr8dS|j|kr|j||j\}}x|jdd|kr|jd=qeWn|j|kr|jddd}x6|jdd|kr|jdd}|jd=qW|j||jddd|\}}n|jj|||_dgtd|j t |j}|g|j|j D]}|d^qk7}d j ||j d >N(t__name__t __module__tmenudefsRR/RLRR"R9R*R0R_RhRqR5R7(((s+/usr/lib64/python2.7/idlelib/CodeContext.pyRs     $  ((t__doc__RIt TkconstantsRRRRRtretsysRRYtidlelib.configHandlerRRWR4R6tcompileRVR(((s+/usr/lib64/python2.7/idlelib/CodeContext.pyt s (