
\[\*                 @   sr   d  d l  Td  d l m Z d  d l Z d  d l j Z d  d l m Z Gd d   d e  Z	 Gd d   d  Z
 d S)	    )*)EditorWindowN)	IOBindingc               @   s   e  Z d  Z d Z d d   Z d d   Z d d   Z d d	   Z f  d
 d d  Z d d   Z	 d d   Z
 d& d' d( d) d* g Z d d d d  d! g Z d Z d d" d#  Z d$ d%   Z d S)+OutputWindowzAn editor window that can serve as an output file.

    Also the future base class for the Python shell window.
    This class has no input facilities.
    c             G   s*   t  j |  |  |  j j d |  j  d  S)Nz<<goto-file-line>>)r   __init__textZbindgoto_file_line)selfargs r   */usr/lib/python3.4/idlelib/OutputWindow.pyr      s    zOutputWindow.__init__c             C   s   d S)Nr   r   )r	   filenamer   r   r   ispythonsource   s    zOutputWindow.ispythonsourcec             C   s   d S)NZOutputr   )r	   r   r   r   short_title   s    zOutputWindow.short_titlec             C   s   |  j    r d Sd Sd  S)NZyesZno)Z	get_saved)r	   r   r   r   	maybesave   s    zOutputWindow.maybesaveinsertc             C   sj   t  | t t f  r- | j t j d  } n  |  j j | | |  |  j j |  |  j j   t	 |  S)Nreplace)

isinstancebytesdecoder   encodingr   r   Zseeupdatelen)r	   stagsmarkr   r   r   write%   s    zOutputWindow.writec             C   s"   x | D] } |  j  |  q Wd  S)N)r   )r	   linesliner   r   r   
writelines-   s    zOutputWindow.writelinesc             C   s   d  S)Nr   )r	   r   r   r   flush1   s    zOutputWindow.flushCut<<cut>>rmenu_check_cutCopy<<copy>>rmenu_check_copyPaste	<<paste>>rmenu_check_pasteNGo to file/line<<goto-file-line>>zfile "([^"]*)", line (\d+)z([^\s]+)\((\d+)\)z^(\s*\S.*?):\s*(\d+):z([^\s]+):\s*(\d+):z^\s*(\S.*?):\s*(\d+):c       	      C   s   |  j  d  k rQ g  } x- |  j D]" } | j t j | t j   q W| |  _  n  |  j j d d  } |  j |  } | s |  j j d d  } |  j |  } | s t	 j
 d d d |  j d  Sn  | \ } } |  j j |  } | j |  d  S)Nzinsert linestartzinsert lineendzinsert -1line linestartzinsert -1line lineendzNo special linezTThe line you point at doesn't look like a valid file name followed by a line number.Zmaster)file_line_progsfile_line_patsappendrecompile
IGNORECASEr   get_file_line_helpertkMessageBoxZ	showerrorflistopenZgotoline)	r	   ZeventlZpatr   resultr   linenoZeditr   r   r   r   I   s(     	
zOutputWindow.goto_file_linec             C   s   x{ |  j  D]l } | j |  } | r
 | j d d  \ } } y t | d  } | j   PWqv t k
 rr w
 Yqv Xq
 q
 Wd  Sy | t |  f SWn t k
 r d  SYn Xd  S)N      r)r,   searchgroupr6   closeOSErrorint	TypeError)r	   r   progmatchr   r9   fr   r   r   r3   d   s    
zOutputWindow._file_line_helper)r!   r"   r#   )r$   r%   r&   )r'   r(   r)   )NNN)r*   r+   N)__name__
__module____qualname____doc__r   r   r   r   r   r   r    Zrmenu_specsr-   r,   r   r3   r   r   r   r   r      s*   			r   c               @   sV   e  Z d  Z i i d d 6d 6i d d 6d 6Z d d   Z d d	   Z d
 d   Z d S)OnDemandOutputWindowZblueZ
foregroundstdoutz#007700stderrc             C   s   | |  _  d  |  _ d  S)N)r5   owin)r	   r5   r   r   r   r      s    	zOnDemandOutputWindow.__init__c             C   s0   |  j  s |  j   n  |  j  j | | |  d  S)N)rM   setupr   )r	   r   r   r   r   r   r   r      s    	zOnDemandOutputWindow.writec             C   sx   t  |  j  |  _ } | j } x6 |  j j   D]% \ } } | r/ | j | |  q/ q/ W| j d  |  j j |  _ d  S)NZsel)	r   r5   rM   r   tagdefsitemsZtag_configureZ	tag_raiser   )r	   rM   r   tagZcnfr   r   r   rN      s    	zOnDemandOutputWindow.setupN)rF   rG   rH   rO   r   r   rN   r   r   r   r   rJ   x   s   rJ   )ZtkinterZidlelib.EditorWindowr   r/   Ztkinter.messageboxZ
messageboxr4   Zidlelibr   r   rJ   r   r   r   r   <module>   s   
q