ó
_y]c           @   sH   d  Z  d d l m Z m Z d d l j Z d e j f d „  ƒ  YZ d S(   s$   A simple completer for the qtconsoleiÿÿÿÿ(   t   QtCoret   QtGuiNt   CompletionPlainc           B   s5   e  Z d  Z d „  Z d „  Z d „  Z d d „ Z RS(   s7    A widget for tab completion,  navigable by arrow keys c         C   s`   t  | j t j t j f ƒ s$ t ‚ t t |  ƒ j ƒ  | j |  _	 | |  _
 |  j	 j |  ƒ d S(   sg    Create a completion widget that is attached to the specified Qt
            text edit widget.
        N(   t
   isinstancet   _controlR   t	   QTextEditt   QPlainTextEditt   AssertionErrort   superR   t   __init__t
   _text_editt   _console_widgett   installEventFilter(   t   selft   console_widget(    (    s9   lib/python2.7/site-packages/qtconsole/completion_plain.pyR	      s
    $	c         C   sb   | |  j  k rI | j ƒ  } | t j j t j j f k rI |  j ƒ  qI n  t t |  ƒ j	 | | ƒ S(   sm    Reimplemented to handle keyboard input and to auto-hide when the
            text edit loses focus.
        (
   R
   t   typeR    t   QEventt   KeyPresst   FocusOutt   cancel_completionR   R   t   eventFilter(   R   t   objt   eventt   etype(    (    s9   lib/python2.7/site-packages/qtconsole/completion_plain.pyR      s
    c         C   s   |  j  j ƒ  d S(   sC   Cancel the completion, reseting internal variable, clearing buffer N(   R   t   _clear_temporary_buffer(   R   (    (    s9   lib/python2.7/site-packages/qtconsole/completion_plain.pyR   ,   s    i    c         C   sY   | s
 d S|  j  ƒ  t j | ƒ } | j t j j d | ƒ|  j j | | d t	 ƒd S(   se    Shows the completion widget with 'items' at the position specified
            by 'cursor'.
        Nt   nt   html(
   R   t   textt	   columnizet   movePositionR   t   QTextCursort   LeftR   t   _fill_temporary_buffert   False(   R   t   cursort   itemst   prefix_lengtht   strng(    (    s9   lib/python2.7/site-packages/qtconsole/completion_plain.pyt
   show_items1   s    
(   t   __name__t
   __module__t   __doc__R	   R   R   R&   (    (    (    s9   lib/python2.7/site-packages/qtconsole/completion_plain.pyR   
   s
   			(   R)   t   qtconsole.qtR    R   t   ipython_genutils.textR   t   QWidgetR   (    (    (    s9   lib/python2.7/site-packages/qtconsole/completion_plain.pyt   <module>   s   