
    <h                        S r SSKrSSKJr  SSKJrJrJr  SSKJrJ	r	  SSK
Jr  SSK
Jr  SSKJr  SS	KJr  SSKJr  SSKrSSKrSSKr\" 5       rS
\S\4S jrS
\S\S\S\4S jrS
\S\S\4S jrS r " S S\5      r " S S\5      r g)zfprompt-toolkit utilities

Everything in this module is a private API,
not to be used outside IPython.
    N)wcwidth)provisionalcompletercursor_to_position_deduplicate_completions)	Completer
Completion)Lexer)PygmentsLexer)patch_stdout)get_ipythonstringreturnc                &   U R                  SS5      n U R                  SS5      n [        U 5      U:  a  U $ U R                  S5      nU R                  [        R                  5      nUS   S:X  a  UR                  5         [        U5      S:  a&  S	R                  US
   US   SS US   SS US   5      $ [        U5      S:  aN  S[        R                  -   S-   [        R                  -   S-   R                  US
   US   SS US   SS US   5      $ U $ )ao  
If a string is long enough, and has at least 3 dots,
replace the middle part with ellipses.

If a string naming a file is long enough, and has at least 3 slashes,
replace the middle part with ellipses.

If three consecutive dots, or two consecutive dots are encountered these are
replaced by the equivalents HORIZONTAL ELLIPSIS or TWO DOT LEADER unicode
equivalents
z...   …z..u   ‥.    u   {}.{}…{}.{}r      Nz{}u   {}…{})replacelensplitosseppopformat)r   	min_elideobject_parts
file_partss       kC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\IPython/terminal/ptutils.py_elide_pointr"      s$    ^^E";<F^^D!56F
6{Y<<$Lbff%J"~
<1299OOBQRS!	
 	
 
Z1	rvv ==FMUUqM:a=!,jnRS.A:b>
 	
 M    typedr   c                    [        U 5      U:  a  U $ [        U5      S-
  nUS:  a  U $ U R                  U5      (       a$  [        U 5      [        U5      :  a  U SS  SXS  3$ U $ )zL
Elide the middle of a long string if the beginning has already been typed.
r      Nr   )r   
startswith)r   r$   r   cut_how_muchs       r!   _elide_typedr)   E   sr    
 6{Yu:a<LaCKU$;!*4VM5J4KLLMr#   c                 $    [        [        XS9XS9$ )Nr   )r)   r"   )r   r$   r   s      r!   _elider,   T   s    V1$ $r#   c                 j    U R                  S5      (       a  [        U5      U:  a  X   S:X  a  U S S $ U $ )N=r   )endswithr   )textbodyoffsets      r!   (_adjust_completion_text_based_on_contextr3   [   s6    }}Sc$i&0T\S5HCRyr#   c                   >    \ rS rSrSrS	S jr\S 5       rS rS r	Sr
g)
IPythonPTCompleterb   z8Adaptor to provide IPython completions to prompt_toolkitNc                 >    Uc  Uc  [        S5      eXl        X l        g )Nz/Please pass shell=an InteractiveShell instance.)	TypeError_ipy_completershell)selfipy_completerr:   s      r!   __init__IPythonPTCompleter.__init__d   s#    =]2MNN+
r#   c                 h    U R                   (       a  U R                   $ U R                  R                  $ )N)r9   r:   r   )r;   s    r!   r<    IPythonPTCompleter.ipy_completerj   s'    &&&::'''r#   c              #   n  #    UR                   R                  5       (       d  g [        5          [        5          UR                  nUR
                  nUR                  nUR                  n[        X4U5      n U R                  X7X`R                  5       S h  vN   S S S 5        S S S 5        g  N! [         aY  n [        R                  " 5       u  pn[        R                  " XU5         S nANR! [          a    [#        S5          S nANmf = fS nAff = f! , (       d  f       N= f! , (       d  f       g = f7f)Nz"Unrecoverable Error in completions)current_linestripr   r   r0   cursor_position_rowcursor_position_colcursor_positionr   _get_completionsr<   	Exceptionsysexc_info	tracebackprint_exceptionAttributeErrorprint)r;   documentcomplete_eventr1   
cursor_row
cursor_colrF   r2   eexc_type	exc_valueexc_tbs               r!   get_completions"IPythonPTCompleter.get_completionsq   s     $$**,,
 ^13==D!55J!55J&66O'*EF@00PbPbccc 4^^ d @@25,,./H--h6JJ% @>??@	@ 43^^s   +D5D$=D6B-B+B-D$"	D5+B--
D8/C,'D,D	DDD	DDD
D!	D$$
D2.D5c              #     #    [        USS5      n[        XR                  X5      5      nU GH  nUR                  (       d  M  [        R
                  " SUR                  5      n[        US   5      S:X  ak  X7R                  -   S:  aY  XR                  S-
     n	[        R
                  " SX-   5      n
[        USS 5      S:X  a  [        XR                  U-
  S-
  S9v   M  UR                  n[        UR                  X5      nU R                  c  SOU R                  R                  nUR                  S	:X  aW  [        UUR                  U-
  [        US
-   XR                  UR                   US9UR                  UR                  -   S9v   GMc  [        UUR                  U-
  [        UXR                  UR                   US9UR                  S9v   GM     g7f)zD
Private equivalent of get_completions() use only for unit_testing.
debugFNFCr   r   )start_positionN   functionz()r+   )r\   displaydisplay_meta)getattrr   completionsr0   unicodedata	normalizer   startr   r3   r:   r   typer,   end	signature)r;   r1   r2   rF   ipycrZ   rb   cr0   char_before
fixed_textdisplay_textadjusted_textr   s                 r!   rG   #IPythonPTCompleter._get_completions   s     gu-.""402A66((7D
 tAw1$"WW,q0"&ww{"3K!,!6!6{1"3J tAay)Q.(GGfDTWXDXYY  66LDM #jj0djj6J6JIvv# !#$77V#3"$t+WWquu-"+
 "#!++!5	 	 !!#$77V#3"$WWquu-"+
 "#	 	W s   GG)r9   r:   )NN)__name__
__module____qualname____firstlineno____doc__r=   propertyr<   rW   rG   __static_attributes__ r#   r!   r5   r5   b   s)    B ( (@,;r#   r5   c                   $    \ rS rSrSrS rS rSrg)IPythonPTLexer   z+
Wrapper around PythonLexer and BashLexer.
c           	         [         n[        UR                  5      U l        [        UR                  5      U l        [        UR                  5      [        UR                  5      [        UR                  5      [        UR                  5      [        UR                  5      [        UR                  5      [        UR                  5      S.U l        g )N)HTMLhtml
javascriptjsperlrubylatex)pygments_lexersr
   Python3Lexerpython_lexer	BashLexershell_lexer	HtmlLexerJavascriptLexer	PerlLexer	RubyLexerTexLexermagic_lexers)r;   ls     r!   r=   IPythonPTLexer.__init__   s    )!..9(5 "!++.!!++.'(9(9: 1 12!!++.!!++."1::.
r#   c                    UR                   R                  5       nU R                  nUR                  S5      (       d  UR                  S5      (       a  U R                  nOVUR                  S5      (       a@  U R
                  R                  5        H"  u  pEUR                  SU-   5      (       d  M   Un  O   UR                  U5      $ )N!z%%bashz%%)r0   lstripr   r'   r   r   itemslex_document)r;   rO   r0   lexermagicr   s         r!   r   IPythonPTLexer.lex_document   s    }}##%!!??34??8#<#<$$E__T"" --335??4%<00E 6
 !!(++r#   )r   r   r   N)rp   rq   rr   rs   rt   r=   r   rv   rw   r#   r!   ry   ry      s    
,r#   ry   )!rt   rc   r   IPython.core.completerr   r   r   prompt_toolkit.completionr   r   prompt_toolkit.lexersr	   r
   prompt_toolkit.patch_stdoutr   IPython.core.getipythonr   pygments.lexerslexersr   r   rI   rK   object_completion_sentinelstrr"   intr)   r,   r3   r5   ry   rw   r#   r!   <module>r      s       < ' / 4 / * 	 
 x # #s #L S   $3 $s $# $` `F!,U !,r#   