← Back
Editing: word_completer.cpython-311.pyc
� �Ïc\ � �x � d dl mZmZmZmZmZmZmZ d dlm Z m Z mZ d dlm Z d dlmZ dgZ G d� de � � ZdS )� )�Callable�Iterable�List�Mapping�Optional�Pattern�Union)� CompleteEvent� Completer� Completion)�Document)�AnyFormattedText� WordCompleterc � � e Zd ZdZ ddeee eg ee f f dede e eef de e eef ded ed ede ee ddfd �Z dededee fd�ZdS )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�ignore_case�display_dict� meta_dict�WORD�sentence�match_middle�pattern�returnc � � |r|rJ �|| _ || _ |pi | _ |pi | _ || _ || _ || _ || _ d S )N)r r r r r r r r ) �selfr r r r r r r r s �J/usr/lib/python3/dist-packages/prompt_toolkit/completion/word_completer.py�__init__zWordCompleter.__init__ s] � � �&�X�&�&�&��� �&���(�.�B���"��b����� � �� �(�������� �document�complete_eventc # �� � �K � � j }t |� � r |� � }� j r|j �n!|� � j � j �� � �� j r�� � � �dt dt f� �fd�}|D ]f} ||� � rY� j � ||� � }� j � |d� � }t |t �� � ||�� � V � �gd S )N)r r �wordr c �z �� �j r| � � � } �j r�| v S | � �� � S )z-True when the word before the cursor matches.)r �lowerr � startswith)r"