o
    �õ±j‚  ã                   @  sv   d dl mZ d dlmZmZmZmZ d dlmZ d dl	m
Z
mZmZ d dlmZ d dlmZ dgZG dd„ deƒZd	S )
é    )Úannotations)ÚCallableÚIterableÚMappingÚSequence)ÚPattern)ÚCompleteEventÚ	CompleterÚ
Completion)ÚDocument)ÚAnyFormattedTextÚWordCompleterc                   @  s4   e Zd ZdZ							dddd„Zddd„ZdS )r   aè  
    Simple autocompletion on a list of words.

    :param words: List of words or callable that returns a list of words.
    :param ignore_case: If True, case-insensitive completion.
    :param meta_dict: Optional dict mapping words to their meta-text. (This
        should map strings to strings or formatted text.)
    :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.
    :param pattern: Optional compiled regex for finding the word before
        the cursor to complete. When given, use this regex pattern instead of
        default one (see document._FIND_WORD_RE)
    FNÚwordsú+Sequence[str] | Callable[[], Sequence[str]]Úignore_caseÚboolÚdisplay_dictú%Mapping[str, AnyFormattedText] | NoneÚ	meta_dictÚWORDÚsentenceÚmatch_middleÚpatternúPattern[str] | NoneÚreturnÚNonec	           	      C  sH   |r|rJ ‚|| _ || _|pi | _|pi | _|| _|| _|| _|| _d S )N)r   r   r   r   r   r   r   r   )	Úselfr   r   r   r   r   r   r   r   © r   ú›/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/prompt_toolkit/completion/word_completer.pyÚ__init__#   s   


zWordCompleter.__init__Údocumentr   Úcomplete_eventr   úIterable[Completion]c                 #  sž   � ˆ j }t|ƒr|ƒ }ˆ jr|j‰n	|jˆ jˆ jd�‰ˆ jr"ˆ ¡ ‰d
‡ ‡fdd„}|D ] }||ƒrLˆ j	 
||¡}ˆ j 
|d¡}t|tˆƒ ||d	�V  q,d S )N)r   r   ÚwordÚstrr   r   c                   s&   ˆ j r|  ¡ } ˆ jrˆ| v S |  ˆ¡S )z-True when the word before the cursor matches.)r   Úlowerr   Ú
startswith)r#   ©r   Úword_before_cursorr   r   Úword_matchesL   s
   
z3WordCompleter.get_completions.<locals>.word_matchesÚ )ÚtextÚstart_positionÚdisplayÚdisplay_meta)r#   r$   r   r   )r   Úcallabler   Útext_before_cursorÚget_word_before_cursorr   r   r   r%   r   Úgetr   r
   Úlen)r   r    r!   r   r)   Úar-   r.   r   r'   r   Úget_completions9   s0   €ÿ
ü€üzWordCompleter.get_completions)FNNFFFN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r    r   r!   r   r   r"   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r5   r   r   r   r   r      s    ÷N)Ú
__future__r   Úcollections.abcr   r   r   r   Úrer   Úprompt_toolkit.completionr   r	   r
   Úprompt_toolkit.documentr   Úprompt_toolkit.formatted_textr   Ú__all__r   r   r   r   r   Ú<module>   s    ÿ