ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python37/lib64/python3.7/idlelib/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python37/lib64/python3.7/idlelib/__pycache__/outwin.cpython-37.pyc

B

� f��@s�dZddlZddlmZddlmZddlmZdddd	d
gZda	dd�Z
d
d�ZGdd�de�ZGdd�d�Z
edkr�ddlmZedddd�dS)z0Editor window that can serve as an output file.
�N)�
messagebox)�EditorWindow)�iomenuzfile "([^"]*)", line (\d+)z([^\s]+)\((\d+)\)z^(\s*\S.*?):\s*(\d+):z([^\s]+):\s*(\d+):z^\s*(\S.*?):\s*(\d+):cCsdd�tD�adS)z?Compile the patterns for matching to file name and line number.cSsg|]}t�|tj��qS�)�re�compile�
IGNORECASE)�.0Zpatrr�3/opt/alt/python37/lib64/python3.7/idlelib/outwin.py�
<listcomp>sz!compile_progs.<locals>.<listcomp>N)�file_line_pats�file_line_progsrrrr
�
compile_progssrc	Cs�ts
t�x^tD]R}|�|�}|r|�dd�\}}yt|d�}|��PWqtk
r`wYqXqWdSy|t|�fStk
r�dSXdS)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.
    ���rN)	r
r�search�group�open�close�OSError�int�	TypeError)�line�prog�match�filename�lineno�frrr
�file_line_helpers"


rc@sneZdZdZdddddgZdZdd	�Zd
d�Zdd
�Zdd�Z	ddd�Z
dd�Zdd�Zdd�Z
ddd�ZdS)�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.
    )ZCutz<<cut>>Zrmenu_check_cut)ZCopyz<<copy>>Zrmenu_check_copy)ZPastez	<<paste>>Zrmenu_check_paste)NNN)zGo to file/linez<<goto-file-line>>NFcGs$tj|f|��|j�d|j�dS)Nz<<goto-file-line>>)r�__init__�textZbind�goto_file_line)�self�argsrrr
r!OszOutputWindow.__init__cCsdS)z6Python source is only part of output: do not colorize.Fr)r$rrrr
�ispythonsourceTszOutputWindow.ispythonsourcecCsdS)zCustomize EditorWindow title.ZOutputr)r$rrr
�short_titleXszOutputWindow.short_titlecCs|��rdSdS)z;Customize EditorWindow to not display save file messagebox.ZyesZno)Z	get_saved)r$rrr
�	maybesave\szOutputWindow.maybesaver�insertcCsFt|t�r|�tjd�}|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.
        �replace)
�
isinstance�bytes�decoder�encodingr"r)Zsee�update�len)r$�s�tags�markrrr
�writeas

zOutputWindow.writecCsx|D]}|�|�qWdS)z"Write each item in lines iterable.N)r4)r$�linesrrrr
�
writelinesxs
zOutputWindow.writelinescCsdS)z8No flushing needed as write() directly writes to widget.Nr)r$rrr
�flush}szOutputWindow.flushcOstj||�dS)N)r�	showerror)r$r%�kwargsrrr
r8�szOutputWindow.showerrorNcCsd|j�dd�}t|�}|sJ|j�dd�}t|�}|sJ|jdd|jd�dS|\}}|j�||�dS)	aHandle 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"�getrr8�flistZgotofileline)r$Zeventr�resultrrrrr
r#�s	
zOutputWindow.goto_file_line)rr))N)�__name__�
__module__�__qualname__�__doc__Zrmenu_specsZallow_code_contextr!r&r'r(r4r6r7r8r#rrrr
r ;s 
r c@s6eZdZddiddid�Zdd�Zdd�Zd	d
�ZdS)�OnDemandOutputWindowZ
foregroundZbluez#007700)�stdout�stderrcCs||_d|_dS)N)r<�owin)r$r<rrr
r!�szOnDemandOutputWindow.__init__cCs"|js|��|j�|||�dS)N)rE�setupr4)r$r1r2r3rrr
r4�szOnDemandOutputWindow.writecCsXt|j�|_}|j}x(|j��D]\}}|r"|j|f|�q"W|�d�|jj|_dS)NZsel)	r r<rEr"�tagdefs�itemsZ
tag_configureZ	tag_raiser4)r$rEr"�tagZcnfrrr
rF�s
zOnDemandOutputWindow.setupN)r>r?r@rGr!r4rFrrrr
rB�s
rB�__main__)�mainzidlelib.idle_test.test_outwinrF)�	verbosity�exit)rArZtkinterrZidlelib.editorrZidlelibrrr
rrr rBr>ZunittestrKrrrr
�<module>s"f

Zerion Mini Shell 1.0