
    ^h/                       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
JrJrJrJrJrJrJrJrJrJr  S SKJrJrJrJr  S SKJrJrJrJr  S S	KJ r   S S
K!J"r"  S SK#J$r$  S SK%J&r&J'r'J(r(  S SK)J*r*J+r+J,r,J-r-J.r.  S SK/J0r0  S SK1J2r2  S SK3J4r4  S SK5J6r6  / SQr7\ r8 " S S\(5      r9 " S S5      r: " S S5      r; " S S5      r< " S S\.5      r= " S S5      r> " S S 5      r?g!)"    )annotations)Any)get_app)Buffer)SYSTEM_BUFFER)
	ConditionFilterOrBool
emacs_modehas_arghas_completions	has_focushas_validation_error	to_filtervi_modevi_navigation_mode)AnyFormattedTextStyleAndTextTuplesfragment_list_lento_formatted_text)ConditionalKeyBindingsKeyBindingsKeyBindingsBasemerge_key_bindings)KeyPressEvent)	InputMode)Keys)ConditionalContainer	ContainerWindow)BufferControlFormattedTextControlSearchBufferControl	UIContent	UIControl)	Dimension)BeforeInput)SimpleLexer)SearchDirection)
ArgToolbarCompletionsToolbarFormattedTextToolbarSearchToolbarSystemToolbarValidationToolbarc                  0   ^  \ rS rSrSSU 4S jjjrSrU =r$ )r+   <   c           	     H   > [         TU ]  [        U40 UD6US[        SS9S9  g )NT   )min)styledont_extend_heightheight)super__init__r!   r%   )selftextr4   kw	__class__s       Y/home/james-whalen/.local/lib/python3.13/site-packages/prompt_toolkit/widgets/toolbars.pyr8   FormattedTextToolbar.__init__=   s2     	 ,,##	 	 	
     ) )r:   r   r4   strr;   r   returnNone)__name__
__module____qualname____firstlineno__r8   __static_attributes____classcell__)r<   s   @r=   r+   r+   <   s    
 
r?   r+   c                  R    \ rS rSrSr  S	     S
S jjrSS jrSS jrSS jrSr	g)r-   H   zR
Toolbar for a system prompt.

:param prompt: Prompt to be displayed to the user.
c           	       ^  UT l         [        U5      T l        [        [        S9T l        T R                  5       T l        [        T R
                  [        SS9[        U 4S jSS9/T R                  S9T l        [        T R                  SSS9T l        [        T R                  [        T R
                  5      S	9T l        g )
N)nameclass:system-toolbar.textr4   c                    > T R                   $ N)promptr9   s   r=   <lambda>(SystemToolbar.__init__.<locals>.<lambda>_   s	    DKKr?   class:system-toolbar)bufferlexerinput_processorskey_bindingsr2   r6   r4   contentfilter)rS   r   enable_global_bindingsr   r   system_buffer_build_key_bindings	_bindingsr    r'   r&   buffer_controlr   windowr   r   	container)r9   rS   r`   s   `  r=   r8   SystemToolbar.__init__O   s    
 &/0F&G##7113+%%$?@/7MN 
 1G
 .KK	$2D2D(E
r?   c                8    SSU R                   R                  4S/$ )N)rW   Shell command: rO   )rA   
)ra   r:   rT   s    r=   _get_display_before_text&SystemToolbar._get_display_before_textl   s&    7($*<*<*A*AB
 	
r?   c                  ^  [        T R                  5      n[        5       nUR                  nU" SUS9U" SUS9U" SUS9SU 4S jj5       5       5       nU" SUS9SU 4S jj5       n[        5       nUR                  nU" SUS9U" SUS9SU 4S jj5       5       nU" SUS9SU 4S	 jj5       n[        5       n	U	R                  nU" [        R
                  S
U) [        -  SS9SU 4S jj5       n
U" S
U) [        -  [        -  SS9SU 4S jj5       n[        [        U[        5      [        U[        5      [        U	T R                  5      /5      $ )Nescape)r_   zc-gzc-cc                   > TR                   R                  5         U R                  R                  R	                  5         gzHide system prompt.N)ra   resetapplayout
focus_lasteventr9   s    r=   _cancel2SystemToolbar._build_key_bindings.<locals>._cancelz   s-    
 $$&II'')r?   enterc                  >#    U R                   R                  TR                  R                  TR	                  5       S9I Sh  vN   TR                  R                  SS9  U R                   R                  R                  5         g NB7fzRun system command.)display_before_textNT)append_to_history)rr   run_system_commandra   r:   rk   rq   rs   rt   ru   s    r=   _accept2SystemToolbar._build_key_bindings.<locals>._accept   sx      ))..""''$($A$A$C /    $$t$<II'')s   A BBABc                   > [         R                  U R                  R                  l        TR
                  R                  5         U R                  R                  R                  5         grp   )	r   
NAVIGATIONrr   vi_state
input_modera   rq   rs   rt   ru   s    r=   
_cancel_vi5SystemToolbar._build_key_bindings.<locals>._cancel_vi   sE     -6,@,@EII)$$&II'')r?   c                f  >#    [         R                  U R                  R                  l        U R                  R                  TR                  R                  TR                  5       S9I Sh  vN   TR                  R                  SS9  U R                  R                  R                  5         g NB7fr{   )r   r   rr   r   r   r~   ra   r:   rk   rq   rs   rt   ru   s    r=   
_accept_vi5SystemToolbar._build_key_bindings.<locals>._accept_vi   s      -6,@,@EII)))..""''$($A$A$C /    $$t$<II'')s   A)B1,B/-AB1!T)r_   	is_globalc                d   > U R                   R                  R                  TR                  5        g)z#M-'!' will focus this user control.N)rr   rs   focusre   ru   s    r=   	_focus_me4SystemToolbar._build_key_bindings.<locals>._focus_me   s!     II""4;;/r?   c                   > [         R                  U R                  R                  l        U R                  R
                  R                  TR                  5        g)zFocus.N)r   INSERTrr   r   r   rs   r   re   ru   s    r=   _focus_me_vi7SystemToolbar._build_key_bindings.<locals>._focus_me_vi   s9     -6,<,<EII)II""4;;/r?   )rv   ErC   rD   )r   ra   r   addr   Escaper
   r   r   r   r   r`   )r9   focusedemacs_bindingshandlerw   r   vi_bindingsr   r   global_bindingsr   r   s   `           r=   rb   !SystemToolbar._build_key_bindingss   sn   D../ %##		)	g	&	g	&	* 
