
    QfG                    D	   U d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 ddl
mZ ddlmZmZ ddlmZmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZ dgZeegdf         Zeeef         Z ede          Z eZ!i Z"de#d<   ddZ$ddZ% e$d          dd            Z& e$d           dd!            Z' e$d"          dd#            Z( e$d$          dd%            Z) e$d&          dd'            Z* e$d(          dd)            Z+ e$d*          dd+            Z, e$d,          dd-            Z- e$d.          dd/            Z. e$d0          dd1            Z/ e$d2          dd3            Z0 e$d4          dd5            Z1 e$d6          dd7            Z2 e$d8          dd9            Z3 e$d:          dd;            Z4 e$d<          dd=            Z5 e$d>          dd?            Z6 e$d@          ddA            Z7 e$dB          ddC            Z8 e$dD          ddE            Z9 e$dF          ddG            Z: e$dH          ddI            Z; e$dJ          ddK            Z< e$dL          ddM            Z= e$dN          ddO            Z> e$dP          ddQ            Z? e$dR          ddS            Z@ e$dT          dddX            ZA e$dY          ddZ            ZB e$d[          dd\            ZC e$d]          dd^            ZD e$d_          dd`            ZE e$da          ddb            ZF e$dc          ddd            ZG e$de          ddf            ZH e$dg          ddh            ZI e$di          ddj            ZJ e$dk          ddl            ZK e$dm          ddn            ZL e$do          ddp            ZM e$dq           edrs          ddt                        ZN e$du          ddv            ZO e$dw          ddx            ZP e$dy          ddz            ZQ e$d{          dd|            ZR e$d}          dd~            ZS e$d          dd            ZT e$d          dd            ZU e$d          dd            ZVdS )z
Key bindings which are also known by GNU Readline by the given names.

See: http://www.delorie.com/gnu/docs/readline/rlman_13.html
    )annotations)CallableTypeVarUnioncast)Document)EditingMode)Bindingkey_binding)KeyPressKeyPressEvent)Keys)BufferControl)SearchDirection)	PasteMode   )!display_completions_like_readlinegenerate_completionsget_by_nameN_T)boundzdict[str, Binding]_readline_commandsnamestrreturnCallable[[_T], _T]c                     d fd}|S )z?
    Store handler in the `_readline_commands` dictionary.
    handlerr   r   c                    t          | t                    r| t          <   n2 t                      t	          t
          |                     t          <   | S )z#`handler` is a callable or Binding.)
isinstancer
   r   r   r   _Handler)r   r   s    d/var/www/html/env/lib/python3.11/site-packages/prompt_toolkit/key_binding/bindings/named_commands.py	decoratorzregister.<locals>.decorator+   sL    gw'' 	N'.t$$'4{}}T(G5L5L'M'Mt$    )r   r   r   r    )r   r#   s   ` r"   registerr&   &   s)    
      r$   r
   c                h    	 t           |          S # t          $ r}t          d|           |d}~ww xY w)zL
    Return the handler for the (Readline) command with the given name.
    zUnknown Readline command: N)r   KeyError)r   es     r"   r   r   7   sO    E!$'' E E E<D<<==1DEs    
1,1zbeginning-of-buffereventENonec                "    | j         }d|_        dS )z*
    Move to the start of the buffer.
    r   N)current_buffercursor_positionr*   buffs     r"   beginning_of_bufferr2   G   s    
 DDr$   zend-of-bufferc                F    | j         }t          |j                  |_        dS )z(
    Move to the end of the buffer.
    N)r.   lentextr/   r0   s     r"   end_of_bufferr6   P   s"    
 Dty>>Dr$   zbeginning-of-linec                f    | j         }|xj        |j                            d          z  c_        dS )z0
    Move to the start of the current line.
    F)after_whitespaceN)r.   r/   documentget_start_of_line_positionr0   s     r"   beginning_of_liner;   Y   sC    
 DDMDD E   r$   zend-of-linec                b    | j         }|xj        |j                                        z  c_        dS )z&
    Move to the end of the line.
    N)r.   r/   r9   get_end_of_line_positionr0   s     r"   end_of_liner>   d   s4    
 DDMBBDDDr$   zforward-charc                p    | j         }|xj        |j                            | j                  z  c_        dS )z#
    Move forward a character.
    countN)r.   r/   r9   get_cursor_right_positionargr0   s     r"   forward_charrD   m   s;    
 DDMCC%)CTTTr$   zbackward-charc                p    | j         }|xj        |j                            | j                  z  c_        dS )zMove back a character.r@   N)r.   r/   r9   get_cursor_left_positionrC   r0   s     r"   backward_charrG   v   s;     DDMBBBSSSr$   zforward-wordc                |    | j         }|j                            | j                  }|r|xj        |z  c_        dS dS )za
    Move forward to the end of the next word. Words are composed of letters and
    digits.
    r@   N)r.   r9   find_next_word_endingrC   r/   r*   r1   poss      r"   forward_wordrL   }   sR     D
