ģō
\Kc           @   s`   d  d k  Z  d  d k l Z d d
 d     YZ d   Z d   Z d   Z d   Z d	   Z d S(   iĸĸĸĸN(   t   idleConft   FormatParagraphc           B   s5   e  Z d  d g f g Z d   Z d   Z d   Z RS(   t   formats   Format Paragraphs   <<format-paragraph>>c         C   s   | |  _  d  S(   N(   t   editwin(   t   selfR   (    (    s-   /usr/lib/python2.5/idlelib/FormatParagraph.pyt   __init__   s    c         C   s   d  |  _ d  S(   N(   t   NoneR   (   R   (    (    s-   /usr/lib/python2.5/idlelib/FormatParagraph.pyt   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         S   s   |  | S(    (    (   t   stt   l(    (    s-   /usr/lib/python2.5/idlelib/FormatParagraph.pyt   <lambda>/   s    i   iĸĸĸĸc         S   s   | |  S(    (    (   t   itemt   prefix(    (    s-   /usr/lib/python2.5/idlelib/FormatParagraph.pyR   ?   s    t   sels   1.0t   endt   break(   t   intR    t	   GetOptionR   t   textt   get_selection_indicest   gett   find_paragrapht   indext   splitt   mapt   lent   joint   maxt   reformat_paragrapht
   tag_removet   mark_sett   undo_block_startt   deleteR   t   undo_block_stopt   see(   R   t   eventt   maxformatwidthR   t   firstt   lastt   datat   comment_headert   linest   format_widtht   newdatat   block_suffixt   builder(    (    s-   /usr/lib/python2.5/idlelib/FormatParagraph.pyt   format_paragraph_event"   s>    
$ 
(   s   Format Paragraphs   <<format-paragraph>>(   t   __name__t
   __module__t   menudefsR   R   R2   (    (    (    s-   /usr/lib/python2.5/idlelib/FormatParagraph.pyR      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   R   R   t   comparet   is_all_whitet   get_comment_headerR   (
   R   t   markt   linenot   colt   linet   first_linenoR,   t   comment_header_lenR*   R)   (    (    s-   /usr/lib/python2.5/idlelib/FormatParagraph.pyR   P   s2     '
 


 
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   R9   t
   get_indentt   ret   ranget
   expandtabst   appendt   rstript   extendR   (   R+   t   limitR-   t   it   nt   indent1t   indent2t   newt   partialt   wordst   jt   word(    (    s-   /usr/lib/python2.5/idlelib/FormatParagraph.pyR    i   sB     '
  

,c         C   s   t  i d |   d  j	 S(   Ns   ^\s*$(   RC   t   matchR   (   R>   (    (    s-   /usr/lib/python2.5/idlelib/FormatParagraph.pyR9      s    c         C   s   t  i d |   i   S(   Ns   ^(\s*)(   RC   RS   t   group(   R>   (    (    s-   /usr/lib/python2.5/idlelib/FormatParagraph.pyRB      s    c         C   s4   t  i d |   } | d  j o d Sn | i d  S(   Ns   ^(\s*#*)R
   i   (   RC   RS   R   RT   (   R>   t   m(    (    s-   /usr/lib/python2.5/idlelib/FormatParagraph.pyR:      s     (    (	   RC   t   configHandlerR    R   R   R    R9   RB   R:   (    (    (    s-   /usr/lib/python2.5/idlelib/FormatParagraph.pys   <module>   s   <		#		