o
    ˷e	                     @   s~   d Z ddlmZmZ ddlmZmZmZ ddlm	Z	 ddl
mZ g dZG dd ded	ZG d
d deZG dd deZdS )z)
Base classes for prompt_toolkit lexers.
    )ABCMetaabstractmethod)CallableHashableOptional)Document)StyleAndTextTuples)LexerSimpleLexerDynamicLexerc                   @   s>   e Zd ZdZededeegef fddZ	de
fddZdS )	r	   z$
    Base class for all lexers.
    documentreturnc                 C   s   dS )aT  
        Takes a :class:`~prompt_toolkit.document.Document` and returns a
        callable that takes a line number and returns a list of
        ``(style_str, text)`` tuples for that line.

        XXX: Note that in the past, this was supposed to return a list
             of ``(Token, text)`` tuples, just like a Pygments lexer.
        N )selfr   r   r   Q/var/www/ideatree/venv/lib/python3.10/site-packages/prompt_toolkit/lexers/base.pylex_document   s    zLexer.lex_documentc                 C   s   t | S )zz
        When this changes, `lex_document` could give a different output.
        (Only used for `DynamicLexer`.)
        )id)r   r   r   r   invalidation_hash!   s   zLexer.invalidation_hashN)__name__
__module____qualname____doc__r   r   r   intr   r   r   r   r   r   r   r   r	      s
    
r	   )	metaclassc                   @   s@   e Zd ZdZddeddfddZdedeege	f fd	d
Z
dS )r
   z
    Lexer that doesn't do any tokenizing and returns the whole input as one
    token.

    :param style: The style string for this lexer.
     styler   Nc                 C   s
   || _ d S N)r   )r   r   r   r   r   __init__1   s   
zSimpleLexer.__init__r   c                    s"   |j  dtdtf fdd}|S )Nlinenor   c                    s*   z	j  |  fgW S  ty   g  Y S w )z%Return the tokens for the given line.)r   
IndexError)r   linesr   r   r   get_line7   s
   z*SimpleLexer.lex_document.<locals>.get_line)r!   r   r   )r   r   r"   r   r    r   r   4   s   zSimpleLexer.lex_document)r   )r   r   r   r   strr   r   r   r   r   r   r   r   r   r   r
   )   s     r
   c                   @   sX   e Zd ZdZdeg ee f ddfddZdedee	ge
f fdd	Zdefd
dZdS )r   z
    Lexer class that can dynamically returns any Lexer.

    :param get_lexer: Callable that returns a :class:`.Lexer` instance.
    	get_lexerr   Nc                 C   s   || _ t | _d S r   )r$   r
   _dummy)r   r$   r   r   r   r   H   s   zDynamicLexer.__init__r   c                 C   s   |   p| j}||S r   )r$   r%   r   )r   r   lexerr   r   r   r   L   s   
zDynamicLexer.lex_documentc                 C   s   |   p| j}t|S r   )r$   r%   r   )r   r&   r   r   r   r   P   s   zDynamicLexer.invalidation_hash)r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   r   r   r   r   A   s
    r   N)r   abcr   r   typingr   r   r   prompt_toolkit.documentr   "prompt_toolkit.formatted_text.baser   __all__r	   r
   r   r   r   r   r   <module>   s    