ó
|Nc           @   s`   d  d l  Z  d  d l m 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,   C:\RCS\Python\lib\idlelib\FormatParagraph.pyt   __init__   s    c         C   s   d  |  _ d  S(   N(   t   NoneR   (   R   (    (    s,   C:\RCS\Python\lib\idlelib\FormatParagraph.pyt   close   s    c         C   sá  t  t j d d d ƒ ƒ } |  j j } |  j j ƒ  \ } } | rc | rc | j | | ƒ } d } n$ t | | j d ƒ ƒ \ } } } } | rK| j	 d ƒ } t
 t | ƒ d „ | ƒ } d j | ƒ } t | t | ƒ d ƒ }	 t | |	 ƒ }
 |
 j	 d ƒ }
 d } |
 d	 s d } |
 d	  }
 n  | d
 „ } d j t
 | |
 ƒ ƒ | }
 n t | | ƒ }
 | j d d d ƒ |
 | k rÀ| j d | ƒ | j ƒ  | j | | ƒ | j | |
 ƒ | j ƒ  n | j d | ƒ | j d ƒ d S(   Nt   mainR   t	   paragrapht    t   inserts   
c         S   s   |  | S(   N(    (   t   stt   l(    (    s,   C:\RCS\Python\lib\idlelib\FormatParagraph.pyt   <lambda>/   s    i   iÿÿÿÿc         S   s   | |  S(   N(    (   t   itemt   prefix(    (    s,   C:\RCS\Python\lib\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,   C:\RCS\Python\lib\idlelib\FormatParagraph.pyt   format_paragraph_event"   s>    	$

(   s   Format Paragraphs   <<format-paragraph>>(   t   __name__t
   __module__t   menudefsR   R   R2   (    (    (    s,   C:\RCS\Python\lib\idlelib\FormatParagraph.pyR      s
   		c   
   
   C   s¦  t  t | j d ƒ ƒ \ } } |  j d | d | ƒ } xM |  j d | d d ƒ r‡ t | ƒ r‡ | d } |  j d | d | ƒ } q; W| } t | ƒ } t | ƒ } xK t | ƒ | k ró t | | ƒ ró | d } |  j d | d | ƒ } q© Wd | } | d } |  j d | d | ƒ } xW | d k r{t | ƒ | k r{t | | ƒ r{| d } |  j d | d | ƒ } q%Wd | d }	 |	 | | |  j |	 | ƒ 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,   C:\RCS\Python\lib\idlelib\FormatParagraph.pyR   P   s,    (




c      	   C   s÷  |  j  d ƒ } d } t | ƒ } x* | | k  rM t | | ƒ rM | d } q$ W| | k r^ |  St | | ƒ } | d | k  rª t | | d ƒ rª t | | d ƒ } n | } | |  } | } x| | k  rÅt | | ƒ rÅt j  d | | ƒ }	 x¿ t d t |	 ƒ d ƒ D]¥ }
 |	 |
 } | s+qn  t | | j ƒ  ƒ | k ro| | k ro| j | j ƒ  ƒ | } n  | | d } |
 d t |	 ƒ k  r|	 |
 d d k r| d } qqW| d } qÃ W| j | j ƒ  ƒ | j	 | | ƒ d j
 | ƒ 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,   C:\RCS\Python\lib\idlelib\FormatParagraph.pyR    i   s<    %
 
	*c         C   s   t  j d |  ƒ d  k	 S(   Ns   ^\s*$(   RC   t   matchR   (   R>   (    (    s,   C:\RCS\Python\lib\idlelib\FormatParagraph.pyR9   Œ   s    c         C   s   t  j d |  ƒ j ƒ  S(   Ns   ^(\s*)(   RC   RS   t   group(   R>   (    (    s,   C:\RCS\Python\lib\idlelib\FormatParagraph.pyRB      s    c         C   s/   t  j d |  ƒ } | d  k r" d S| j d ƒ S(   Ns   ^(\s*#*)R
   i   (   RC   RS   R   RT   (   R>   t   m(    (    s,   C:\RCS\Python\lib\idlelib\FormatParagraph.pyR:   ’   s     (    (	   RC   t   idlelib.configHandlerR    R   R   R    R9   RB   R:   (    (    (    s,   C:\RCS\Python\lib\idlelib\FormatParagraph.pyt   <module>   s   <		#		