
    G@d                         d 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
 ddlmZ ddlmZ ddlmZ dd	lmZ  G d
 d          Z G d de          Zd Zedk    r e             dS dS )z
Find in Files Plugin.
    )Qt)QApplication)PluginsSpyderDockablePlugin)on_plugin_availableon_plugin_teardown_)FindInFilesWidget)ApplicationMenus)getcwd_or_homec                       e Zd ZdZdS )FindInFilesActionszfind in filesN)__name__
__module____qualname__FindInFiles     Alib/python3.11/site-packages/spyder/plugins/findinfiles/plugin.pyr   r      s        !KKKr   r   c                      e Zd ZdZdZg Zej        ej        ej	        gZ
ej        gZeZeZdZdZed             Zd Zd Zd Z eej        	          d
             Z eej        	          d             Z eej	        	          d             Z eej        	          d             Z eej        	          d             Z eej	        	          d             ZddZd Z d Z!d Z"ddZ#d Z$d Z%dS )r   z#
    Find in files DockWidget.
    find_in_filesFTc                       t          d          S )NFindr	   r   r   r   get_namezFindInFiles.get_name/   s    yyr   c                      t          d          S )Nz$Search for strings of text in files.r	   selfs    r   get_descriptionzFindInFiles.get_description3   s    7888r   c                 ,    |                      d          S )Nfindf)create_iconr   s    r   get_iconzFindInFiles.get_icon6   s    (((r   c                     |                      t          j        t          d          t          d          | j        dt
          j                   |                                  d S )NzFind in fileszSearch text in multiple filesT)texttip	triggeredregister_shortcutcontext)create_actionr   r   r
   findr   WindowShortcutrefresh_search_directoryr   s    r   on_initializezFindInFiles.on_initialize9   sd    *?##122i"% 	 	
 	
 	
 	%%'''''r   )pluginc                     |                                  }|                     t          j                  |j                            fd           j                            | j                   d S )Nc                 6                         | |||          S )N)start_column
end_column)load)filenamelinenosearch_textcolnocolendeditors        r   <lambda>z1FindInFiles.on_editor_available.<locals>.<lambda>I   s)    &u BM BI BI r   )
get_widget
get_pluginr   Editorsig_edit_goto_requestedconnect!sig_file_opened_closed_or_updatedset_current_opened_filer   widgetr:   s     @r   on_editor_availablezFindInFiles.on_editor_availableD   s    ""00&..I I I I	J 	J 	J 	088(	* 	* 	* 	* 	*r   c                     |                      t          j                  }|j                            | j                   |j                            | j                   d S N)r=   r   Projectssig_project_loadedr@   set_project_pathsig_project_closedunset_project_pathr   projectss     r   on_projects_availablez!FindInFiles.on_projects_availableN   sP    ??7#344#++D,ABBB#++D,CDDDDDr   c                     |                      t          j                  }|                     t          j                  }|                    |t          j                   d S N)menu_id)	r=   r   MainMenu
get_actionr   r   add_item_to_application_menur   Search)r   mainmenufindinfiles_actions      r   on_main_menu_availablez"FindInFiles.on_main_menu_availableT   s\    ??7#344!__-?-KLL--$+ 	. 	
 	
 	
 	
 	
r   c                     |                                  }|                     t          j                  }|j                                         |j                            | j                   d S rG   )r<   r=   r   r>   r?   
disconnectrA   rB   rC   s      r   on_editor_teardownzFindInFiles.on_editor_teardown^   sd    ""00&113330;;(	* 	* 	* 	* 	*r   c                     |                      t          j                  }|j                            | j                   |j                            | j                   d S rG   )r=   r   rH   rI   r[   rJ   rK   rL   rM   s     r   #on_projects_teardon_plugin_teardownz/FindInFiles.on_projects_teardon_plugin_teardownf   sP    ??7#344#..t/DEEE#..t/FGGGGGr   c                     |                      t          j                  }|                    t          j        t          j                   d S rQ   )r=   r   rS   !remove_item_from_application_menur   r   r   rV   )r   rW   s     r   on_main_menu_teardownz!FindInFiles.on_main_menu_teardownl   sI    ??7#34422*$+ 	3 	
 	
 	
 	
 	
r   c                     |                                                                   |                                  j        r(|                                                      d           dS )NT)ignore_results)r<   _update_optionsrunning_stop_and_reset_thread)r   
cancelables     r   on_closezFindInFiles.on_closeu   sZ    ))+++??$ 	JOO44D4IIItr   c                 l    |                                                      t                                 dS )z+
        Refresh search directory.
        N)r<   set_directoryr   r   s    r   r-   z$FindInFiles.refresh_search_directory}   s.     	''(8(899999r   c                 T    |                                                      |           dS )z
        Set path of current opened file in editor.

        Parameters
        ----------
        path: str
            Path of editor file.
        N)r<   set_file_path)r   path	_languages      r   rB   z#FindInFiles.set_current_opened_file   s(     	''-----r   c                 T    |                                                      |           dS )z
        Set and refresh current project path.

        Parameters
        ----------
        path: str
            Opened project path.
        N)r<   rJ   )r   rm   s     r   rJ   zFindInFiles.set_project_path   s(     	**400000r   Nc                 T    |                                                      |           dS )z
        Set maximum amount of results to add to the result browser.

        Parameters
        ----------
        value: int, optional
            Number of results. If None an input dialog will be used.
            Default is None.
        N)r<   set_max_results)r   values     r   rq   zFindInFiles.set_max_results   s(     	))%00000r   c                 R    |                                                                   dS )z-
        Unset current project path.
        N)r<   disable_project_searchr   s    r   rL   zFindInFiles.unset_project_path   s&     	0022222r   c                 J   t          j                    }d}	 |                                r|                                }n# t          $ r Y nw xY w|                                  |                                 }|r|                    |           |                                 dS )z
        Search text in multiple files.

        Notes
        -----
        Find in files using the currently selected text of the focused widget.
         N)	r   focusWidgethas_selected_textget_selected_textAttributeErrorswitch_to_pluginr<   set_search_textr+   )r   focus_widgetr%   rD   s       r   r+   zFindInFiles.find   s     $/11	--// 8#5577 	 	 	D	 	"" 	)""4(((s   (A   
AA)FrG   )&r   r   r   __doc__NAMEREQUIRESr   r>   rH   rS   OPTIONALVariableExplorerTABIFYr   WIDGET_CLASSCONF_SECTION	CONF_FILERAISE_AND_FOCUSstaticmethodr   r   r#   r.   r   rE   rO   rY   r   r\   r^   ra   rh   r-   rB   rJ   rq   rL   r+   r   r   r   r   r       s*         DH 0'2BCH&'F$LLIO   \9 9 9) ) )	( 	( 	( ///* * 0/*  0111E E 21E
  0111
 
 21
 w~...* * /.* w/000H H 10H
 w/000
 
 10
   : : :	. 	. 	.	1 	1 	1
1 
1 
1 
13 3 3    r   r   c                      dd l } ddlm} ddlm}  |            }t          d |          }|                                 |                     |                                           d S )Nr   )CONF)qapplication)	sysspyder.config.managerr   spyder.utils.qthelpersr   r   showexitexec_)r   r   r   apprD   s        r   testr      sv    JJJ******333333
,..Ct$$F
KKMMMHHSYY[[r   __main__N)r~   qtpy.QtCorer   qtpy.QtWidgetsr   spyder.api.pluginsr   r   )spyder.api.plugin_registration.decoratorsr   r   spyder.api.translationsr
   .spyder.plugins.findinfiles.widgets.main_widgetr   spyder.plugins.mainmenu.apir   spyder.utils.miscr   r   r   r   r   r   r   r   <module>r      sN   
       ' ' ' ' ' ' = < < < < < < <- - - - - - - - % % % % % % L L L L L L 8 8 8 8 8 8 , , , , , ,
" " " " " " " "b b b b b& b b bJ	 	 	 zDFFFFF r   