o
    tf                     @   s:   d Z ddlmZmZmZ ddlmZ G dd dejZdS )z$A simple completer for the qtconsole    )QtCoreQtGui	QtWidgets   )	columnizec                       s>   e Zd ZdZ fddZ fddZdd Zdd	d
Z  ZS )CompletionPlainz7 A widget for tab completion,  navigable by arrow keys c                    s@   t |jtjtjfsJ t   |j| _|| _| j	|  dS )zg Create a completion widget that is attached to the specified Qt
            text edit widget.
        N)

isinstance_controlr   Z	QTextEditZQPlainTextEditsuper__init__
_text_edit_console_widgetZinstallEventFilter)selfZconsole_widget	__class__ c/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/qtconsole/completion_plain.pyr      s
   
zCompletionPlain.__init__c                    s<   || j kr| }|tjjtjjfv r|   t ||S )zm Reimplemented to handle keyboard input and to auto-hide when the
            text edit loses focus.
        )	r   typer   ZQEventZKeyPressZFocusOutcancel_completionr
   eventFilter)r   objeventetyper   r   r   r      s
   
zCompletionPlain.eventFilterc                 C   s   | j   dS )zCCancel the completion, reseting internal variable, clearing buffer N)r   Z_clear_temporary_buffer)r   r   r   r   r   -   s   z!CompletionPlain.cancel_completionr   c                 C   s@   |sdS |    t|}|jtjj|d | jj||dd dS )ze Shows the completion widget with 'items' at the position specified
            by 'cursor'.
        N)nF)html)r   r   ZmovePositionr   ZQTextCursorZLeftr   Z_fill_temporary_buffer)r   cursoritemsZprefix_lengthZstrngr   r   r   
show_items2   s   zCompletionPlain.show_items)r   )	__name__
__module____qualname____doc__r   r   r   r   __classcell__r   r   r   r   r      s    r   N)	r!   Zqtpyr   r   r   utilr   ZQWidgetr   r   r   r   r   <module>   s    