ó
‹²,]c           @   s   d  Z  d d l Z d d l m Z d d l m Z m Z m Z d d l m	 Z	 d d l
 m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z m Z d d l m Z d d l m Z d e e f d „  ƒ  YZ d „  Z e d k rü e ƒ  n  d S(   s   Find in Files PluginiÿÿÿÿN(   t   QApplication(   t   Signalt   Slott   Qt(   t   QKeySequence(   t   _(   t   get_edit_extensions(   t   getcwd_or_home(   t   icon_manager(   t   create_actiont   MENU_SEPARATOR(   t   FindInFilesWidget(   t   SpyderPluginMixint   FindInFilesc           B   sÚ   e  Z d  Z d Z e e e ƒ Z e e ƒ Z	 e e e
 e ƒ Z e e ƒ Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z e ƒ  d „  ƒ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z RS(   s   Find in files DockWidgett   find_in_filesc         C   s0  |  j  d ƒ } |  j  d ƒ |  _ |  j  d ƒ } g  | D] } | |  j k r7 | ^ q7 } | |  j 7} |  j  d ƒ } |  j  d ƒ } |  j  d d  ƒ } |  j  d ƒ } |  j  d ƒ }	 |  j  d	 ƒ }
 |  j  d
 g  ƒ } t j |  | | | | | | | |	 |
 | ƒ t j |  | ƒ |  j ƒ  |  j j |  j	 ƒ d  S(   Nt   supported_encodingst   search_text_samplest   search_textt   search_text_regexpt   excludet   exclude_idxt   exclude_regexpt   more_optionst   case_sensitivet   path_history(
   t
   get_optionR   t   NoneR   t   __init__R   t   initialize_plugint   toggle_visibilityt   connectt   toggle(   t   selft   parentR   R   t   txtR   R   R   R   R   R   R   (    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyR   (   s,    

c         C   s    |  j  r |  j  j | ƒ n  d S(   s   Toggle widget visibilityN(   t
   dockwidgett
   setVisible(   R    t   state(    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyR   D   s    	c         C   s   |  j  j t ƒ  ƒ d S(   s   Refresh search directoryN(   t   find_optionst   set_directoryR   (   R    (    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyt
   refreshdirI   s    c         C   s   |  j  j | ƒ d S(   s   Refresh current project pathN(   R&   t   set_project_path(   R    t   path(    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyR)   M   s    c         C   s   |  j  j | ƒ d S(   s)   Get path of current opened file in editorN(   R&   t   set_file_path(   R    R*   (    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyt   set_current_opened_fileQ   s    c         C   s   |  j  j ƒ  d S(   s   Refresh current project pathN(   R&   t   disable_project_search(   R    (    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyt   unset_project_pathU   s    c         C   s’   t  j ƒ  } |  j s5 |  j j t ƒ |  j j ƒ  n  d } y | j ƒ  rY | j ƒ  } n  Wn t	 k
 rm n X|  j
 | ƒ | rŽ |  j ƒ  n  d S(   s   Find in files callbackt    N(   R    t   focusWidgett   ismaximizedR#   R$   t   Truet   raise_t   has_selected_textt   get_selected_textt   AttributeErrort   set_search_textt   find(   R    t   widgett   text(    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyt   findinfiles_callbackY   s    	c         C   s   |  j  ƒ  t j |  ƒ d S(   sR   Switch to plugin
        This method is called when pressing plugin's shortcut keyN(   R;   R   t   switch_to_plugin(   R    (    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyR<   l   s    
c         C   s
   t  d ƒ S(   s   Return widget titles   Find in files(   R   (   R    (    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyt   get_plugin_titles   s    c         C   s
   |  j  j S(   sq   
        Return the widget to give focus to when
        this plugin's dockwidget is raised on top-level
        (   R&   R   (   R    (    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyt   get_focus_widgetw   s    c         C   s   g  S(   s*   Return a list of actions related to plugin(    (   R    (    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyt   get_plugin_actions~   s    c         C   s2  |  j  j |  ƒ |  j j |  j  j j ƒ |  j j |  j  j ƒ |  j  j j	 j |  j
 ƒ |  j  j j j |  j ƒ |  j  j j j |  j ƒ |  j  j j j |  j ƒ t |  t d ƒ d t j d ƒ d |  j d t |  j ƒ d t j d t d ƒ ƒ} |  j  j t | g 7_ |  j  j t | g 7_ |  j
 ƒ  d	 S(
   s'   Register plugin in Spyder's main windows   &Find in filest   icont   findft	   triggeredt   shortcutt   contextt   tips   Search text in multiple filesN(   t   maint   add_dockwidgett	   edit_gotoR   t   editort   loadt   redirect_stdiot   redirect_internalshell_stdiot   workingdirectoryt   refresh_findinfilesR(   t   projectst   sig_project_loadedR)   t   sig_project_closedR.   t   open_file_updateR,   R	   R   t   imaR@   R<   R   RC   R   t   WidgetShortcutt   search_menu_actionsR
   t   search_toolbar_actions(   R    t   findinfiles_action(    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyt   register_plugin‚   s$    		c         C   s   d S(   s   Refresh widgetN(    (   R    (    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyt   refresh_plugin™   s    c         C   sõ   |  j  ƒ  |  j j d t ƒ } | d k	 rñ | \ } } } } } } }	 }
 d } | |  } | |  } |
 | }
 |  j d | ƒ |  j d | ƒ |  j d | ƒ |  j d | ƒ |  j d | ƒ |  j d | ƒ |  j d	 |	 ƒ |  j d
 |
 ƒ n  t S(   s3   Perform actions before parent main window is closedt   to_savei   R   R   R   R   R   R   R   R   N(   t   closing_widgetR&   t   get_optionsR2   R   t
   set_option(   R    t
   cancelablet   optionsR   t   text_reR   R   t
   exclude_reR   R   R   t
   hist_limit(    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyt   closing_plugin   s"    


N(   t   __name__t
   __module__t   __doc__t   CONF_SECTIONR   t   strt   objectt   sig_option_changedt   boolR   t   intRH   RK   R   R   R   R(   R)   R,   R.   R   R;   R<   R=   R>   R?   RX   RY   t   FalseRc   (    (    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyR       s(   											c          C   sC   d d l  m }  |  ƒ  } t ƒ  } | j ƒ  t j | j ƒ  ƒ d  S(   Niÿÿÿÿ(   t   qapplication(   t   spyder.utils.qthelpersRn   R   t   showt   syst   exitt   exec_(   Rn   t   appR9   (    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyt   testµ   s
    		
t   __main__(   Rf   Rq   t   qtpy.QtWidgetsR    t   qtpy.QtCoreR   R   R   t
   qtpy.QtGuiR   t   spyder.config.baseR   t   spyder.config.utilsR   t   spyder.utils.miscR   t   spyder.utilsR   RS   Ro   R	   R
   t   spyder.widgets.findinfilesR   t   spyder.pluginsR   R   Ru   Rd   (    (    (    s9   lib/python2.7/site-packages/spyder/plugins/findinfiles.pyt   <module>   s   •	