
                             S r SSKJr  SSKJrJr  SSKJr  SSKJ	r	  Sr
 " S S	\5      r " S
 S\" \\5      5      r " S S\5      r " S S\5      rg)a:  
`Fish-style <http://fishshell.com/>`_  like auto-suggestion.

While a user types input in a certain buffer, suggestions are generated
(asynchronously.) Usually, they are displayed after the input. When the cursor
presses the right arrow and the cursor is at the end of the input, the
suggestion will be inserted.
    )unicode_literals)ABCMetaabstractmethod)with_metaclass   )to_cli_filter)
SuggestionAutoSuggestAutoSuggestFromHistoryConditionalAutoSuggestc                   $    \ rS rSrSrS rS rSrg)r	      zV
Suggestion returned by an auto-suggest algorithm.

:param text: The suggestion text.
c                     Xl         g Ntext)selfr   s     .lib/third_party/prompt_toolkit/auto_suggest.py__init__Suggestion.__init__   s    	    c                      SU R                   -  $ )NzSuggestion(%s)r   )r   s    r   __repr__Suggestion.__repr__    s    $))++r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r	   r	      s    
,r   r	   c                   (    \ rS rSrSr\S 5       rSrg)r
   $   z1
Base class for auto suggestion implementations.
c                     g)a,  
Return `None` or a :class:`.Suggestion` instance.

We receive both ``buffer`` and ``document``. The reason is that auto
suggestions are retrieved asynchronously. (Like completions.) The
buffer text could be changed in the meantime, but ``document`` contains
the buffer document like it was at the start of the auto suggestion
call. So, from here, don't access ``buffer.text``, but use
``document.text`` instead.

:param buffer: The :class:`~prompt_toolkit.buffer.Buffer` instance.
:param document: The :class:`~prompt_toolkit.document.Document` instance.
Nr!   r   clibufferdocuments       r   get_suggestionAutoSuggest.get_suggestion(   s    r   r!   N)r   r   r   r   r   r   r)   r    r!   r   r   r
   r
   $   s      r   r
   c                       \ rS rSrSrS rSrg)r   9   z5
Give suggestions based on the lines in the history.
c                 ^   UR                   nUR                  R                  SS5      S   nUR                  5       (       am  [	        [        U5      5       HT  n[	        UR                  5       5       H4  nUR                  U5      (       d  M  [        U[        U5      S  5      s  s  $    MV     g g )N
r   )
historyr   rsplitstripreversedlist
splitlines
startswithr	   len)r   r&   r'   r(   r0   r   stringlines           r   r)   %AutoSuggestFromHistory.get_suggestion=   s    .. }}##D!,R0 ::<<"4=1$V%6%6%89Dt,,)$s4yz*:;; : 2 r   r!   N)r   r   r   r   r   r)   r    r!   r   r   r   r   9   s    <r   r   c                   $    \ rS rSrSrS rS rSrg)r   L   zM
Auto suggest that can be turned on and of according to a certain condition.
c                 ^    [        U[        5      (       d   eXl        [        U5      U l        g r   )
isinstancer
   auto_suggestr   filter)r   r?   r@   s      r   r   ConditionalAutoSuggest.__init__P   s'    ,4444(#F+r   c                 h    U R                  U5      (       a  U R                  R                  XU5      $ g r   )r@   r?   r)   r%   s       r   r)   %ConditionalAutoSuggest.get_suggestionV   s/    ;;s$$33CJJ r   )r?   r@   N)r   r   r   r   r   r   r)   r    r!   r   r   r   r   L   s    ,Kr   r   N)r   
__future__r   abcr   r   sixr   filtersr   __all__objectr	   r
   r   r   r!   r   r   <module>rJ      sX    ( '  "
, 
,.&1 *<[ <&K[ Kr   