python (3.11.7)
    eS                         d Z ddlZddlmZ ddlmZ g dZdad Zd Z	 G d d	e          Z
 G d
 d          Zedk    rdd
l
mZ  eddd           dS dS )z0Editor window that can serve as an output file.
    N)
messagebox)EditorWindow)zfile "([^"]*)", line (\d+)z([^\s]+)\((\d+)\)z^(\s*\S.*?):\s*(\d+):z([^\s]+):\s*(\d+):z^\s*(\S.*?):\s*(\d+):c                  (    d t           D             adS )z?Compile the patterns for matching to file name and line number.c                 L    g | ]!}t          j        |t           j                  "S  )recompile
IGNORECASE).0pats     B/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/idlelib/outwin.py
<listcomp>z!compile_progs.<locals>.<listcomp>   s6     2 2 2 z#r}55 2 2 2    N)file_line_patsfile_line_progsr   r   r
   
compile_progsr      s$    2 2"02 2 2OOOr   c                 V   t           st                       t           D ]h}|                    |           }|rO|                    dd          \  }}	 t	          |          }|                                  n# t          $ r Y dw xY widS 	 |t          |          fS # t          $ r Y dS w xY w)a-  Extract file name and line number from line of text.
    Check if line of text contains one of the file/line patterns.
    If it does and if the file and line are valid, return
    a tuple of the file name and line number.  If it doesn't match
    or if the file or line is invalid, return None.
          N)	r   r   searchgroupopencloseOSErrorint	TypeError)lineprogmatchfilenamelinenofs         r
   file_line_helperr#      s        D!! 	${{1a00Hf
NN			 
 
 
	 tV$$   tts$   #A55
BB	B 
B('B(c                   X    e Zd ZdZg dZdZd Zd Zd Zd Z	dd
Z
d Zd Zd
 Z
ddZdS )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.
    Adds binding to open a file at a line to the text widget.
    ))Cutz<<cut>>rmenu_check_cut)Copyz<<copy>>rmenu_check_copy)Pastez	<<paste>>rmenu_check_paste)NNN)zGo to file/line<<goto-file-line>>NFc                 j    t          j        | g|R   | j                            d| j                   d S )Nr,   )r   __init__textbindgoto_file_line)selfargss     r
   r.   zOutputWindow.__init__N   s;    d*T****	+T-@AAAAAr   c                     dS )z6Python source is only part of output: do not colorize.Fr   )r2   r    s     r
   ispythonsourcezOutputWindow.ispythonsourceS   s    ur   c                     dS )zCustomize EditorWindow title.Outputr   r2   s    r
   short_titlezOutputWindow.short_titleW   s    xr   c                 2    |                                  rdndS )z;Customize EditorWindow to not display save file messagebox.yesno)	get_savedr8   s    r
   	maybesavezOutputWindow.maybesave[   s    ((2uud2r   r   insertc                     t          |t                    sJ | j                            |||           | j                            |           | j                                         t
          |          S )a  Write text to text widget.
        The text is inserted at the given index with the provided
        tags.  The text widget is then scrolled to make it visible
        and updated to display it, giving the effect of seeing each
        line as it is added.
        Args:
            s: Text to insert into text widget.
            tags: Tuple of tag strings to apply on the insert.
            mark: Index for the insert.
        Return:
            Length of text inserted.
        )
isinstancestrr/   r?   seeupdate_idletaskslenr2   stagsmarks       r
   writezOutputWindow.write`   sg      !S!!!!!	q$'''	
d	""$$$1vv
r   c                 :    |D ]}|                      |           dS )z"Write each item in lines iterable.N)rJ   )r2   linesr   s      r
   
writelineszOutputWindow.writelinesv   s0     	 	DJJt	 	r   c                     dS )z8No flushing needed as write() directly writes to widget.Nr   r8   s    r
   flushzOutputWindow.flush{   s    r   c                 (    t          j        |i | d S N)r   	showerror)r2   r3   kwargss      r
   rR   zOutputWindow.showerror   s    d-f-----r   Nc                 4   | j                             dd          }t          |          }|sK| j                             dd          }t          |          }|s|                     dd| j                    dS |\  }}| j                            ||           dS )	a  Handle request to open file/line.
        If the selected or previous line in the output window
        contains a file name and line number, then open that file
        name in a new window and position on the line number.
        Otherwise, display an error messagebox.
        zinsert linestartzinsert lineendzinsert -1line linestartzinsert -1line lineendzNo special linezTThe line you point at doesn't look like a valid file name followed by a line number.)parentN)r/   getr#   rR   flistgotofileline)r2   eventr   resultr    r!   s         r
   r1   zOutputWindow.goto_file_line   s     y}}/1ABB!$'' 	 9==!:!8: :D%d++F 
%C9	  &