-
-
-EI
-
>
>C
 $#$ $r$   zbackward-wordc                |    | j         }|j                            | j                  }|r|xj        |z  c_        dS dS )zo
    Move back to the start of the current or previous word. Words are composed
    of letters and digits.
    r@   N)r.   r9   find_previous_word_beginningrC   r/   rJ   s      r"   backward_wordrO      sR     D
-
4
459
4
E
EC
 $#$ $r$   zclear-screenc                B    | j         j                                         dS )zJ
    Clear the screen and redraw everything at the top of the screen.
    N)apprendererclearr*   s    r"   clear_screenrU      s!    
 
Ir$   zredraw-current-linec                    dS )zl
    Refresh the current line.
    (Readline defines this command, but prompt-toolkit doesn't have it.)
    Nr%   rT   s    r"   redraw_current_linerW      s	     	Dr$   zaccept-linec                8    | j                                          dS )z<
    Accept the line regardless of where the cursor is.
    N)r.   validate_and_handlerT   s    r"   accept_linerZ      s    
 
,,.....r$   zprevious-historyc                F    | j                             | j                   dS )zN
    Move `back` through the history list, fetching the previous command.
    r@   N)r.   history_backwardrC   rT   s    r"   previous_historyr]      s&    
 
))	):::::r$   znext-historyc                F    | j                             | j                   dS )zM
    Move `forward` through the history list, fetching the next command.
    r@   N)r.   history_forwardrC   rT   s    r"   next_historyr`      s&    
 
((uy(99999r$   zbeginning-of-historyc                :    | j                             d           dS )z0
    Move to the first line in the history.
    r   N)r.   go_to_historyrT   s    r"   beginning_of_historyrc      s!    
 
&&q)))))r$   zend-of-historyc                    | j                             ddz             | j         }|                    t          |j                  dz
             dS )zW
    Move to the end of the input history, i.e., the line currently being entered.
    
   d   r@   r   N)r.   r_   rb   r4   _working_linesr0   s     r"   end_of_historyrh      sT    
 
((r3w(777Ds4.//!344444r$   zreverse-search-historyc                    | j         j        j        }t          |t                    r:|j        r5t          j        | j         j        _	        |j        | j         j        _        dS dS dS )z
    Search backward starting at the current line and moving `up` through
    the history as necessary. This is an incremental search.
    N)
rQ   layoutcurrent_controlr    r   search_buffer_controlr   BACKWARDcurrent_search_state	direction)r*   controls     r"   reverse_search_historyrq      sm     i.G'=)) Ig.K I3B3K	&0+2+H	(((I I I Ir$   zend-of-filec                8    | j                                          dS )z
    Exit.
    N)rQ   exitrT   s    r"   end_of_filert      s    
 
INNr$   zdelete-charc                    | j                             | j                  }|s | j        j                                         dS dS )z-
    Delete character before the cursor.
    r@   N)r.   deleterC   rQ   outputbellr*   deleteds     r"   delete_charr{      sN    
 "))	)::G  	   r$   zbackward-delete-charc                    | j         dk     r"| j                            | j                    }n | j                            | j                   }|s | j        j                                         dS dS )z1
    Delete the character behind the cursor.
    r   r@   N)rC   r.   rv   delete_before_cursorrQ   rw   rx   ry   s     r"   backward_delete_charr~      sz    
 y1}} &--UYJ-??&;;%);LL  	   r$   zself-insertc                T    | j                             | j        | j        z             dS )z
    Insert yourself.
    N)r.   insert_textdatarC   rT   s    r"   self_insertr     s*    
 
