
    [                         S r SSKJr  SSKJrJr  SSKJr  Sr " S S\	5      r
 " S S	\	5      r " S
 S\" \\	5      5      rS rS rg)
    )unicode_literals)ABCMetaabstractmethod)with_metaclass)
Completion	CompleterCompleteEventget_common_complete_suffixc                   N    \ rS rSrSr  SS jrS rS rS r\	S 5       r
S	 rS
rg)r      a_  
:param text: The new string that will be inserted into the document.
:param start_position: Position relative to the cursor_position where the
    new text will start. The text will be inserted between the
    start_position and the original cursor position.
:param display: (optional string) If the completion has to be displayed
    differently in the completion menu.
:param display_meta: (Optional string) Meta information about the
    completion, e.g. the path or source where it's coming from.
:param get_display_meta: Lazy `display_meta`. Retrieve meta information
    only when meta is displayed.
Nc                 x    Xl         X l        X@l        XPl        Uc  Xl        OX0l        U R                  S::  d   eg )Nr   )textstart_position_display_meta_get_display_metadisplay)selfr   r   r   display_metaget_display_metas         ,lib/third_party/prompt_toolkit/completion.py__init__Completion.__init__   s<    	,)!1?L"L""a'''    c                 *   U R                   U R                  :X  a6  U R                  R                  < SU R                  < SU R                  < S3$ U R                  R                  < SU R                  < SU R                  < SU R                   < S3$ )Nz(text=z, start_position=)z
, display=)r   r   	__class____name__r   r   s    r   __repr__Completion.__repr__*   sg    <<499$''D4G4GI I ''D4G4G r   c                     U R                   UR                   :H  =(       aY    U R                  UR                  :H  =(       a9    U R                  UR                  :H  =(       a    U R                  UR                  :H  $ N)r   r   r   r   )r   others     r   __eq__Completion.__eq__3   s`    II# 45#7#774LLEMM)4 !3!33		5r   c                 p    [        U R                  U R                  U R                  U R                  45      $ r#   )hashr   r   r   r   r   s    r   __hash__Completion.__hash__:   s*    TYY 3 3T\\4CTCTUVVr   c                     U R                   b  U R                   $ U R                  (       a!  U R                  5       U l         U R                   $ gN )r   r   r   s    r   r   Completion.display_meta=   sG     )%%%##!%!7!7!9D%%% r   c                     [        U[        5      (       a  XR                  -
  S:  d   e[        U R                  XR                  -
  S U R
                  U R                  U R                  S9$ )z
(Only for internal use!)
Get a new completion by splitting this one. Used by
`CommandLineInterface` when it needs to have a list of new completions
after inserting the common prefix.
r   N)r   r   r   r   )
isinstanceintr   r   r   r   r   r   )r   positions     r   new_completion_from_position'Completion.new_completion_from_positionJ   se     (C((X8K8K-Kq-PPP8&9&99:;LL++!33	5 	5r   )r   r   r   r   r   )r   NNN)r   
__module____qualname____firstlineno____doc__r   r    r%   r)   propertyr   r3   __static_attributes__ r   r   r   r      s?     KO"&(5W 
 
5r   r   c                   (    \ rS rSrSrSS jrS rSrg)r
   Z   a  
Event that called the completer.

:param text_inserted: When True, it means that completions are requested
    because of a text insert. (`Buffer.complete_while_typing`.)
:param completion_requested: When True, it means that the user explicitely
    pressed the `Tab` key in order to view the completions.

These two flags can be used for instance to implemented a completer that
shows some completions when ``Tab`` has been pressed, but not
automatically when the user presses a space. (Because of
`complete_while_typing`.)
c                 <    U(       a	  U(       a   eXl         X l        g r#   )text_insertedcompletion_requested)r   r?   r@   s      r   r   CompleteEvent.__init__h   s    !&:;; + %9!r   c                 n    U R                   R                  < SU R                  < SU R                  < S3$ )Nz(text_inserted=z, completion_requested=r   )r   r   r?   r@   r   s    r   r    CompleteEvent.__repr__q   s+    NN##T%7%79R9RT 	Tr   )r@   r?   N)FF)r   r5   r6   r7   r8   r   r    r:   r;   r   r   r
   r
   Z   s    9Tr   r
   c                   (    \ rS rSrSr\S 5       rSrg)r	   v   z+
Base class for completer implementations.
c              #      #    g7f)z
Yield :class:`.Completion` instances.

:param document: :class:`~prompt_toolkit.document.Document` instance.
:param complete_event: :class:`.CompleteEvent` instance.
Nr;   )r   documentcomplete_events      r   get_completionsCompleter.get_completionsz   s
      s   r;   N)r   r5   r6   r7   r8   r   rI   r:   r;   r   r   r	   r	   v   s      r   r	   c                    ^  U 4S jnU Vs/ s H  o2" U5      (       d  M  UPM     nn[        U5      [        U5      :w  a  gS n[        U Vs/ s H
  o5" U5      PM     sn5      $ s  snf s  snf )z/
Return the common prefix for all completions.
c                 n   > U R                   S U R                  *  nTR                  R                  U5      $ r#   )r   r   text_before_cursorendswith)
completionendrG   s     r   doesnt_change_before_cursor?get_common_complete_suffix.<locals>.doesnt_change_before_cursor   s4    oo9
 9 99:**33C88r   r-   c                 6    U R                   U R                  * S  $ r#   )r   r   )rO   s    r   
get_suffix.get_common_complete_suffix.<locals>.get_suffix   s    
 9 99:;;r   )len_commonprefix)rG   completionsrQ   ccompletions2rT   s   `     r   r   r      sm    
9  +M{!.I!.LA{LM <C,,< >A*Q->?? N ?s   A%A%A*c                     U (       d  g[        U 5      n[        U 5      n[        U5       H  u  p4XBU   :w  d  M  US U s  $    U$ r,   )minmax	enumerate)stringss1s2irY   s        r   rW   rW      sG     \\bMDAqEz"1v " 	r   N)r8   
__future__r   abcr   r   sixr   __all__objectr   r
   r	   r   rW   r;   r   r   <module>rh      sU    ' ' H5 H5VTF T8w/  @.r   