
    J                     j    S r SSKJr  SSKJrJrJrJr  SSKJ	r	J
r
  SSKJr  SSKrSr " S	 S
\5      rg)z}
The BufferMapping contains all the buffers for a command line interface, and it
keeps track of which buffer gets the focus.
    )unicode_literals   )DEFAULT_BUFFERSEARCH_BUFFERSYSTEM_BUFFERDUMMY_BUFFER)BufferAcceptAction)InMemoryHistoryN)BufferMappingc                   X   ^  \ rS rSrSrS\4U 4S jjrS rS rS r	S r
S	 rS
 rSrU =r$ )r      a<  
Dictionary that maps the name of the buffers to the
:class:`~prompt_toolkit.buffer.Buffer` instances.

This mapping also keeps track of which buffer currently has the focus.
(Some methods receive a 'cli' parameter. This is useful for applications
where this `BufferMapping` is shared between several applications.)
Nc                   > Ub  [        U[        5      (       d   e[        [        U ]  5         U R                  [        [        [        R                  S9[        [        [        5       [        R                  S9[        [        [        5       [        R                  S9[        [        SS905        Ub  U R                  U5        U=(       d    [        /U l        g )N)accept_action)historyr   T)	read_only)
isinstancedictsuperr   __init__updater   r	   r
   RETURN_DOCUMENTr   r   IGNOREr   r   focus_stack)selfbuffersinitial	__class__s      0lib/third_party/prompt_toolkit/buffer_mapping.pyr   BufferMapping.__init__   s    *Wd";";;; 	mT+- 	 F1M1MN6/*;<K^K^_6/*;<K^K^_&40
 	 KK  $5~6    c                 $    X R                   S      $ )z
The active :class:`.Buffer`.
r   r   clis     r   currentBufferMapping.current1   s     $$R())r!   c                      U R                   S   $ )z*
The name of the active :class:`.Buffer`.
r#   r$   r%   s     r   current_nameBufferMapping.current_name7   s     ##r!   c                 z    [        U R                  5      S:  a   X R                  S      $ g! [         a     gf = f)z<
Return the previously focussed :class:`.Buffer` or `None`.
r   N)lenr   KeyErrorr%   s     r   previousBufferMapping.previous=   sI     t 1$,,R011 %  s   - 
::c                 V    [        U[        R                  5      (       d   eU/U l        g)z'
Focus the buffer with the given name.
N)r   six	text_typer   r   r&   buffer_names      r   focusBufferMapping.focusG   s%     +s}}5555'=r!   c                 |    [        U[        R                  5      (       d   eU R                  R	                  U5        g)z!
Push buffer on the focus stack.
N)r   r3   r4   r   appendr5   s      r   
push_focusBufferMapping.push_focusN   s/     +s}}5555,r!   c                     [        U R                  5      S:  a  U R                  R                  5         g[        S5      e)z"
Pop buffer from the focus stack.
r   z*Cannot pop last item from the focus stack.N)r.   r   pop
IndexErrorr%   s     r   	pop_focusBufferMapping.pop_focusU   s5     t 1$  "IJJr!   r$   )__name__
__module____qualname____firstlineno____doc__r   r   r'   r*   r0   r7   r;   r@   __static_attributes____classcell__)r   s   @r   r   r      s9      $^ 7.*$)-K Kr!   r   )rF   
__future__r   enumsr   r   r   r   bufferr	   r
   r   r   r3   __all__r   r    r!   r   <module>rN      s5    ( M M ( $ 

KKD KKr!   