$$UZ%)%;<<<<<r$   ztranspose-charsc                &   | j         }|j        }|dk    rdS |t          |j                  k    s|j        |         dk    r|                                 dS |xj        |j                                        z  c_        |                                 dS )a  
    Emulate Emacs transpose-char behavior: at the beginning of the buffer,
    do nothing.  At the end of a line or buffer, swap the characters before
    the cursor.  Otherwise, move the cursor right, and then swap the
    characters before the cursor.
    r   N
)r.   r/   r4   r5   swap_characters_before_cursorr9   rB   )r*   bps      r"   transpose_charsr     s     	A	AAvv	
c!&kk		QVAY$..	'')))))	QZAACCC	'')))))r$   zuppercase-wordc                    | j         }t          | j                  D ]X}|j                                        }|j        j        d|         }|                    |                                d           YdS )z4
    Uppercase the current (or following) word.
    NT	overwrite)r.   rangerC   r9   rI   text_after_cursorr   upperr*   r1   irK   wordss        r"   uppercase_wordr   '  y    
 D59 8 8m1133/5$77778 8r$   zdowncase-wordc                    | j         }t          | j                  D ]X}|j                                        }|j        j        d|         }|                    |                                d           YdS )z4
    Lowercase the current (or following) word.
    NTr   )r.   r   rC   r9   rI   r   r   lowerr   s        r"   downcase_wordr   4  r   r$   zcapitalize-wordc                    | j         }t          | j                  D ]X}|j                                        }|j        j        d|         }|                    |                                d           YdS )z5
    Capitalize the current (or following) word.
    NTr   )r.   r   rC   r9   rI   r   r   titler   s        r"   capitalize_wordr   A  r   r$   zquoted-insertc                    d| j         _        dS )z{
    Add the next character typed to the line verbatim. This is how to insert
    key sequences like C-q, for example.
    TN)rQ   quoted_insertrT   s    r"   r   r   N  s     #EIr$   z	kill-linec                l   | j         }| j        dk     r/|                    |j                                                   }nS|j        j        dk    r|                    d          }n-|                    |j                                                  }| j        j	        
                    |           dS )z
    Kill the text from the cursor to the end of the line.

    If we are at the end of the line, this should remove the newline.
    (That way, it is possible to delete multiple lines by executing this
    command multiple times.)
    r   r@   r   r   N)r.   rC   r}   r9   r:   current_charrv   r=   rQ   	clipboardset_textr*   r1   rz   s      r"   	kill_liner   \  s     Dy1}}++=;;=== , 
 
 =%--kk!nnGGkk(N(N(P(PkQQG	I  )))))r$   z	kill-wordc                    | j         }|j                            | j                  }|rd|                    |          }| j        r&| j        j                                        j	        |z   }| j        j        
                    |           dS dS )z
    Kill from point to the end of the current word, or if between words, to the
    end of the next word. Word boundaries are the same as forward-word.
    r@   N)r.   r9   rI   rC   rv   	is_repeatrQ   r   get_datar5   r   )r*   r1   rK   rz   s       r"   	kill_wordr   r  s     D
-
-
-EI
-
>
>C
 .++C+((? 	Di)22449GCG	$$W-----. .r$   zunix-word-ruboutTWORDboolc                t   | j         }|j                            | j        |          }||j         }|re|                    |           }| j        r&|| j        j        	                                j
        z  }| j        j                            |           dS | j        j                                         dS )zi
    Kill the word behind point, using whitespace as a word boundary.
    Usually bound to ControlW.
    )rA   r   Nr@   )r.   r9   find_start_of_previous_wordrC   r/   r}   r   rQ   r   r   r5   r   rw   rx   )r*   r   r1   rK   rz   s        r"   unix_word_ruboutr     s     D
-
3
3%)$
3
O
OC
{ ##
  ++3$+77 ? 	;uy*3355::G	$$W----- 		r$   zbackward-kill-wordc                (    t          | d           dS )z
    Kills the word before point, using "not a letter nor a digit" as a word boundary.
    Usually bound to M-Del or M-Backspace.
    F)r   N)r   rT   s    r"   backward_kill_wordr     s     U''''''r$   zdelete-horizontal-spacec                d   | j         }|j        j        }|j        j        }t	          |          t	          |                    d                    z
  }t	          |          t	          |                    d                    z
  }|                    |           |                    |           dS )z2
    Delete all spaces and tabs around point.
    z	 r@   N)	r.   r9   text_before_cursorr   r4   rstriplstripr}   rv   )r*   r1   r   r   delete_beforedelete_afters         r"   delete_horizontal_spacer     s    
 D97*++c2D2K2KE2R2R.S.SSM())C0A0H0H0O0O,P,PPLM222KKlK#####r$   zunix-line-discardc                   | j         }|j        j        dk    r(|j        j        dk    r|                    d           dS |                    |j                                                   }| j        j                            |           dS )zM
    Kill backward from the cursor to the beginning of the current line.
    r   r   r@   N)	r.   r9   cursor_position_colr/   r}   r:   rQ   r   r   r   s      r"   unix_line_discardr     s    
 D}(A--$-2ORS2S2S!!!*****++=;;=== , 
 
 		$$W-----r$   yankc                    | j                             | j        j                                        | j        t          j                   dS )z
    Paste before cursor.
    )rA   