' 
' 
*	*
 
	(	* 
)	* "m		)	g	&	* 
' 
*	* 
	(	* 
)	* &- $$	S'J)>$	O	0 
P	0 
WHw.1CCt	T	0 
U	0
 "&~zB&{G<&8S8ST
 	
r?   c                    U R                   $ rR   rf   rT   s    r=   __pt_container__SystemToolbar.__pt_container__       ~~r?   )rc   rd   rf   r`   rS   ra   re   N)ri   T)rS   r   r`   r	   rC   rD   rC   r   )rC   r   rC   r   )
rE   rF   rG   rH   __doc__r8   rk   rb   r   rI   r@   r?   r=   r-   r-   H   sA     $5/3
 
 !-
 
	
:
F
Pr?   r-   c                  (    \ rS rSrSS jrSS jrSrg)r)      c                x    SS jn[        [        U5      SS9U l        [        U R                  [        S9U l        g )Nc                 l    [        5       R                  R                  =(       d    Sn U S:X  a  Sn SSU 4/$ )NrA   -z-1)zclass:arg-toolbarzRepeat: zclass:arg-toolbar.text)r   key_processorarg)r   s    r=   get_formatted_text/ArgToolbar.__init__.<locals>.get_formatted_text   s=    )))--3Ccz 2)3/ r?   r2   r6   r]   r   )r   r!   re   r   r   rf   )r9   r   s     r=   r8   ArgToolbar.__init__   s0    	 12DEaP-dkk'Rr?   c                    U R                   $ rR   r   rT   s    r=   r   ArgToolbar.__pt_container__   r   r?   )rf   re   NrC   rD   r   rE   rF   rG   rH   r8   r   rI   r@   r?   r=   r)   r)      s    Sr?   r)   c                  V    \ rS rSrSr      S             SS jjrS	S jrSrg)
r,      zg
:param vi_mode: Display '/' and '?' instead of I-search.
:param ignore_case: Search case insensitive.
Nc                   ^ ^^^^^ Uc
  [        5       n[        SU 4S jj5       mSUUUU UU4S jjnUT l        [        U[	        USS9/[        SS9US9T l        [        [        T R                  SSS	9TS
9T l	        g )Nc                 Z   > T R                   [        5       R                  R                  ;   $ rR   )controlr   rs   search_linksrT   s   r=   is_searching,SearchToolbar.__init__.<locals>.is_searching   s     <<79#3#3#@#@@@r?   c                    > T" 5       (       d  T$ TR                   R                  R                  [        R                  :X  a  T(       a  S$ T $ T(       a  S$ T$ )N?/)r   searcher_search_state	directionr(   BACKWARD)backward_search_promptforward_search_promptr   r9   text_if_not_searchingr   s   r=   get_before_input0SearchToolbar.__init__.<locals>.get_before_input   sJ    >>,,22<<@X@XX%sA+AA%s@+@@r?   zclass:search-toolbar.promptrP   zclass:search-toolbar.text)rX   rZ   rY   ignore_caser2   zclass:search-toolbarr\   r]   )rC   bool)rC   r   )
r   r   search_bufferr"   r&   r'   r   r   r   rf   )	r9   r   r   r   r   r   r   r   r   s	   ` ````  @r=   r8   SearchToolbar.__init__   s      "HM		A 
	A	A 	A +* ,4QR $?@#
 .4<<9OP
r?   c                    U R                   $ rR   r   rT   s    r=   r   SearchToolbar.__pt_container__  r   r?   )rf   r   r   )NFrA   z
I-search: zI-search backward: F)r   zBuffer | Noner   r   r   r   r   r   r   r   r   r	   rC   rD   r   )rE   rF   rG   rH   r   r8   r   rI   r@   r?   r=   r,   r,      sj     (,242>3H$)(
$(
 (
  0	(

  0(
 !1(
 "(
 
(
Tr?   r,   c                      \ rS rSrSS jrSrg)_CompletionsToolbarControli  c                <  ^ / m[        5       R                  R                  nU(       Gab  UR                  nUR                  nUS-
  nSnSn/ n	[        U5       H|  u  p[        U	5      [        UR                  5      -   U:  a  X=(       d    S::  a  / n	SnOSn  O?U	R                  [        UR                  X:X  a  SOSS95        U	R                  S5        M~     U	R                  S	S
U[        U	5      -
  -  45        U	S U n	TR                  S5        TR                  SU(       a  SOS
45        TR                  S5        TR                  U	5        TR                  S5        TR                  SU(       a  SOS
45        TR                  S5        SU4S jjn[        USS9$ )N   Fr   Tz+class:completion-toolbar.completion.currentz#class:completion-toolbar.completionrP   )rA    rA   r   zclass:completion-toolbar.arrow<>c                   > T$ rR   r@   )iall_fragmentss    r=   get_line;_CompletionsToolbarControl.create_content.<locals>.get_lineE  s	      r?   r2   )r   
line_count)r   intrC   r   )r   current_buffercomplete_statecompletionscomplete_index	enumerater   lendisplay_textextendr   appendr#   )r9   widthr6   r   r   indexcontent_widthcut_left	cut_right	fragmentsr   cr   r   s                @r=   create_content)_CompletionsToolbarControl.create_content  s   ,. 11@@(44K"11E "AIM HI -/I!+.$Y/#ann2EEVZa($&	#' %)	  %  !z J!F	   +- /2 b#9J99U)U"VWX!.=1I   +  1(3L   +  +  +  1)3M   +	! (q99r?   r@   N)r   r   r6   r   rC   r#   )rE   rF   rG   rH   r   rI   r@   r?   r=   r   r     s    @:r?   r   c                  (    \ rS rSrSS jrSS jrSrg)r*   iK  c                L    [        [        [        5       SSS9[        S9U l        g )Nr2   zclass:completion-toolbarr\   r]   )r   r   r   r   rf   rT   s    r=   r8   CompletionsToolbar.__init__L  s&    -*,Q>X #	
r?   c                    U R                   $ rR   r   rT   s    r=   r   #CompletionsToolbar.__pt_container__T  r   r?   r   Nr   r   r   r@   r?   r=   r*   r*   K  s    
r?   r*   c                  ,    \ rS rSrSSS jjrSS jrSrg)	r.   iX  c                   ^ SU4S jjn[        U5      U l        [        [        U R                  SS9[        S9U l        g )Nc                 D  > [        5       R                  n U R                  (       ay  U R                  R	                  U R                  R
                  5      u  pT(       a&  U R                  R                   SUS-    SUS-    S3nOU R                  R                  nSU4/$ / $ )Nz (line=r2   z column=)zclass:validation-toolbar)r   r   validation_errordocumenttranslate_index_to_positioncursor_positionmessage)buffrowcolumnr:   show_positions       r=   r   6ValidationToolbar.__init__.<locals>.get_formatted_textZ  s    9++D$$"mmGG))99 !"33;;<GC!G9HU[^_U_T``abD0088D3T:;;	r?   r2   r   r]   r   )r!   r   r   r   r   rf   )r9   r   r   s    ` r=   r8   ValidationToolbar.__init__Y  s4    	" ,,>?-4<<2;O
r?   c                    U R                   $ rR   r   rT   s    r=   r   "ValidationToolbar.__pt_container__q  r   r?   )rf   r   N)F)r   r   rC   rD   r   r   r@   r?   r=   r.   r.   X  s    
0r?   r.   N)@
__future__r   typingr   "prompt_toolkit.application.currentr   prompt_toolkit.bufferr   prompt_toolkit.enumsr   prompt_toolkit.filtersr   r	   r
   r   r   r   r   r   r   r   prompt_toolkit.formatted_textr   r   r   r   'prompt_toolkit.key_binding.key_bindingsr   r   r   r   (prompt_toolkit.key_binding.key_processorr   #prompt_toolkit.key_binding.vi_stater   prompt_toolkit.keysr    prompt_toolkit.layout.containersr   r   r   prompt_toolkit.layout.controlsr    r!   r"   r#   r$   prompt_toolkit.layout.dimensionr%    prompt_toolkit.layout.processorsr&   prompt_toolkit.lexersr'   prompt_toolkit.searchr(   __all__r   r+   r-   r)   r,   r   r*   r.   r@   r?   r=   <module>r     s    "  6 ( .     C 9 $ T T  6 8 - 1 	
6 	
t tn (1 1hA: A:H
 
 r?   