
                         F    d dl mZ d dlmZ d dlmZmZ dZ G d de      Zy)    )unicode_literals)string_types)	Completer
Completion)WordCompleterc                   "    e Zd ZdZ	 	 ddZd Zy)r   a  
    Simple autocompletion on a list of words.

    :param words: List of words.
    :param ignore_case: If True, case-insensitive completion.
    :param meta_dict: Optional dict mapping words to their meta-information.
    :param WORD: When True, use WORD characters.
    :param sentence: When True, don't complete by comparing the word before the
        cursor, but by comparing all the text before the cursor. In this case,
        the list of words is just a list of strings, where each string can
        contain spaces. (Can not be used together with the WORD option.)
    :param match_middle: When True, match not only the start, but also in the
                         middle of the word.
    Nc                     |r|rJ t        |      | _        || _        |xs i | _        || _        || _        || _        t        d | j                  D              sJ y )Nc              3   <   K   | ]  }t        |t                y w)N)
isinstancer   ).0ws     9lib/third_party/prompt_toolkit/contrib/completers/base.py	<genexpr>z)WordCompleter.__init__.<locals>.<genexpr>$   s     C
1:a.
s   )listwordsignore_case	meta_dictWORDsentencematch_middleall)selfr   r   r   r   r   r   s          r   __init__zWordCompleter.__init__   sY    X&&%[
&"b	 (C

CCCC    c              #   ^   K    j                   r|j                  n|j                   j                         j                  rj                          fd} j                  D ]A  } ||      s j                  j                  |d      }t        |t               |       C y w)N)r   c                 ~    j                   r| j                         } j                  r| v S | j                        S )z/ True when the word before the cursor matches. )r   lowerr   
startswith)wordr   word_before_cursors    r   word_matchesz3WordCompleter.get_completions.<locals>.word_matches0   s;    zz|  )T11'9::r    )display_meta)r   text_before_cursorget_word_before_cursorr   r   r   r   r   getr   len)r   documentcomplete_eventr!   ar#   r    s   `     @r   get_completionszWordCompleter.get_completions&   s     ==!)!<!<!)!@!@dii!@!P!3!9!9!;	; AA#~~11!R8 S);%<$<<XX s   A/B-49B-)FNFFF)__name__
__module____qualname____doc__r   r+    r   r   r   r      s     GL.3
DYr   r   N)	
__future__r   sixr   prompt_toolkit.completionr   r   __all__r   r0   r   r   <module>r5      s#    '  ;
2YI 2Yr   