Ë
    #´˜jI  ã                   ó˜   — d Z ddlZddlmZ ddlmZ g d¢Zdad„ Zd„ Z	 G d„ d	e«      Z
 G d
„ d«      Zedk(  rddlmZ  eddd¬«       yy)z0Editor window that can serve as an output file.
é    N)Ú
messagebox)ÚEditorWindow)zfile "([^"]*)", line (\d+)z([^\s]+)\((\d+)\)z^(\s*\S.*?):\s*(\d+):z([^\s]+):\s*(\d+):z^\s*(\S.*?):\s*(\d+):c                  óz   — t         D � cg c]&  } t        j                  | t        j                  «      ‘Œ( c} ayc c} w )z?Compile the patterns for matching to file name and line number.N)Úfile_line_patsÚreÚcompileÚ
IGNORECASEÚfile_line_progs)Úpats    ú lib/python3.12/idlelib/outwin.pyÚcompile_progsr      s5   € õ #1ó2Ù"0˜3ô —z‘z #¤r§}¡}Õ5Ø"0ñ2�Oùò 2s   ‰+8c                 ó  — t         s
t        «        t         D ]H  }|j                  | «      }|sŒ|j                  dd«      \  }}	 t	        |«      }|j                  «         n y	 |t        |«      fS # t        $ r Y Œew xY w# t        $ r Y yw xY 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   ÚsearchÚgroupÚopenÚcloseÚOSErrorÚintÚ	TypeError)ÚlineÚprogÚmatchÚfilenameÚlinenoÚfs         r   Úfile_line_helperr      s–   € õ ÜŒßˆØ—‘˜DÓ!ˆÚØ$Ÿ{™{¨1¨aÓ0ÑˆH�fðÜ˜“N�Ø—‘”	Ùð  ð ðØœ˜V›Ð$Ð$øô ò Ùðûô ò Ùðús$   ÁA1Á$B  Á1	A=Á<A=Â 	BÂBc                   óV   — e Zd ZdZg d¢ZdZd„ Zd„ Zd„ Zd„ Z	dd„Z
d	„ Zd
„ Zd„ Zdd„Zy)ÚOutputWindowzÛAn 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)zGo to file/lineú<<goto-file-line>>NFc                 ó|   — t        j                  | g|¢­Ž  | j                  j                  d| j                  «       y )Nr'   )r   Ú__init__ÚtextÚbindÚgoto_file_line)ÚselfÚargss     r   r)   zOutputWindow.__init__N   s.   € Ü×Ñ˜dÐ* TÓ*Ø�	‰	�‰Ð+¨T×-@Ñ-@ÕAó    c                  ó   — y)z6Python source is only part of output: do not colorize.F© )r-   r   s     r   ÚispythonsourcezOutputWindow.ispythonsourceS   s   € àr/   c                  ó   — y)zCustomize EditorWindow title.ÚOutputr1   ©r-   s    r   Úshort_titlezOutputWindow.short_titleW   s   € àr/   c                 ó*   — | j                  «       rdS dS )z;Customize EditorWindow to not display save file messagebox.ÚyesÚno)Ú	get_savedr5   s    r   Ú	maybesavezOutputWindow.maybesave[   s   € àŸ™Ô(ˆuÐ2¨dÐ2r/   c                 óà   — t        |t        «      sJ ‚| j                  j                  |||«       | j                  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.
        )Ú
isinstanceÚstrr*   ÚinsertÚseeÚupdateÚlen©r-   ÚsÚtagsÚmarks       r   ÚwritezOutputWindow.write`   sS   € ô  ˜!œSÔ!Ð!Ð!Ø�	‰	×Ñ˜˜q $Ô'Ø�	‰	�‰�dÔØ�	‰	×ÑÔÜ�1‹vˆr/   c                 ó4   — |D ]  }| j                  |«       Œ y)z"Write each item in lines iterable.N)rG   )r-   Úlinesr   s      r   Ú
writelineszOutputWindow.writelinesv   s   € ãˆDØ�J‰J�tÕñ r/   c                  ó   — y)z8No flushing needed as write() directly writes to widget.Nr1   r5   s    r   ÚflushzOutputWindow.flush{   s   € àr/   c                 ó.   — t        j                  |i |¤Ž y ©N)r   Ú	showerror)r-   r.   Úkwargss      r   rO   zOutputWindow.showerror   s   € Ü×Ñ˜dÐ- fÓ-r/   Nc                 ó(  — | j                   j                  dd«      }t        |«      }|sH| j                   j                  dd«      }t        |«      }|s| j                  dd| j                   ¬«       y|\  }}| j                  j                  ||«       y)	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.
        z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.)ÚparentN)r*   Úgetr   rO   ÚflistÚgotofileline)r-   Úeventr   Úresultr   r   s         r   r,   zOutputWindow.goto_file_line‚   s’   € ð �y‰y�}‰}Ð/Ð1AÓBˆÜ! $Ó'ˆÙð —9‘9—=‘=Ð!:Ø!8ó:ˆDä% dÓ+ˆFÙØ—‘Ø%ðCàŸ9™9ð	 ô &ð
 Ø!Ñˆ�&Ø�
‰
×Ñ ¨&Õ1r/   )r1   r?   rN   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úrmenu_specsÚallow_code_contextr)   r2   r6   r;   rG   rJ   rL   rO   r,   r1   r/   r   r    r    :   sD   „ ñò€Kð ÐòBò
òò3ó
ò,ò
ò.ô2r/   r    c                   ó0   — e Zd ZddiddidœZd„ Zd„ Zd„ Zy)	ÚOnDemandOutputWindowÚ
foregroundÚbluez#007700)ÚstdoutÚstderrc                 ó    — || _         d | _        y rN   )rT   Úowin)r-   rT   s     r   r)   zOnDemandOutputWindow.__init__§   s   € ØˆŒ
Øˆ�	r/   c                 óv   — | j                   s| j                  «        | j                   j                  |||«       y rN   )re   ÚsetuprG   rC   s       r   rG   zOnDemandOutputWindow.write«   s&   € Ø�yŠyØ�J‰JŒLØ�	‰	�‰˜˜4 Õ&r/   c                 ó  — t        | j                  «      x| _        }|j                  }| j                  j                  «       D ]  \  }}|sŒ	 |j                  |fi |¤Ž Œ |j                  d«       | j                  j                  | _        y )NÚsel)	r    rT   re   r*   ÚtagdefsÚitemsÚtag_configureÚ	tag_raiserG   )r-   re   r*   ÚtagÚcnfs        r   rg   zOnDemandOutputWindow.setup°   sp   € Ü'¨¯
©
Ó3Ð3ˆŒ	�DØ�y‰yˆØŸ™×*Ñ*Ö,‰HˆC�ÚØ"�×"Ñ" 3Ñ.¨#Ó.ð -ð 	�‰�uÔØ—Y‘Y—_‘_ˆ�
r/   N)rX   rY   rZ   rj   r)   rG   rg   r1   r/   r   r_   r_   Ÿ   s*   „ ð ! &Ð)Ø  )Ð,ñ€Gòò'ó
%r/   r_   Ú__main__)Úmainzidlelib.idle_test.test_outwinr   F)Ú	verbosityÚexit)r[   r   Útkinterr   Úidlelib.editorr   r   r
   r   r   r    r_   rX   Úunittestrq   r1   r/   r   Ú<module>rw      se   ðñó 
å å 'ò€ð €ò2òô8a2�<ô a2÷J%ñ %ð6 ˆzÒÝÙÐ	(°A¸EÖBð r/   