paste_modeN)r.   paste_clipboard_datarQ   r   r   rC   r   EMACSrT   s    r"   r   r     sJ    
 
--	$$&&eiIO .     r$   zyank-nth-argc                Z    | j         r| j        nd}| j                            |           dS )z
    Insert the first argument of the previous command. With an argument, insert
    the nth word from the previous command (start counting at 0).
    N)arg_presentrC   r.   yank_nth_argr*   ns     r"   r   r     s4     &0		DA	%%a(((((r$   zyank-last-argc                Z    | j         r| j        nd}| j                            |           dS )zf
    Like `yank_nth_arg`, but if no argument has been given, yank the last word
    of each line.
    N)r   rC   r.   yank_last_argr   s     r"   r   r     s4     &0		DA	&&q)))))r$   zyank-popc                    | j         }|j        }| j        j        }|P||_        |                                 |                    |                                t          j	                   dS dS )z`
    Rotate the kill ring, and yank the new top. Only works following yank or
    yank-pop.
    N)r   )
r.   document_before_pasterQ   r   r9   rotater   r   r   r   )r*   r1   doc_before_paster   s       r"   yank_popr     ss     D1	#I#(!!)"4"4"6"69?!SSSSS $#r$   completec                $    t          |            dS )z(
    Attempt to perform completion.
    N)r   rT   s    r"   r   r     s    
 &e,,,,,r$   zmenu-completec                $    t          |            dS )z
    Generate completions, or go to the next completion. (This is the default
    way of completing input in prompt_toolkit.)
    N)r   rT   s    r"   menu_completer     s     r$   zmenu-complete-backwardc                8    | j                                          dS )zA
    Move backward through the list of possible completions.
    N)r.   complete_previousrT   s    r"   menu_complete_backwardr     s    
 
**,,,,,r$   zstart-kbd-macroc                B    | j         j                                         dS )zL
    Begin saving the characters typed into the current keyboard macro.
    N)rQ   emacs_statestart_macrorT   s    r"   start_kbd_macror     s!    
 
