©’f” c @ sĪ d Z d d l Z d d l m Z m Z m Z m Z m Z d d l Z d d l m
Z d d l m
Z
e d d d d d
d d d
d d d g Z d Z d Z e j d d d Z Gd d d Z d S( uI CodeContext - 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.
i N( u TOPu LEFTu Xu Wu SUNKEN( u maxsize( u idleConfu classu defu elifu elseu exceptu finallyu foru ifu tryu whileu withid ič u ^(\s*)(\w*)c C s | j | j S( N( u matchu groups( u su c( ( u8 /opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu s u c B sę | Ee Z d Z d d g f g Z e j d d d d d d d Z e j d d d
d d d d Z e j d d d
d d d d Z d d Z d d d Z d d Z d d d d Z
d d Z d d Z d d Z d S(! u CodeContextu optionsu !Code Conte_xtu <>u
extensionsu numlinesu typeu intu defaulti u bgcoloru stru LightGrayu fgcoloru Blackc C sŗ | | _ | j | _ | j d | _ d | _ d g | _ d | _ t j d d d d d d
d
} | r | j
| j j d d n | j j
t | j | j j
t | j d S( Nu fonti i u u
extensionsu CodeContextu visibleu typeu boolu defaultu <>i’’’’F( i i’’’’u FT( u editwinu textu textfontu Noneu labelu Falseu infou
topvisibleu idleConfu GetOptionu toggle_code_context_eventu setvaru Trueu afteru UPDATEINTERVALu timer_eventu FONTUPDATEINTERVALu font_timer_event( u selfu editwinu visible( ( u8 /opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu __init__" s
u CodeContext.__init__c C s | j sC| j j | j j f } d } xM | D]E } | t t | j d 7} | t t | j d 7} q. Wd } x- | D]% } | t t | j d 7} q Wt j | j j
d d | j d d t d t
d | j d
| j d | j d d d | d | d
t
| _ | j j d t d t d d d | j j n | j j d | _ t j d d d t | j d k t j d S( Ni u padxu borderu textu
i u anchoru justifyu fontu bgu fgu widthu reliefu sideu fillu expandu beforeu
extensionsu CodeContextu visibleF( u labelu editwinu textu
text_frameu intu stru pack_infou cgetu tkinteru Labelu topu
context_depthu Wu LEFTu textfontu bgcoloru fgcoloru SUNKENu packu TOPu Xu Falseu destroyu Noneu idleConfu SetOptionu SaveUserCfgFiles( u selfu eventu widgetsu padxu widgetu border( ( u8 /opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu toggle_code_context_event7 s0
#
#
u% CodeContext.toggle_code_context_eventc C s | j j d | d | } t | \ } } | t k o> | } t | t | k so | t | d k rx t } n t | } | | | f S( 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 #( u textu getu getspacesfirstwordu BLOCKOPENERSu lenu INFINITY( u selfu linenumu textu spacesu firstwordu openeru indent( ( u8 /opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu
get_line_info[ s . u CodeContext.get_line_infoi i c
C sŃ g } t } x® t | | d d D] } | j | \ } } } | | k r# | } | d k rl | d 7} n | r¦ | | k r¦ | | k r¦ | j | | | | f n | | k r¹ Pq¹ q# q# W| j | | f S( 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.
i u elseu elifi’’’’( u elseu elif( u INFINITYu rangeu
get_line_infou appendu reverse(
u selfu new_topvisibleu stoplineu
stopindentu linesu
lastindentu linenumu indentu textu opener( ( u8 /opt/alt/python33/lib64/python3.3/idlelib/CodeContext.pyu get_contextk s
u CodeContext.get_contextc C s t | j j d j d d } | j | k r8 d S| j | k r | j | | j \ } } x² | j d d | k r | j d =qe Wn | j | k r| j d
d d } x6 | j d d | k ré | j d d } | j d =q“ W| j | | j d d d | \ } } n | j j | | | _ d g t d | j t
| j } | d d | j | j d
D 7} d j | | j d