
    
8d                     P    d Z ddlmZmZmZ ddlmZ  G d dej                  ZdS )z$A simple completer for the qtconsole    )QtCoreQtGui	QtWidgetsNc                   :     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        	                    |            dS )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     :lib/python3.11/site-packages/qtconsole/completion_plain.pyr   zCompletionPlain.__init__   sm     .1I4GIa3bccccc(1-**400000    c                     || j         k    rL|                                }|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   QEventKeyPressFocusOutcancel_completionr   eventFilter)r   objeventetyper   s       r   r   zCompletionPlain.eventFilter   se     $/!!JJLLE/1GIII&&(((ww""3...r   c                 8    | j                                          dS )zCCancel the completion, reseting internal variable, clearing buffer N)r   _clear_temporary_buffer)r   s    r   r   z!CompletionPlain.cancel_completion,   s    4466666r   r   c                     |sdS |                                   t          j        |          }|                    t          j        j        |           | j                            ||d           dS )ze Shows the completion widget with 'items' at the position specified
            by 'cursor'.
        N)nF)html)	r   text	columnizemovePositionr   QTextCursorLeftr   _fill_temporary_buffer)r   cursoritemsprefix_lengthstrngs        r   
show_itemszCompletionPlain.show_items1   sw      	F   u%% 	E-2mDDD33FE3NNNNNr   )r   )	__name__
__module____qualname____doc__r   r   r   r0   __classcell__)r   s   @r   r   r   
   s        AA
1 
1 
1 
1 
1
/ 
/ 
/ 
/ 
/7 7 7
O O O O O O O Or   r   )	r4   qtpyr   r   r   ipython_genutils.textr&   QWidgetr    r   r   <module>r:      s~    * *
 * ) ) ) ) ) ) ) ) ) $ $ $ $ $ $2O 2O 2O 2O 2Oi' 2O 2O 2O 2O 2Or   