I%%'''''r$   zend-kbd-macroc                B    | j         j                                         dS )zg
    Stop saving the characters typed into the current keyboard macro and save
    the definition.
    N)rQ   r   	end_macrorT   s    r"   end_kbd_macror   #  s!     
I##%%%%%r$   zcall-last-kbd-macroF)record_in_macroc                r    | j         j        j        }|r#| j         j                            |d           dS dS )a  
    Re-execute the last keyboard macro defined, by making the characters in the
    macro appear as if typed at the keyboard.

    Notice that we pass `record_in_macro=False`. This ensures that the 'c-x e'
    key sequence doesn't appear in the recording itself. This function inserts
    the body of the called macro back into the KeyProcessor, so these keys will
    be added later on to the macro of their handlers have `record_in_macro=True`.
    TfirstN)rQ   r   macrokey_processorfeed_multiple)r*   r   s     r"   call_last_kbd_macror   ,  sJ     I!'E A	--e4-@@@@@A Ar$   zprint-last-kbd-macroc                6     d fd}ddl m}  ||           dS )z(
    Print the last keyboard macro.
    r   r,   c                 Z    j         j        j        } | r| D ]}t          |           d S d S N)rQ   r   r   print)r   kr*   s     r"   print_macroz)print_last_kbd_macro.<locals>.print_macroF  sH    	%+ 	  a	 	 r$   r   )run_in_terminalNr   r,   )*prompt_toolkit.application.run_in_terminalr   )r*   r   r   s   `  r"   print_last_kbd_macror   ?  sL          KJJJJJOK     r$   undoc                8    | j                                          dS )z
    Incremental undo.
    N)r.   r   rT   s    r"   r   r   V  s    
 
r$   zinsert-commentc           	         | j         }| j        dk    rdd}ndd}t          d                    t	          ||j                                                            d	          |_        |                                 d
S )z
    Without numeric argument, comment all lines.
    With numeric argument, uncomment all lines.
    In any case accept the input.
    r   liner   r   c                D    |                      d          r
| dd          n| S )N#r   )
startswithr   s    r"   changezinsert_comment.<locals>.changej  s%    #s33=488=r$   c                    d| z   S )Nr   r%   r   s    r"   r   zinsert_comment.<locals>.changeo  s    :r$   r   r   )r5   r/   N)r   r   r   r   )	r.   rC   r   joinmapr5   
splitlinesr9   rY   )r*   r1   r   s      r"   insert_commentr   ^  s     D yA~~	> 	> 	> 	> 	>
	 	 	 	 YYs649#7#7#9#9::;;Q  DM
 	r$   zvi-editing-modec                2    t           j        | j        _        dS )z$
    Switch to Vi editing mode.
    N)r	   VIrQ   editing_moderT   s    r"   vi_editing_moder   z  s    
 )^EIr$   zemacs-editing-modec                2    t           j        | j        _        dS )z'
    Switch to Emacs editing mode.
    N)r	   r   rQ   r   rT   s    r"   emacs_editing_moder     s    
 ).EIr$   zprefix-metac                v    | j         j                            t          t          j                  d           dS )z
    Metafy the next character typed. This is for keyboards without a meta key.

    Sometimes people also want to bind other keys to Meta, e.g. 'jj'::

        key_bindings.add_key_binding('j', 'j', filter=ViInsertMode())(prefix_meta)
    Tr   N)rQ   r   feedr   r   EscaperT   s    r"   prefix_metar     s2     
I  $+!6!6d CCCCCr$   zoperate-and-get-nextc                    | j         j        dz                                    dfd}| j        j                            |           dS )z
    Accept the current line for execution and fetch the next line relative to
    the current line from the history for editing.
    r   r   r,   c                 J    t           j                  k     r	 _        d S d S r   )r4   rg   working_index)r1   	new_indexs   r"   set_working_indexz/operate_and_get_next.<locals>.set_working_index  s/    s4.////!*D 0/r$   Nr   )r.   r  rY   rQ   pre_run_callablesappend)r*   r  r1   r  s     @@r"   operate_and_get_nextr    st     D"Q&I 	+ + + + + + + 
I&&'899999r$   zedit-and-execute-commandc                @    | j         }|                    d           dS )zN
    Invoke an editor on the current command line, and accept the result.
    T)rY   N)r.   open_in_editorr0   s     r"   edit_and_executer
    s)    
 DD11111r$   )r   r   r   r   )r   r   r   r
   )r*   r+   r   r,   )T)r*   r+   r   r   r   r,   )W__doc__
__future__r   typingr   r   r   r   prompt_toolkit.documentr   prompt_toolkit.enumsr	   'prompt_toolkit.key_binding.key_bindingsr
   r   (prompt_toolkit.key_binding.key_processorr   r   prompt_toolkit.keysr   prompt_toolkit.layout.controlsr   prompt_toolkit.searchr   prompt_toolkit.selectionr   
completionr   r   __all__r!   _HandlerOrBindingr   r+   r   __annotations__r&   r   r2   r6   r;   r>   rD   rG   rL   rO   rU   rW   rZ   r]   r`   rc   rh   rq   rt   r{   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r
  r%   r$   r"   <module>r     s
     # " " " " " 1 1 1 1 1 1 1 1 1 1 1 1 , , , , , , , , , , , , H H H H H H H H L L L L L L L L $ $ $ $ $ $ 8 8 8 8 8 8 1 1 1 1 1 1 . . . . . . O O O O O O O O  ]OT)*(G+, WT*+++ *,  + + + +   "E E E E  

     !  
/* * * * 

    
-E E E E 
.U U U U 
/T T T T 
.	$ 	$ 	$ 	$ 
/	$ 	$ 	$ 	$ 
.    

  	 	 	 ! 	 
-/ / / / 

; ; ; ; 
.: : : : 

 !!* * * "!* 

5 5 5 5 

"##	I 	I 	I $#	I" 
-    
-        

 !!      "!  
-= = = = 

* * * *$ 

	8 	8 	8 	8 
/	8 	8 	8 	8 

	8 	8 	8 	8 
/# # # # 
+* * * ** 
+. . . ." 

         8 

( ( (  ( 

#$$$ $ $ %$$ 

. . . . 
&    
.) ) ) ) 
/* * * * 
*T T T T( 
*- - - - 
/        

"##- - - $#- 

( ( ( ( 
/& & & & 

  U###A A A $# ! A" 

 !!! ! ! "!!, 
&        

   6 

, , , , 

/ / /  / 
-
D 
D 
D 
D 

 !!: : : "!:( 

$%%2 2 2 &%2 2 2r$   