
    ^h                        S r SSKJr  SSKrSSKJrJr  SSKJr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  SS
KJr  SSKJrJr  SSKJrJrJr  SSKJrJ r J!r!  SSK"J#r#J$r$  SSK%J&r&J'r'J(r(  SSK)J*r*  SSK+J,r,  SSK-J.r.  SSK/J0r0J1r1J2r2J3r3J4r4J5r5J6r6  \(       a  SSK7J8r8J9r9  SSK-J:r:  / SQr;\	\<\</\4   r= " S S\S9r> " S S5      r? " S S\>5      r@ " S S \>5      rA " S! S"\5      rB " S# S$\>5      rC " S% S&\C5      rDg)'z)
User interface Controls for the layout.
    )annotationsN)ABCMetaabstractmethod)TYPE_CHECKINGCallableHashableIterable
NamedTuple)get_app)Buffer)SimpleCache)Point)Document)FilterOrBool	to_filter)AnyFormattedTextStyleAndTextTuplesto_formatted_text)fragment_list_to_textfragment_list_widthsplit_lines)LexerSimpleLexer)MouseButton
MouseEventMouseEventType)SearchState)SelectionType)
get_cwidth   )DisplayMultipleCursors#HighlightIncrementalSearchProcessorHighlightSearchProcessorHighlightSelectionProcessor	ProcessorTransformationInputmerge_processors)KeyBindingsBaseNotImplementedOrNone)Event)BufferControlSearchBufferControlDummyControlFormattedTextControl	UIControl	UIContentc                      \ rS rSrSrSS jrSS jr          SS jrSS jr\	SS j5       r
SS jrSS	 jrSS
 jrSS jrSS jrSrg)r/   ?   z-
Base class for all user interface controls.
c                    g N selfs    X/home/james-whalen/.local/lib/python3.13/site-packages/prompt_toolkit/layout/controls.pyresetUIControl.resetD   s        c                    g r4   r5   r7   max_available_widths     r8   preferred_widthUIControl.preferred_widthH   s    r;   c                    g r4   r5   )r7   widthmax_available_height
wrap_linesget_line_prefixs        r8   preferred_heightUIControl.preferred_heightK   s     r;   c                    g)z.
Tell whether this user control is focusable.
Fr5   r6   s    r8   is_focusableUIControl.is_focusableT   s     r;   c                    g)zV
Generate the content for this user control.

Returns a :class:`.UIContent` instance.
Nr5   )r7   rB   heights      r8   create_contentUIControl.create_contentZ       r;   c                    [         $ )a  
Handle mouse events.

When `NotImplemented` is returned, it means that the given event is not
handled by the `UIControl` itself. The `Window` or key bindings can
decide to handle this event as scrolling or changing focus.

:param mouse_event: `MouseEvent` instance.
)NotImplemented)r7   mouse_events     r8   mouse_handlerUIControl.mouse_handlerb   s
     r;   c                    g)zl
Request to move the cursor down.
This happens when scrolling down and the cursor is completely at the
top.
Nr5   r6   s    r8   move_cursor_downUIControl.move_cursor_downn   rO   r;   c                    g)z 
Request to move the cursor up.
Nr5   r6   s    r8   move_cursor_upUIControl.move_cursor_upu   rO   r;   c                    g)z
The key bindings that are specific for this user control.

Return a :class:`.KeyBindings` object if some key bindings are
specified, or `None` otherwise.
Nr5   r6   s    r8   get_key_bindingsUIControl.get_key_bindingsz   rO   r;   c                    / $ )z
Return a list of `Event` objects. This can be a generator.
(The application collects all these events, in order to bind redraw
handlers to these events.)
r5   r6   s    r8   get_invalidate_eventsUIControl.get_invalidate_events   s	     	r;   r5   NreturnNoner>   intrb   
int | None
rB   re   rC   re   rD   boolrE   GetLinePrefixCallable | Nonerb   rf   rb   rh   rB   re   rL   re   rb   r0   rR   r   rb   r)   rb   KeyBindingsBase | Nonerb   zIterable[Event[object]])__name__
__module____qualname____firstlineno____doc__r9   r?   rF   rI   r   rM   rS   rV   rY   r\   r_   __static_attributes__r5   r;   r8   r/   r/   ?   sx     " 	
 6 
  

