B
    '˜t\¼  ã               @   s.   d dl mZ dgZG dd„ deƒZdd„ ZdS )é    )Úunicode_literalsÚexplode_text_fragmentsc                   sH   e Zd ZdZ‡ fdd„Zdd„ Z‡ fdd„Zdd	„ Z‡ fd
d„Z‡  Z	S )Ú_ExplodedListz¬
    Wrapper around a list, that marks it as 'exploded'.

    As soon as items are added or the list is extended, the new items are
    automatically exploded as well.
    c                s   t t| ƒj||Ž d| _d S )NT)Úsuperr   Ú__init__Úexploded)ÚselfÚaÚkw)Ú	__class__© ú:lib/python3.7/site-packages/prompt_toolkit/layout/utils.pyr      s    z_ExplodedList.__init__c             C   s   |   |g¡ d S )N)Úextend)r   Úitemr   r   r   Úappend   s    z_ExplodedList.appendc                s   t t| ƒ t|ƒ¡ d S )N)r   r   r   r   )r   Zlst)r   r   r   r      s    z_ExplodedList.extendc             C   s   t ‚d S )N)ÚNotImplementedError)r   Úindexr   r   r   r   Úinsert   s    z_ExplodedList.insertc                s8   t |tƒst||d ƒ}t|gƒ}tt| ƒ ||¡ dS )zl
        Ensure that when `(style_str, 'long string')` is set, the string will be
        exploded.
        é   N)Ú
isinstanceÚslicer   r   r   Ú__setitem__)r   r   Úvalue)r   r   r   r      s    

z_ExplodedList.__setitem__)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   Ú__classcell__r   r   )r   r   r      s   r   c             C   sJ   t | ddƒr| S g }x,| D ]$\}}x|D ]}| ||f¡ q(W qW t|ƒS )a.  
    Turn a list of (style_str, text) tuples into another list where each string is
    exactly one character.

    It should be fine to call this function several times. Calling this on a
    list that is already exploded, is a null operation.

    :param fragments: List of (style, text) tuples.
    r   F)Úgetattrr   r   )Z	fragmentsÚresultZstyleÚstringÚcr   r   r   r   )   s    
N)Z
__future__r   Ú__all__Úlistr   r   r   r   r   r   Ú<module>   s   !