mò
­fIc           @   sZ   d  k  Z  d k l Z d f  d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z d „  Z d  S(	   N(   s   idleConft   FormatParagraphc           B   s5   t  Z d d g f g Z d „  Z d „  Z d „  Z RS(   Nt   formats   Format Paragraphs   <<format-paragraph>>c         C   s   | |  _  d  S(   N(   t   editwint   self(   R   R   (    (    t4   /mit/python/lib/python2.4/idlelib/FormatParagraph.pyt   __init__   s    c         C   s   d  |  _ d  S(   N(   t   NoneR   R   (   R   (    (    R   t   close   s    c         C   sê  t  t i d d d ƒ ƒ }	 |  i i } |  i i ƒ  \ } } | o# | o | i
 | | ƒ } d }
 n% t | | i d ƒ ƒ \ } } }
 } |
 oÁ | i d ƒ } t t |
 ƒ d „ | ƒ } d i | ƒ } t |	 t |
 ƒ d ƒ } t | | ƒ } | i d ƒ } d } | d	 p d } | d	  } n |
 d
 „ } d i t | | ƒ ƒ | } n t | |	 ƒ } | i d d d ƒ | | j oH | i d | ƒ | i ƒ  | i | | ƒ | i | | ƒ | i ƒ  n | i d | ƒ | i  d ƒ d  S(   Nt   mainR    t	   paragrapht    t   inserts   
c         C   s   |  | S(   N(   t   stt   l(   R   R   (    (    R   t   <lambda>/   s    i   iÿÿÿÿc         C   s   | |  S(   N(   t   prefixt   item(   R   R   (    (    R   R   ?   s    t   sels   1.0t   end(!   t   intt   idleConft	   GetOptiont   maxformatwidthR   R   t   textt   get_selection_indicest   firstt   lastt   gett   datat   comment_headert   find_paragrapht   indext   splitt   linest   mapt   lent   joint   maxt   format_widtht   reformat_paragrapht   newdatat   block_suffixt   buildert
   tag_removet   mark_sett   undo_block_startt   deleteR   t   undo_block_stopt   see(   R   t   eventR   R&   R*   R   R)   R!   R(   R   R   R   R   (    (    R   t   format_paragraph_event"   s<    
$ 
(   s   Format Paragraphs   <<format-paragraph>>(   t   __name__t
   __module__t   menudefsR   R   R2   (    (    (    R   R       s   		c   
      C   s°  t  t | i d ƒ ƒ \ } } |  i d | d | ƒ } xP |  i	 d | d d ƒ o5 t
 | ƒ o( | d } |  i d | d | ƒ } q; W| } t | ƒ } t | ƒ }	 xN t | ƒ | j o: t
 | |	 ƒ o( | d } |  i d | d | ƒ } q¬ Wd | } | d } |  i d | d | ƒ } x[ | d j oM t | ƒ | j o: t
 | |	 ƒ o( | d } |  i d | d | ƒ } q+Wd | d } | | | |  i | | ƒ f S(   Nt   .s   %d.0s   %d.0 lineendt   <R   i   i    (   R"   R   t   markR    t   linenot   colR   R   t   linet   comparet   is_all_whitet   first_linenot   get_comment_headerR   R#   t   comment_header_lenR   R   (
   R   R8   R   R>   R   R9   R;   R   R:   R@   (    (    R   R   O   s,     '
 %


 2
c         C   s  |  i d ƒ } d } t | ƒ } x- | | j  o t | | ƒ o | d } q$ W| | j o |  Sn t | | ƒ } | d | j  o. t | | d ƒ o t | | d ƒ }	 n | }	 | |  } | } x| | j  o t | | ƒ oî t i d | | ƒ }
 xÇ t d t |
 ƒ d ƒ D]­ } |
 | } | p qn t | | i ƒ  ƒ | j o* | | j o | i | i ƒ  ƒ |	 } n | | d } | d t |
 ƒ j  o# |
 | d d j o | d } qqW| d } qÎ W| i | i ƒ  ƒ | i | | ƒ d i | ƒ S(   Ns   
i    i   s   (\s+)i   t    (   R   R    R!   t   iR#   t   nR=   t
   get_indentt   indent1t   indent2t   newt   partialt   ret   wordst   ranget   jt   wordt
   expandtabst   limitt   appendt   rstript   extendR$   (   R   RO   RH   RB   RM   RL   R!   RC   RE   RF   RJ   RG   (    (    R   R'   h   s@     '
  
*
,c         C   s   t  i d |  ƒ d  j	 S(   Ns   ^\s*$(   RI   t   matchR;   R   (   R;   (    (    R   R=   ‹   s    c         C   s   t  i d |  ƒ i ƒ  S(   Ns   ^(\s*)(   RI   RS   R;   t   group(   R;   (    (    R   RD   Ž   s    c         C   s4   t  i d |  ƒ } | d  j o d Sn | i d ƒ S(   Ns   ^(\s*#*)R
   i   (   RI   RS   R;   t   mR   RT   (   R;   RU   (    (    R   R?   ‘   s     (	   RI   t   configHandlerR   R    R   R'   R=   RD   R?   (   R   RD   R?   R'   R   RI   R    R=   (    (    R   t   ?   s   	;		#		