B
    nôb\v  ã               @   s~   d 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mZmZmZ G dd„ deeeeeƒZG d	d
„ d
eeƒZdS )z#Control widgets used by ShellWidgeté    )ÚQtÚSignal)Ú	QTextEdit)Úrestore_keyevent)ÚCallTipWidget)ÚBaseEditMixinÚGetHelpMixinÚTracebackLinksMixinÚBrowseHistoryMixinc                   sh   e Zd ZdZeZeeƒZee	ƒZ
eƒ Zddd„Zdd„ Zdd„ Zd	d
„ Z‡ fdd„Z‡ fdd„Z‡  ZS )ÚControlWidgetzw
    Subclass of QTextEdit with features from Spyder's mixins to use as the
    control widget for IPython widgets
    Nc             C   sR   t  | |¡ t | ¡ t | ¡ t | ¡ t | ¡ t| dd| _g | _d| _	d S )NF)Zhide_timer_on)
r   Ú__init__r   r	   r   r
   r   Zcalltip_widgetÚfound_resultsZcalltips)ÚselfÚparent© r   úDlib/python3.7/site-packages/spyder/widgets/ipythonconsole/control.pyr      s    



zControlWidget.__init__c             C   s   | j  d¡ dS )zReimplement Qt MethodTN)Úvisibility_changedÚemit)r   Úeventr   r   r   Ú	showEvent+   s    zControlWidget.showEventc             C   s@   |   ¡ j| _|  ¡ r2|  ¡ }|r2| ¡ s2|  |¡ |  |¡ dS )z Action for '(' N)ZparentWidgetZ_prompt_posZcurrent_prompt_posZget_current_line_to_cursorZget_last_objÚisdigitZshow_object_infoZinsert_text)r   ÚtextZlast_objr   r   r   Ú_key_paren_left/   s    
zControlWidget._key_paren_leftc             C   sP   t |ƒ\}}}}}|tjkr@|  ¡ s@| jr@|  ¡ js@|  |¡ nt 	| |¡ dS )z4Reimplement Qt Method - Basic keypress event handlerN)
r   r   ZKey_ParenLeftZhas_selected_textZhelp_enabledr   Z_readingr   r   ÚkeyPressEvent)r   r   r   ÚkeyÚctrlÚshiftr   r   r   r   8   s
    zControlWidget.keyPressEventc                s   | j  ¡  tt| ƒ |¡S )z7Reimplement Qt method to send focus change notification)Úfocus_changedr   Úsuperr   ÚfocusInEvent)r   r   )Ú	__class__r   r   r   B   s    
zControlWidget.focusInEventc                s   | j  ¡  tt| ƒ |¡S )z7Reimplement Qt method to send focus change notification)r   r   r   r   ÚfocusOutEvent)r   r   )r    r   r   r!   G   s    
zControlWidget.focusOutEvent)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚQT_CLASSr   Úboolr   ÚstrZgo_to_errorr   r   r   r   r   r   r!   Ú__classcell__r   r   )r    r   r      s   
	
r   c                   s^   e Zd ZdZeZeeƒZeƒ Z	eƒ Z
ddd„Zdd„ Zdd„ Z‡ fd	d
„Z‡ fdd„Z‡  ZS )ÚPageControlWidgetz„
    Subclass of QTextEdit with features from Spyder's mixins.BaseEditMixin to
    use as the paging widget for IPython widgets
    Nc             C   s    t  | |¡ t | ¡ g | _d S )N)r   r   r   r   )r   r   r   r   r   r   W   s    
zPageControlWidget.__init__c             C   s   | j  d¡ dS )zReimplement Qt MethodTN)r   r   )r   r   r   r   r   r   \   s    zPageControlWidget.showEventc             C   s2   t |ƒ\}}}}}|tjkr.|  ¡ r.| j ¡  dS )z4Reimplement Qt Method - Basic keypress event handlerN)r   r   Z	Key_SlashZ	isVisibleÚshow_find_widgetr   )r   r   r   r   r   r   r   r   r   r   `   s    zPageControlWidget.keyPressEventc                s   | j  ¡  tt| ƒ |¡S )z7Reimplement Qt method to send focus change notification)r   r   r   r*   r   )r   r   )r    r   r   r   g   s    
zPageControlWidget.focusInEventc                s   | j  ¡  tt| ƒ |¡S )z7Reimplement Qt method to send focus change notification)r   r   r   r*   r!   )r   r   )r    r   r   r!   l   s    
zPageControlWidget.focusOutEvent)N)r"   r#   r$   r%   r   r&   r   r'   r   r+   r   r   r   r   r   r!   r)   r   r   )r    r   r*   M   s   
r*   N)r%   Zqtpy.QtCorer   r   Zqtpy.QtWidgetsr   Zspyder.utils.qthelpersr   Zspyder.widgets.calltipr   Zspyder.widgets.mixinsr   r   r	   r
   r   r*   r   r   r   r   Ú<module>   s   9