
    G@d                         d Z ddlZddlmZmZ ddlmZ ddlmZm	Z	 ddl
mZmZ ddlmZ ddlmZ dd	lmZmZ dd
lmZmZ  ej        e          Z G d de	          ZdS )z
Internal Console Plugin.
    N)SignalSlotQIcon)PluginsSpyderDockablePlugin)on_plugin_availableon_plugin_teardown_)DEV)ConsoleWidgetConsoleWidgetActions)ApplicationMenusFileMenuSectionsc                      e Zd ZdZdZeZej        gZ	eZ
dZej        ej        gZdZdZ e            Z eeee          Z	  e            Z	  ee          Z	 ed             Zd Zd Zd Z eej        	          d
             Z e ej        	          d             Z!d Z"ddZ#d Z$ e%            d             Z&e'd             Z(d Z)d Z*d Z+d Z, e%e          dd            Z-d Z.d Z/d Z0d Z1d Z2d Z3dS )Consolez
    Console widget
    internal_consoleFTc                       t          d          S )NzInternal consoler        =lib/python3.11/site-packages/spyder/plugins/console/plugin.pyget_namezConsole.get_nameP   s    #$$$r   c                     t                      S Nr   selfs    r   get_iconzConsole.get_iconT   s    wwr   c                      t          d          S )Nz Internal console running Spyder.r   r   s    r   get_descriptionzConsole.get_descriptionW   s    3444r   c           	         |                                  }|j                            | j                   |j                            | j                   |j                            | j                   |j                            | j                   |                     ddd          }|rEt          |ddt          d          t          d          	          }|	                    |           d S d S )
Nprevious_crash main)defaultsectionTzSegmentation fault crashz+<h3>Spyder crashed during last session</h3>zIPlease provide any additional information you might have about the crash.)textis_tracebacktitlelabelsteps)

get_widgetsig_edit_goto_requestedconnectsig_focus_changedsig_refreshedsig_help_requestedget_confdictr   handle_exception)r   widgetr"   
error_datas       r   on_initializezConsole.on_initializeZ   s	   "" 	&..t/KLLL (()?@@@$$T%7888!))$*ABBB  ' 
 
  		0#!0EFF 6 7 7  J ##J/////		0 		0r   )pluginc                     |                                  }|                     t          j                  }|                    |j        t          j        t          j	                   d S )N)menu_idr&   )