r;   r/   )	metaclassc                  p    \ rS rSrSrS SSSS4         SS jjrSS jr S         SS	 jjrS
rg)r0      a  
Content generated by a user control. This content consists of a list of
lines.

:param get_line: Callable that takes a line number and returns the current
    line. This is a list of (style_str, text) tuples.
:param line_count: The number of lines.
:param cursor_position: a :class:`.Point` for the cursor position.
:param menu_position: a :class:`.Point` for the menu position.
:param show_cursor: Make the cursor visible.
c                    / $ r4   r5   is    r8   <lambda>UIContent.<lambda>   s    2r;   r   NTc                r    Xl         X l        U=(       d
    [        SSS9U l        X@l        XPl        0 U l        g Nr   xy)get_line
line_countr   cursor_positionmenu_positionshow_cursor_line_heights_cache)r7   r   r   r   r   r   s         r8   __init__UIContent.__init__   s7     !$.A%!q/*& 9; r;   c                N    XR                   :  a  U R                  U5      $ [        e)z(Make it iterable (iterate line by line).)r   r   
IndexError)r7   linenos     r8   __getitem__UIContent.__getitem__   s!    OO#==((r;   c           
     F   [        5       R                  XU4n U R                  U   $ ! [         a    US:X  a  SnO[	        U R                  U5      5      SU n[        U5      nU(       aj  U[        [        U" US5      5      5      -  nSnX:  aD  US-  nX-  n[        U" XS-
  5      5      n	[        [	        U	5      5      n
X:  a  SnOEX-  nX:  a  MD  O9 [        X5      u  pU(       a  US-  n[        SU5      nO! [         a    Sn Of = fX`R                  U'   Us $ f = f)a  
Return the height that a given line would need if it is rendered in a
space with the given width (using line wrapping).

:param get_line_prefix: None or a `Window.get_line_prefix` callable
    that returns the prefix to be inserted before this line.
:param slice_stop: Wrap only "line[:slice_stop]" and return that
    partial result. This is needed for scrolling the window correctly
    when line wrapping.
:returns: The computed height.
r   i Nr    )r   render_counterr   KeyErrorr   r   r   r   r   divmodmaxZeroDivisionError)r7   r   rB   rE   
slice_stopkeyrL   line
text_width
fragments2prefix_widthquotient	remainders                r8   get_height_for_lineUIContent.get_height_for_line   sR   * i&&zA0	++C00 .	z -T]]6-BCKZP'-
""5)/&!*DE# J
 F %,!"+
%6+FQJ?&
 (22G
2S'T'0%*F!"2
 %, 2.4Z.G+ %$MH!$Q!1 - '!&' -3$$S)M].	s:   ( B)D D C;"D ;D
D 	D

D D )r   r   r   r   r   r   )
r   #Callable[[int], StyleAndTextTuples]r   re   r   Point | Noner   r   r   rh   )r   re   rb   r   r4   )
r   re   rB   re   rE   ri   r   rf   rb   re   )	rp   rq   rr   rs   rt   r   r   r   ru   r5   r;   r8   r0   r0      s    
 :F(,&* ;5; ; &	;
 $; ;" "&GG G 6	G
 G 
G Gr;   r0   c                      \ 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S jr	SS	 jr
          SS
 jrSS jrSS jrSS jrSS jrSrg)r.      a]  
Control that displays formatted text. This can be either plain text, an
:class:`~prompt_toolkit.formatted_text.HTML` object an
:class:`~prompt_toolkit.formatted_text.ANSI` object, a list of ``(style_str,
text)`` tuples or a callable that takes no argument and returns one of
those, depending on how you prefer to do the formatting. See
``prompt_toolkit.layout.formatted_text`` for more information.

(It's mostly optimized for rather small widgets, like toolbars, menus, etc...)

When this UI control has the focus, the cursor will be shown in the upper
left corner of this control by default. There are two ways for specifying
the cursor position:

- Pass a `get_cursor_position` function which returns a `Point` instance
  with the current cursor position.

- If the (formatted) text is passed as a list of ``(style, text)`` tuples
  and there is one that looks like ``('[SetCursorPosition]', '')``, then
  this will specify the cursor position.

Mouse support:

    The list of fragments can also contain tuples of three items, looking like:
    (style_str, text, handler). When mouse support is enabled and the user
    clicks on this fragment, then the given handler is called. That handler
    should accept two inputs: (Application, MouseEvent) and it should
    either handle the event or return `NotImplemented` in case we want the
    containing Window to handle this event.

:param focusable: `bool` or :class:`.Filter`: Tell whether this control is
    focusable.

:param text: Text or formatted text to be displayed.
:param style: Style string applied to the content. (If you want to style
    the whole :class:`~prompt_toolkit.layout.Window`, pass the style to the
    :class:`~prompt_toolkit.layout.Window` instead.)
:param key_bindings: a :class:`.KeyBindings` object.
:param get_cursor_position: A callable that returns the cursor position as
    a `Point` instance.
Nc                    Xl         X l        [        U5      U l        X@l        XPl        X`l        Xpl        [        SS9U l	        [        SS9U l
        S U l        g )N   maxsizer    )textstyler   	focusablekey_bindingsr   modalget_cursor_positionr   _content_cache_fragment_cache
_fragments)r7   r   r   r   r   r   r   r   s           r8   r   FormattedTextControl.__init__%  s_     	
"9- )&
#6  ALTV@WEPF
 6:r;   c                    S U l         g r4   )r   r6   s    r8   r9   FormattedTextControl.resetC  s	    r;   c                "    U R                  5       $ r4   r   r6   s    r8   rI   !FormattedTextControl.is_focusableF      ~~r;   c                P    U R                   R                   SU R                  < S3$ )N())	__class__rp   r   r6   s    r8   __repr__FormattedTextControl.__repr__I  s$    ..))*!DII=::r;   c                h   ^  T R                   R                  [        5       R                  U 4S j5      $ )z
Get fragments, but only retrieve fragments once during one render run.
(This function is called several times during one rendering, because
we also need those for calculating the dimensions.)
c                 D   > [        T R                  T R                  5      $ r4   )r   r   r   r6   s   r8   r|   AFormattedTextControl._get_formatted_text_cached.<locals>.<lambda>S  s    .?		4::.Vr;   )r   getr   r   r6   s   `r8   _get_formatted_text_cached/FormattedTextControl._get_formatted_text_cachedL  s,     ##''I$$&V
 	
r;   c                    [        U R                  5       5      nUR                  S5       Vs/ s H  n[        U5      PM     nn[	        U5      $ s  snf )zU
Return the preferred width for this control.
That is the width of the longest line.

)r   r   splitr   r   )r7   r>   r   lline_lengthss        r8   r?   $FormattedTextControl.preferred_widthV  sK    
 %T%D%D%FG/3zz$/?@/?!
1/?@<   As   Ac                    U R                  US5      nU(       a=  Sn[        UR                  5       H   nXeR                  XqU5      -  nXb:  d  M  Us  $    U$ UR                  $ )z/
Return the preferred height for this control.
Nr   )rM   ranger   r   )r7   rB   rC   rD   rE   contentrL   r{   s           r8   rF   %FormattedTextControl.preferred_height_  sg     %%eT2F7--.55aPP1// / M%%%r;   c           
       ^ ^	^
^^ T R                  5       n[        [        U5      5      nU VVs/ s H  nU Vs/ s H  ofS   US   4PM     snPM     snnm
UT l         S   SU
4S jjjmSU4S jjmT R                  =(       d    T" 5       m	[        U5      UT	4nS	U	U
UU 4S jjnT R                  R                  Xx5      $ s  snf s  snnf )
Nr   r    c                   > [        T5       H2  u  pSnU H%  tpEnX;   a  [        X1S9s  s  $ U[        U5      -  nM'     M4     g r   )	enumerater   len)fragmentr   r   r   	style_strr   _fragment_liness          r8   r   @FormattedTextControl.create_content.<locals>.get_cursor_position  sL     %^4+/'Ia,$q.TNA ,0 5 r;   c                    > T " S5      $ )Nz[SetMenuPosition]r5   )r   s   r8   get_menu_position>FormattedTextControl.create_content.<locals>.get_menu_position  s    &':;;r;   c                 V   > [        U4S j[        T5      TR                  T T" 5       S9$ )Nc                   > TU    $ r4   r5   )r{   r   s    r8   r|   JFormattedTextControl.create_content.<locals>.get_content.<locals>.<lambda>  s
    >!#4r;   )r   r   r   r   r   )r0   r   r   )r   r   r   r7   s   r8   get_content8FormattedTextControl.create_content.<locals>.get_content  s-    4~. ,, //1 r;   )z[SetCursorPosition])r   strrb   r   )rb   r   )rb   r0   )r   listr   r   r   tupler   r   )r7   rB   rL   fragments_with_mouse_handlers"fragment_lines_with_mouse_handlersr   itemr   r   r   r   r   r   s   `        @@@@r8   rM   #FormattedTextControl.create_contentt  s    (,(G(G(I%-156.
* ;4
: -11DD1gtAwD1:4
 8
 2						 			<  33J7JJM 23UOL	 	 ""&&s88O 24
s   
CCCCc                   U R                   (       a  [        [        U R                   5      5      n X!R                  R                     nUR                  R
                  nSnU H>  nU[        US   5      -  nXT:  d  M  [        U5      S:  a  US   nU" U5      s  $   [        $     [        $ [        $ ! [         a	    [        s $ f = f)a  
Handle mouse events.

(When the fragment list contained mouse handlers and the user clicked on
on any of these, the matching handler is called. This handler can still
return `NotImplemented` in case we want the
:class:`~prompt_toolkit.layout.Window` to handle this particular
event.)
r   r          )	r   r   r   positionr   r   r   r   rQ   )r7   rR   fragments_for_line	fragmentsxposcountr   handlers           r8   rS   "FormattedTextControl.mouse_handler  s     ??!%k$//&B!C"./C/C/E/EF	
 #++-- %DSa\)E|t9> '+1gG#*;#77!  & ~+  &%%&s   B2 2CCc                    U R                   $ r4   )r   r6   s    r8   is_modalFormattedTextControl.is_modal  s    zzr;   c                    U R                   $ r4   r   r6   s    r8   r\   %FormattedTextControl.get_key_bindings  s       r;   )
r   r   r   r   r   r   r   r   r   r   ) r   FNTFN)r   r   r   r   r   r   r   rn   r   rh   r   rh   r   z!Callable[[], Point | None] | Nonerb   rc   ra   rj   rb   r   )rb   r   )r>   re   rb   re   rg   )rB   re   rL   rf   rb   r0   rl   rm   )rp   rq   rr   rs   rt   r   r9   rI   r   r   r?   rF   rM   rS   r   r\   ru   r5   r;   r8   r.   r.      s    (X "$"'/3 AE:: :  	:
 -: : : ?: 
:< ;
!&& "& 	&
 6& 
&*09d%N!r;   r.   c                  ,    \ rS rSrSrSS jrSS jrSrg)	r-   i  z
A dummy control object that doesn't paint any content.

Useful for filling a :class:`~prompt_toolkit.layout.Window`. (The
`fragment` and `char` attributes of the `Window` class can be used to
define the filling.)
c                &    SS jn[        USS-  S9$ )Nc                    / $ r4   r5   rz   s    r8   r   -DummyControl.create_content.<locals>.get_line  s    Ir;   d   )r   r   r{   re   rb   r   )r0   )r7   rB   rL   r   s       r8   rM   DummyControl.create_content  s    	 (sCx@@r;   c                    g)NFr5   r6   s    r8   rI   DummyControl.is_focusable  s    r;   r5   Nrk   rj   )rp   rq   rr   rs   rt   rM   rI   ru   r5   r;   r8   r-   r-     s    Ar;   r-   c                  4    \ rS rSr% S\S'   S\S'   S\S'   Srg)	_ProcessedLinei  r   r   zCallable[[int], int]source_to_displaydisplay_to_sourcer5   N)rp   rq   rr   rs   __annotations__ru   r5   r;   r8   r  r    s    !!++++r;   r  c                  T   \ rS rSrSr          S                   SS jjrSS jr\SS j5       r\SS j5       r	\SS j5       r
SS	 jrSS
 jr          SS jr    SS jr        SS jr S        S!S jjrS"S jrS#S jrS#S jrS$S jrS%S jrSrg)&r+   i  a  
Control for visualizing the content of a :class:`.Buffer`.

:param buffer: The :class:`.Buffer` object to be displayed.
:param input_processors: A list of
    :class:`~prompt_toolkit.layout.processors.Processor` objects.
:param include_default_input_processors: When True, include the default
    processors for highlighting of selection, search and displaying of
    multiple cursors.
:param lexer: :class:`.Lexer` instance for syntax highlighting.
:param preview_search: `bool` or :class:`.Filter`: Show search while
    typing. When this is `True`, probably you want to add a
    ``HighlightIncrementalSearchProcessor`` as well. Otherwise only the
    cursor position will move, but the text won't be highlighted.
:param focusable: `bool` or :class:`.Filter`: Tell whether this control is focusable.
:param focus_on_click: Focus this buffer when it's click, but not yet focused.
:param key_bindings: a :class:`.KeyBindings` object.
Nc                   X l         X0l        [        5       [        5       [	        5       [        5       /U l        [        U5      U l        [        U5      U l	        [        U	5      U l
        U=(       d
    [        5       U l        Xl        U=(       d
    [        5       U l        Xl        Xpl        [%        SS9U l        S U l        S U l        g )N   r   )input_processors include_default_input_processorsr#   r"   r$   r!   default_input_processorsr   preview_searchr   focus_on_clickr   bufferr   r   lexerr   _search_buffer_controlr   r   _last_click_timestamp_last_get_processed_line)r7   r  r	  r
  r  r  r   search_buffer_controlr   r  r   s              r8   r   BufferControl.__init__  s     !10P- %&/1')"$	)
% (7"9-'7(*+km
(&;# " 	 48"PT%r;   c                l    SU R                   R                   SU R                  < S[        U 5      < S3$ )N<z buffer=z at >)r   rp   r  idr6   s    r8   r   BufferControl.__repr__/  s1    4>>**+8DKK?$r$xlRSTTr;   c                    [        U R                  5      (       a  U R                  5       nOU R                  nUb  [        U[        5      (       d   eU$ r4   )callabler  
isinstancer,   )r7   results     r8   r  #BufferControl.search_buffer_control2  sK     D//00002F00F~F4G!H!HHHr;   c                :    U R                   nUb  UR                  $ g r4   )r  r  )r7   controls     r8   search_bufferBufferControl.search_buffer>  s     ,,>>!r;   c                T    U R                   nU(       a  UR                  $ [        5       $ )z
Return the `SearchState` for searching this `BufferControl`. This is
always associated with the search control. If one search bar is used
for searching multiple `BufferControls`, then they share the same
`SearchState`.
)r  searcher_search_stater   )r7   r  s     r8   search_stateBufferControl.search_stateE  s'     !% : : (>>>= r;   c                "    U R                  5       $ r4   r   r6   s    r8   rI   BufferControl.is_focusableS  r   r;   c                    g)a  
This should return the preferred width.

Note: We don't specify a preferred width according to the content,
      because it would be too expensive. Calculating the preferred
      width can be done by calculating the longest line, but this would
      require applying all the processors to each line. This is
      unfeasible for a larger document, and doing it for small
      documents only would result in inconsistent behavior.
Nr5   r=   s     r8   r?   BufferControl.preferred_widthV  s     r;   c                    SnU R                  USS9nU(       d  UR                  $ UR                  U:  a  U$ [        UR                  5       H   nXVR                  XqU5      -  nXR:  d  M  Us  $    U$ )Nr   r    )rL   )rM   r   r   r   )r7   rB   rC   rD   rE   rL   r   r{   s           r8   rF   BufferControl.preferred_heightc  s     %%eA%6 %%% !55''w))*A11!OLLF-++	 + r;   c                   ^ ^ SUU 4S jjnTR                   T R                  R                  5       4nT R                  R	                  X25      $ )z@
Create a function that returns the fragments for a given line.
c                 :   > TR                   R                  T 5      $ r4   )r  lex_document)documentr7   s   r8   get_formatted_text_for_lineTBufferControl._get_formatted_text_for_line_func.<locals>.get_formatted_text_for_line  s    ::**844r;   )rb   r   )r   r  invalidation_hashr   r   )r7   r0  r1  r   s   ``  r8   !_get_formatted_text_for_line_func/BufferControl._get_formatted_text_for_line_func  sA    	5 	5 }}djj::<=##''IIr;   c                   ^ ^^^^^ T R                   =(       d    / nT R                  (       a  T R                  U-   n[        U5      m        SUUUU U4S jjmSUU U4S jjnU" 5       $ )z
Create a function that takes a line number of the current document and
returns a _ProcessedLine(processed_fragments, source_to_display, display_to_source)
tuple.
c                   > SS jnTR                  [        TTU UUT	TU5      5      n[        UR                  UR                  UR
                  5      $ )z0Transform the fragments for a given line number.c                    U $ )zX position from the buffer to the x position in the
processed fragment list. By default, we start from the 'identity'
operation.r5   rz   s    r8   r  [BufferControl._create_get_processed_line_func.<locals>.transform.<locals>.source_to_display  s	     r;   )r{   re   rb   re   )apply_transformationr&   r  r   r  r  )
r   r   r   r  transformationr0  rL   merged_processorr7   rB   s
        r8   	transform@BufferControl._create_get_processed_line_func.<locals>.transform  sd     .BB#%	N "((0000 r;   c                 F   >^^ TR                  T5      m0 mSUUU4S jjn U $ )Nc                ^   >  TU    $ ! [          a    T" U T" U 5      T5      nUTU '   Us $ f = fr4   )r   )r{   processed_linecacher   r=  s     r8   get_processed_line^BufferControl._create_get_processed_line_func.<locals>.create_func.<locals>.get_processed_line  sA    * 8O *%.q(1+x%HN-E!H))*s    !,,)r{   re   rb   r  )r4  )rC  rB  r   r0  r7   r=  s    @@r8   create_funcBBufferControl._create_get_processed_line_func.<locals>.create_func  s*    ==hGH/1E* * &%r;   )r   re   r   r   r   r   rb   r  )rb   Callable[[int], _ProcessedLine])r	  r
  r  r'   )r7   r0  rB   rL   r	  rE  r<  r=  s   ````  @@r8   _create_get_processed_line_func-BufferControl._create_get_processed_line_func  s      006B00#<<?OO+,<=		)	 :	 		 	B	& 	& }r;   c                  ^ U R                   nUR                  5         U R                  nU=(       dg    [        U R	                  5       =(       aG    U=(       a>    UR                   R
                  =(       a!    [        5       R                  R                  U :H  5      nU(       aR  UbO  U R                  nUR                  [        UR                   R
                  UR                  UR                  S95      nOUR                  nU R                  XU5      mTU l        SU4S jjn	SU4S jjn
[#        U
UR$                  U	" UR&                  UR(                  5      S9n[        5       R                  R*                  U :X  a  U R,                  (       a  U R-                  5       OSnUbC  [/        U[0        5      (       d   eUR                  R3                  U5      u  pU	" X5      Ul        U$ UR4                  (       a^  UR                  R3                  [7        UR8                  UR4                  R:                  R8                  5      5      u  pU	" X5      Ul        U$ SUl        U$ )z
Create a UIContent.
N)r   	directionignore_casec                B   > [        T" U 5      R                  U5      U S9$ )z.Return the content column for this coordinate.r   )r   r  )rowcolrC  s     r8   translate_rowcol6BufferControl.create_content.<locals>.translate_rowcol  s!    -c2DDSISQQr;   c                8   > T" U 5      R                   nUS/-   nU$ )z-Return the fragments for a given line number.)r    )r   )r{   r   rC  s     r8   r   .BufferControl.create_content.<locals>.get_line  s'    *1-77I "YK/Ir;   )r   r   r   )rN  re   rO  re   rb   r   r   )r  load_history_if_not_yet_loadedr  rh   r  r   r   layoutsearch_target_buffer_controlr%  document_for_searchr   rK  rL  r0  rH  r  r0   r   cursor_position_rowcursor_position_colcurrent_controlr   r  re   translate_index_to_positioncomplete_stateminr   original_document)r7   rB   rL   r  r  search_controlpreview_nowssr0  rP  r   r   r   menu_rowmenu_colrC  s                  @r8   rM   BufferControl.create_content  s     	--/ 33$ 
! B B %%**	B I99TA)
 >5""B11'..33 ll "H H!AAV
 );%	R
	 **,,,h.J.J
 9++t3484F4FD..0DM(!-5555%+__%P%P!&" )9(L%" ! && &,__%P%P..--??OO&" )9(L%  )-%r;   c                   U R                   nUR                  n[        5       R                  R                  U :X  Ga^  U R
                  (       GaJ  U R                  UR                  5      nUR                  UR                  5      nUR                  R                  UR                  U5      nUR                  [        R                  :X  a  UR                  5         Xbl        gUR                  [        R                   :X  ak  UR"                  [$        R&                  :w  aM  UR(                  c9  [+        UR                  U-
  5      S:  a  UR-                  [.        R0                  S9  Xbl        gUR                  [        R2                  :X  Ga  [+        UR                  U-
  5      S:  a0  UR(                  c  UR-                  [.        R0                  S9  Xbl        U R4                  =(       a%    [6        R6                  " 5       U R4                  -
  S:  n[6        R6                  " 5       U l        U(       ae  UR                  R9                  5       u  pU=R                  U-  sl        UR-                  [.        R0                  S9  U=R                  X-
  -  sl        g[:        $  gU R=                  5       (       a8  UR                  [        R2                  :X  a  U [        5       R                  l        g[:        $ )z!
Mouse handler for this control.
Nr   )selection_typer    g333333?)r  r   r   rV  r[  r  r   r  r   r0  translate_row_col_to_index
event_typer   
MOUSE_DOWNexit_selectionr   
MOUSE_MOVEbuttonr   NONEselection_stateabsstart_selectionr   
CHARACTERSMOUSE_UPr  timefind_boundaries_of_current_wordrQ   r  )
r7   rR   r  r   rA  r   indexdouble_clickstartends
             r8   rS   BufferControl.mouse_handler8  sq    '' 9++t3,,,!%!>!>xzz!J &77

CBB8::tT ))^-F-FF))+-2*r m  **n.G.GG#**k.>.>> ..6 6 6 >?!C..m>V>V.W-2*Z W !++~/F/FF 611E9:Q>!119"22/</G/G 3  27.
 22 K IIK$*D*DDsJ ! 26D.#%+__%T%T%V
..%7...m>V>V.W..#+=.$  *)k -H  ##%%**n.E.EE
 48	  0  &%r;   c                v    U R                   nU=R                  UR                  R                  5       -  sl        g r4   )r  r   r0  get_cursor_down_positionr7   bs     r8   rV   BufferControl.move_cursor_down  s)    KK	QZZ@@BBr;   c                v    U R                   nU=R                  UR                  R                  5       -  sl        g r4   )r  r   r0  get_cursor_up_positionr}  s     r8   rY   BufferControl.move_cursor_up  s)    KK	QZZ>>@@r;   c                    U R                   $ )z7
When additional key bindings are given. Return these.
r   r6   s    r8   r\   BufferControl.get_key_bindings  s        r;   c              #     #    U R                   R                  v   U R                   R                  v   U R                   R                  v   U R                   R                  v   g7f)z&
Return the Window invalidate events.
N)r  on_text_changedon_cursor_position_changedon_completions_changedon_suggestion_setr6   s    r8   r_   #BufferControl.get_invalidate_events  sG     
 kk)))kk444kk000kk+++s   A"A$)r   r  r  r  r  r  r  r   r
  r	  r   r  r   r  )
NNTNFTNNFN)r  Buffer | Noner	  list[Processor] | Noner
  rh   r  Lexer | Noner  r   r   r   r  z>None | SearchBufferControl | Callable[[], SearchBufferControl]r   zCallable[[], int | None] | Noner  r   r   rn   r   )rb   zSearchBufferControl | None)rb   r  )rb   r   rj   rd   rg   )r0  r   rb   r   )r0  r   rB   re   rL   re   rb   rG  )F)rB   re   rL   re   r  rh   rb   r0   rl   ra   rm   ro   )rp   rq   rr   rs   rt   r   r   propertyr  r!  r%  rI   r?   rF   r4  rH  rM   rS   rV   rY   r\   r_   ru   r5   r;   r8   r+   r+     s   * !%3715"',"& 9=',/3,U,U 1,U +/	,U
 ,U %,U  ,U K,U 7,U %,U -,U\U 	 	   ! !  " 	
 6 
<J J	,J> >),>69>	(>B ?Dgg"%g7;g	gRM^CA!	,r;   r+   c                  V   ^  \ rS rSrSr      S           SU 4S jjjrSrU =r$ )r,   i  z
:class:`.BufferControl` which is used for searching another
:class:`.BufferControl`.

:param ignore_case: Search case insensitive.
c                D   > [         TU ]  UUUUUS9  [        US9U l        g )N)r  r	  r  r  r   )rL  )superr   r   r$  )r7   r  r	  r  r  r   rL  r   s          r8   r   SearchBufferControl.__init__  s5     	-)% 	 	
 &1[%I"r;   )r$  )NNNFNF)r  r  r	  r  r  r  r  r   r   rn   rL  r   )rp   rq   rr   rs   rt   r   ru   __classcell__)r   s   @r8   r,   r,     sh     !%37"',/3$)JJ 1J 	J
 %J -J "J Jr;   r,   )Ert   
__future__r   rt  abcr   r   typingr   r   r   r	   r
   "prompt_toolkit.application.currentr   prompt_toolkit.bufferr   prompt_toolkit.cacher   prompt_toolkit.data_structuresr   prompt_toolkit.documentr   prompt_toolkit.filtersr   r   prompt_toolkit.formatted_textr   r   r   #prompt_toolkit.formatted_text.utilsr   r   r   prompt_toolkit.lexersr   r   prompt_toolkit.mouse_eventsr   r   r   prompt_toolkit.searchr   prompt_toolkit.selectionr   prompt_toolkit.utilsr   
processorsr!   r"   r#   r$   r%   r&   r'   'prompt_toolkit.key_binding.key_bindingsr(   r)   r*   __all__re   GetLinePrefixCallabler/   r0   r.   r-   r  r+   r,   r5   r;   r8   <module>r     s    #  ' J J 6 ( , 0 , : 
 
 5 O O - 2 +    + !#s-=!=> I' IXl l^W!9 W!t9 &,Z ,q,I q,hJ- Jr;   