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

isinstance_controlr   	QTextEditQPlainTextEditsuper__init__
_text_edit_console_widgetinstallEventFilter)selfconsole_widget	__class__s     </usr/lib/python3/dist-packages/qtconsole/completion_plain.pyr   zCompletionPlain.__init__   s^     .11I4G4GIaIa3bccc(11-**40    c                     || j                   k(  rV|j                         }|t        j                  j                  t        j                  j
                  fv r| j                          t        | !  ||      S )zm Reimplemented to handle keyboard input and to auto-hide when the
            text edit loses focus.
        )	r   typer   QEventKeyPressFocusOutcancel_completionr   eventFilter)r   objeventetyper   s       r   r   zCompletionPlain.eventFilter   s[     $//!JJLE//1G1GII&&(w"3..r   c                 8    | j                   j                          y)zCCancel the completion, reseting internal variable, clearing buffer N)r   _clear_temporary_buffer)r   s    r   r   z!CompletionPlain.cancel_completion-   s    446r   c                     |sy| j                          t        |      }|j                  t        j                  j
                  |       | j                  j                  ||d       y)ze Shows the completion widget with 'items' at the position specified
            by 'cursor'.
        N)nF)html)r   r   movePositionr   QTextCursorLeftr   _fill_temporary_buffer)r   cursoritemsprefix_lengthstrngs        r   
show_itemszCompletionPlain.show_items2   s\      %  	E--22mD33FE3Nr   )r   )	__name__
__module____qualname____doc__r   r   r   r0   __classcell__)r   s   @r   r	   r	      s    A
1
/7
Or   r	   N)	r4   qtpyr   r   r   utilr   QWidgetr	    r   r   <module>r:      s'    *
 * ) 2Oi'' 2Or   