r,   
get_pluginr   MainMenuadd_item_to_application_menuquit_actionr   Filer   Restart)r   r5   mainmenus      r   on_main_menu_availablezConsole.on_main_menu_availableu   s`    ""??7#344 	--$)$, 	. 	. 	. 	. 	. 	.r   c                     |                      t          j                  }|                    t          j        t          j                   d S )N)r:   )r;   r   r<   !remove_item_from_application_menur   Quitr   r?   )r   rA   s     r   on_main_menu_teardownzConsole.on_main_menu_teardown   sI    ??7#34422 %$) 	3 	+ 	+ 	+ 	+ 	+r   c                 |    |                                  }|                                                     |           d S r   )get_fontr,   set_font)r   fonts     r   update_fontzConsole.update_font   s3    }}""4(((((r   c                 \    |                                  j                                         dS )NT)r,   dialog_manager	close_all)r   
cancelables     r   on_closezConsole.on_close   s&    (22444tr   c                     |                      | j        j                   t          5| j                            d           | j                                         d S d S )NF)set_exit_functionr$   closingr   toggle_view_action
setChecked
dockwidgethider   s    r   on_mainwindow_visiblezConsole.on_mainwindow_visible   sZ    ty0111 ;#..u555O  """"" ;r   c                 R    |                                                                   dS )z+Report an issue with the SpyderErrorDialog.N)r,   report_issuer   s    r   rZ   zConsole.report_issue   s&     	&&(((((r   c                 4    |                                  j        S )z1
        Error dialog attribute accesor.
        )r,   	error_dlgr   s    r   error_dialogzConsole.error_dialog   s    
   **r   c                 R    |                                                                   dS )z4
        Close the error dialog if visible.
        N)r,   close_error_dlgr   s    r   close_error_dialogzConsole.close_error_dialog   s&     	))+++++r   c                 R    |                                                                   dS )z
        Exit the internal console interpreter.

        This is equivalent to requesting the main application to quit.
        N)r,   exit_interpreterr   s    r   rb   zConsole.exit_interpreter   s&     	**,,,,,r   c                 T    |                                                      |           dS )zL
        Execute the given `lines` of code in the internal console.
        N)r,   execute_lines)r   liness     r   rd   zConsole.execute_lines   s(     	''.....r   c                 N    |                                                                  S )zA
        Return the system path of the internal console.
        )r,   get_sys_pathr   s    r   rg   zConsole.get_sys_path   s        --///r   Nc                     ||                                  }|                                                     ||           dS )a)  
        Handle any exception that occurs during Spyder usage.

        Parameters
        ----------
        error_data: dict
            The dictionary containing error data. The expected keys are:
            >>> error_data= {
                "text": str,
                "is_traceback": bool,
                "repo": str,
                "title": str,
                "label": str,
                "steps": str,
            }

        Notes
        -----
        The `is_traceback` key indicates if `text` contains plain text or a
        Python error traceback.

        The `title` and `repo` keys indicate how the error data should
        customize the report dialog and Github error submission.

        The `label` and `steps` keys allow customizing the content of the
        error dialog.
        N)sender)ri   r,   r4   )r   r6   ri   s      r   r4   zConsole.handle_exception   sM    : >[[]]F** 	+ 	
 	
 	
 	
 	
r   c                 8    | j                                          dS )z@
        Send the quit request to the main application.
        N)sig_quit_requestedemitr   s    r   quitzConsole.quit   s     	$$&&&&&r   c                 R    |                                                                   dS )zI
        Restore stdout and stderr when using open file dialogs.
        N)r,   restore_stdsr   s    r   ro   zConsole.restore_stds   s&     	&&(((((r   c                 R    |                                                                   dS )zJ
        Redirect stdout and stderr when using open file dialogs.
        N)r,   redirect_stdsr   s    r   rq   zConsole.redirect_stds   s&     	'')))))r   c                 T    |                                                      |           dS )ze
        Set the callback function to execute when the `exit_interpreter` is
        called.
        N)r,   rR   )r   funcs     r   rR   zConsole.set_exit_function   s(    
 	++D11111r   c                 X    |                                  }|                    |           dS )z
        Start the internal console interpreter.

        Stdin and stdout are now redirected through the internal console.
        N)r,   start_interpreter)r   	namespacer5   s      r   ru   zConsole.start_interpreter   s-     ""  +++++r   c                 V    |                                                      ||           dS )zT
        Add an object to the namespace dictionary of the internal console.
        N)r,   set_namespace_item)r   namevalues      r   rx   zConsole.set_namespace_item  s*     	,,T599999r   )Fr   )4__name__
__module____qualname____doc__NAMEr   WIDGET_CLASSr   r<   OPTIONALCONF_SECTION	CONF_FILEIPythonConsoleHistoryTABIFYCAN_BE_DISABLEDRAISE_AND_FOCUSr   r/   strintr-   r0   r3   r1   staticmethodr   r   r    r7   r	   rB   r
   rF   rK   rP   rX   r   rZ   propertyr]   r`   rb   rd   rg   r4   rm   ro   rq   rR   ru   rx   r   r   r   r   r   !   sq         D L !HLI$go6FOO $fS#s33 FHHMH % % \%  5 5 50 0 06  0111. . 21. w/000+ + 10+) ) )   # # # 
TVV) ) V) + + X+, , ,- - -/ / /0 0 0 
T$ZZ!
 !
 !
 Z!
F' ' ') ) )* * *2 2 2, , ,: : : : :r   r   )r~   loggingqtpy.QtCorer   r   
qtpy.QtGuir   spyder.api.pluginsr   r   )spyder.api.plugin_registration.decoratorsr	   r
   spyder.api.translationsr   spyder.config.baser   *spyder.plugins.console.widgets.main_widgetr   r   spyder.plugins.mainmenu.apir   r   	getLoggerr{   loggerr   r   r   r   <module>r      s?   
  % $ $ $ $ $ $ $       = < < < < < < <- - - - - - - - % % % % % % " " " " " ") ) ) ) ) ) ) ) J J J J J J J J 
	8	$	$i: i: i: i: i:" i: i: i: i: i:r   