
    ^hH                        S r SSKrSSKrSSKrSSKrSSK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  SS	K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$J%r%  SSK&J'r'  S/r(\ " S S5      5       r)\ " S S\)5      5       r*\ " S S\)5      5       r+S\4S jr,/ \ RZ                  R]                  5        V Vs/ s H  u  p\+" X/S5      PM     snn Q\ R^                  R]                  5        V Vs/ s H  u  p\+" X/S5      PM     snn Q\+" \ R`                  S/S5      P\+" \ Rb                  S/S 5      P\+" \ Rd                  S/S!5      P\+" \ Rf                  S/S"5      P\+" \ Rh                  S#/S$5      P\+" \ Rh                  S%/S&5      P\+" \ Rh                  S'/S(5      P\+" \ Rh                  S/S)5      P\+" \ Rh                  S/S*5      P\+" \ Rj                  S+/S,5      P\+" \ Rj                  S+/S-5      P\+" \ Rj                  S+/S.5      P\+" \ Rj                  S+/S/5      P\+" \ Rj                  S+/S05      Pr6\+" \!Rn                  S1/S25      \+" \!Rn                  S3/S25      \+" \!Rp                  S4/S25      \+" \!Rp                  S5/S25      \+" \!Rr                  S6S7/S25      \+" \!Rt                  S8/S25      \+" \!Rv                  S6/S95      \+" \!Rv                  S:/S95      \+" \!Rx                  S;/S<5      \+" \!Rz                  S=/S>5      \+" \!R|                  S;/S?5      \+" \!R~                  S=/S@5      \+" \!R                  S6S5/S25      \+" \!R                  SA/S25      \+" \!R                  S6SB/S95      \+" \!R                  S+/SC5      \+" \!R                  S5/SD5      /rE\R                  \R                  \R                  \R                  \R                  \R                  SE.R]                  5        V Vs/ s H  u  p\+" X/SF5      PM     snn rL\R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  SG.
R]                  5        VVs/ s H  u  p!\+" U\U" U5      SF5      PM     snnrVSH\SI\+4SJ jrWSwSK\4SL jjrXSM rYSN rZSO r[SP r\SQ r]SR r^SS r_ST r`SU raSV rbSW rcSX rdSY reSZ rf\R                  S[:X  a  SS\KhJiri  SS]KjJkrkJlrlJmrm  \%S^ 5       rnO\%S_ 5       rn\+" \[S`/Sa5      \+" \YS6S`/Sb5      \+" \cSc/5      \+" \]Sd/Se5      \+" \^Sf/Se5      \+" \_Sg/Sh5      \+" \`Si/Sj5      \+" \aSi/Sk5      \+" \bSl/Sm5      \+" \dSn/So5      \+" \eSp/Sq5      \+" \fSr/Sj5      /\6Q\EQ\+" \Ss/St5      P\+" \nSu/Sv5      P\LQ\VQrogs  snn f s  snn f s  snn f s  snnf )xzU
Module to define and register Terminal IPython shortcuts with
:mod:`prompt_toolkit`
    N)	dataclass)CallableAnyOptionalList)get_app)KeyBindings)KeyPressEvent)named_commands)!display_completions_like_readline)	InputModeViState)	Condition)get_ipython)
auto_match)auto_suggest)filter_from_string)undoc)DEFAULT_BUFFERcreate_ipython_shortcutsc                   <    \ rS rSr% \\/\4   \S'   \\	   \S'   Sr
g)BaseBinding%   commandkeys N)__name__
__module____qualname____firstlineno__r   r
   r   __annotations__r   str__static_attributes__r       ]/home/james-whalen/.local/lib/python3.13/site-packages/IPython/terminal/shortcuts/__init__.pyr   r   %   s    }os*++
s)Or$   r   c                        \ rS rSr% \\S'   Srg)RuntimeBinding+   filterr   N)r   r   r   r    r   r!   r#   r   r$   r%   r'   r'   +   s    r$   r'   c                   0    \ rS rSr% Sr\\   \S'   S rSr	g)Binding0   N	conditionc                 j    U R                   (       a  [        U R                   5      U l        g S U l        g N)r-   r   r)   )selfs    r%   __post_init__Binding.__post_init__8   s     >>,T^^<DKDKr$   )r)   )
r   r   r   r    r-   r   r"   r!   r1   r#   r   r$   r%   r+   r+   0   s      $Ix}#r$   r+   handlerc                     U R                   R                  S5      nU R                  nUS   n[        U5      S:  a  US   nU SU SU 3$ U SU 3$ )N.r      :)r   splitr   len)r3   partsnamepackagefinal_modules        r%   create_identifierr?   ?   sh    $$S)EDAhG
5zA~Ry!L>4&11!D6""r$   z>focused_insert & auto_match & followed_by_closing_paren_or_endz8focused_insert & auto_match & preceded_by_raw_str_prefix"z~focused_insert & auto_match & not_inside_unclosed_string & preceded_by_paired_double_quotes & followed_by_closing_paren_or_end'z~focused_insert & auto_match & not_inside_unclosed_string & preceded_by_paired_single_quotes & followed_by_closing_paren_or_endzXfocused_insert & auto_match & not_inside_unclosed_string & preceded_by_two_double_quoteszXfocused_insert & auto_match & not_inside_unclosed_string & preceded_by_two_single_quotes)z=focused_insert & auto_match & followed_by_closing_round_paren]z9focused_insert & auto_match & followed_by_closing_bracket}z7focused_insert & auto_match & followed_by_closing_bracez6focused_insert & auto_match & followed_by_double_quotez6focused_insert & auto_match & followed_by_single_quote	backspacez_focused_insert & preceded_by_opening_round_paren & auto_match & followed_by_closing_round_parenzWfocused_insert & preceded_by_opening_bracket & auto_match & followed_by_closing_bracketzSfocused_insert & preceded_by_opening_brace & auto_match & followed_by_closing_bracezQfocused_insert & preceded_by_double_quote & auto_match & followed_by_double_quotezQfocused_insert & preceded_by_single_quote & auto_match & followed_by_single_quoteendz@has_suggestion & default_buffer_focused & emacs_like_insert_modec-ezc-frightescapefzc-rightz;has_suggestion & default_buffer_focused & emacs_insert_modedeletezc-upzQnavigable_suggestions & ~has_line_above & has_suggestion & default_buffer_focusedzc-downzQnavigable_suggestions & ~has_line_below & has_suggestion & default_buffer_focusedz?has_line_above & navigable_suggestions & default_buffer_focusedz?has_line_below & navigable_suggestions & default_buffer_focusedzc-leftdownz/default_buffer_focused & emacs_like_insert_modez]is_cursor_at_the_end_of_line & default_buffer_focused & emacs_like_insert_mode & pass_through)zc-azc-bzc-kzc-wzc-yzc-_z0vi_insert_mode & default_buffer_focused & ebivim)
)c-xrG   )rM   e)rI   b)rI   c)rI   d)rI   h)rI   l)rI   u)rI   y)rI   r5   bindingsbindingc                     U R                   " UR                  0 UR                  b  SUR                  0O0 D6" UR                  5        g )Nr)   )addr   r)   r   )rV   rW   s     r%   add_bindingrZ   @  s?    LL	)0)CHgnn% oor$   returnc                   ^  [        5       nU=(       d    / n[         Hx  nSnU HY  nUR                  UR                  :X  d  M  UR                  UR                  :X  d  M;  UR                  UR                  :X  d  MW  Sn  O   U(       a  Mm  [        X#5        Mz     U 4S jnS nT R                  S:X  a>  T R                  (       a-  [        R                  [        l        [        Xg5      [        l        U$ )a  Set up the prompt_toolkit keyboard shortcuts for IPython.

Parameters
----------
shell: InteractiveShell
    The current IPython shell Instance
skip: List[Binding]
    Bindings to skip.

Returns
-------
KeyBindings
    the keybinding instance for prompt toolkit.

FTc                 t   > [        5       nTR                  Ul        TR                  Ul        U R                  $ r/   )r   ttimeoutlen
timeoutlen_input_mode)r0   appshells     r%   get_input_mode0create_ipython_shortcuts.<locals>.get_input_modeg  s0    i++))r$   c                    [         R                  S[         R                  S0R                  US5      nSR	                  U5      n[
        R                  R                  U5        [
        R                  R                  5         Xl	        g )N         z[{} q)
r   
NAVIGATIONREPLACEgetformatsysstdoutwriteflushr`   )r0   modeshapecursors       r%   set_input_mode0create_ipython_shortcuts.<locals>.set_input_moden  sa    %%q)*;*;Q?CCD!L##E*

 

r$   vi)r	   KEY_BINDINGSr   r)   r   rZ   editing_modemodal_cursorr   INSERTr   r`   property
input_mode)rb   skipkbrW   skip_this_oneto_skiprc   rt   s   `       r%   r   r   G  s      
B:2DG7??2NNgnn4LLGLL0 $  B      T!e&8&8'..%nEIr$   c                     [        5       n[        U R                  U R                  R                  U5        U R                  R	                  5         g)zReformat code and execute itN)r   reformat_text_before_cursorcurrent_bufferdocumentvalidate_and_handleeventrb   s     r%   reformat_and_executer   ~  s>    MEe22;;U 
,,.r$   c                     U R                  [        UR                  S UR                   5      5      n UR	                  U5      nU R                  U5        g ! [         a  nU R                  U5         S nAg S nAff = fr/   )delete_before_cursorr:   textcursor_positionreformat_handlerinsert_text	Exception)bufferr   rb   r   formatted_textrN   s         r%   r   r     sm    &&s8==9S8;S;S+T'UVD!//5>* !4  !s   "A 
A; A66A;c                     [        5       n[        USS 5      (       a  UR                  U5      " U 5      $ [        U5      " U 5      $ )Nhandle_return)r   getattrr   newline_or_execute_outerr   s     r%   #handle_return_or_newline_or_executer     s>    MEuot,,""5)%00'.u55r$   c                    ^  U 4S jnU$ )Nc                   > U R                   nUR                  nUR                  (       a@  UR                  R                  nU(       a  UR	                  U5        gUR                  5         gUR                  S:X  a  UR                  nOUR                  SUR                   nT	R                  U5      u  pVUR                  UR                  S nSnUR                  5       (       d  [        XT	5        SnUR                  (       dc  UR                  UR                  UR                  5       -
  :  d8  T	R                  (       a  UR!                  SU-   5        gUR!                  S5        gUS:w  a5  UR"                  (       a$  U(       d  [        XT	5        UR%                  5         gT	R                  (       a  UR!                  SU-   5        gUR!                  S5        g)zCWhen the user presses return, insert a newline or execute the code.Nr6   FT

incomplete)r   r   complete_statecurrent_completionapply_completioncancel_completion
line_countr   r   check_completestripr   on_last_linecursor_position_rowempty_line_count_at_the_end
autoindentr   accept_handlerr   )
r   rO   rQ   cc
check_textstatusindentafter_cursorreformattedrb   s
            r%   newline_or_execute4newline_or_execute_outer.<locals>.newline_or_execute  sx     JJ!!44B""2&  ##% <<1J 3!"3"34J--j9 vva//12!!##'e4KNN$$q7T7T7V(VVdVm,  d#l"(8(8+A%8!!#dVm,d#r$   r   )rb   r   s   ` r%   r   r     s    .$` r$   c                 8    U R                   R                  5         g)z
Control-P in vi edit mode on readline is history next, unlike default prompt toolkit.

If completer is open this still select previous completion.
N)r   auto_upr   s    r%   'previous_history_or_previous_completionr     s     
  "r$   c                 8    U R                   R                  5         g)z
Control-N in vi edit mode on readline is history previous, unlike default prompt toolkit.

If completer is open this still select next completion.
N)r   	auto_downr   s    r%   next_history_or_next_completionr     s     
""$r$   c                 `    U R                   nUR                  (       a  UR                  5         gg)zDismiss completionN)r   r   r   r   rO   s     r%   dismiss_completionr     s'    A	 r$   c                     U R                   nUR                  (       a  UR                  5         gUR                  5         g)zReset bufferN)r   r   r   resetr   s     r%   reset_bufferr     s+    A			r$   c                     U R                   R                  R                  (       a  U R                   R                  5         gU R                  R
                  R                  [        5        g)zReset search bufferN)r   r   r   r   ra   layoutfocusr   r   s    r%   reset_search_bufferr     sA    $$))""$		~.r$   c                 8    U R                   R                  5         g)zSuspend to backgroundN)ra   suspend_to_backgroundr   s    r%   suspend_to_bgr     s    	II##%r$   c                     [        [        SS5      nUb&  [        R                  " S[        R                  5        g[
        R                  " S5        g)z
Quit application with ``SIGQUIT`` if supported or ``sys.exit`` otherwise.

On platforms that support SIGQUIT, send SIGQUIT to the current process.
On other platforms, just exit the process with a message.
SIGQUITNr   Quit)r   signaloskillr   rm   exit)r   sigquits     r%   quitr     s6     fi.G
6>>"r$   c                 :    U R                   R                  S5        g)zIndent buffer    N)r   r   r   s    r%   indent_bufferr   	  s    	$$W-r$   c                 >   [        5       nUR                  nU R                  nUR                  nUR                  (       a  UR                  5         UR                  SUR                   S-   nUR                  U5      u  pgUR                  SSU=(       d    S-  -   SS9  g)a`  Insert a newline after the cursor indented appropriately.

Fancier version of former ``newline_with_copy_margin`` which should
compute the correct indentation of the inserted line. That is to say, indent
by 4 extra space after a function definition, class definition, context
manager... And dedent by 4 space after ``pass``, ``return``, ``raise ...``.
Nr    r   F)move_cursor)
r   input_transformer_managerr   r   r   r   r   r   r   r   )r   rb   inputsplitterrO   rQ   r   _r   s           r%   newline_autoindentr     s     ME33MA	

A	66%A%%&-D,,T2IAMM$#1-.EMBr$   c                 L    U R                   R                  R                  5         g)z'Open code from input in external editorN)ra   r   open_in_editorr   s    r%   open_input_in_editorr   "  s    	II++-r$   win32)TryNext)ClipboardEmptytkinter_clipboard_getwin32_clipboard_getc                      [        5       nU R                  R                  UR                  SS5      5        g ! [         a%     [        5       n NC! [        [        4 a      g f = f[         a     g f = f)N	r   )r   r   r   r   r   r   replace)r   r   s     r%   	win_paster   /  sp    	&(D 	((dG)DE  	,.^,  		s-   
8 
A2
AA#A2"A##A21A2c                     g)zStub used on other platformsNr   r   s    r%   r   r   >  s     	r$   enterz5default_buffer_focused & ~has_selection & insert_modez>default_buffer_focused & ~has_selection & insert_mode & ebivimzc-\zc-pz'vi_insert_mode & default_buffer_focusedzc-nzc-gz(default_buffer_focused & has_completionszc-cdefault_buffer_focusedsearch_buffer_focusedzc-zsupports_suspendtabzLdefault_buffer_focused & ~has_selection & insert_mode & cursor_in_leading_wszc-oz*default_buffer_focused & emacs_insert_modef2zc-izireadline_like_completions & default_buffer_focused & ~has_selection & insert_mode & ~cursor_in_leading_wszc-vz1default_buffer_focused & ~vi_mode & is_windows_osr/   )p__doc__r   r   rm   warningsdataclassesr   typingr   r   r   r   "prompt_toolkit.application.currentr   prompt_toolkit.key_bindingr	   (prompt_toolkit.key_binding.key_processorr
   #prompt_toolkit.key_binding.bindingsr   nc.prompt_toolkit.key_binding.bindings.completionr   #prompt_toolkit.key_binding.vi_stater   r   prompt_toolkit.filtersr   IPython.core.getipythonr   IPython.terminal.shortcutsr   matchr   "IPython.terminal.shortcuts.filtersr   IPython.utils.decoratorsr   prompt_toolkit.enumsr   __all__r   r'   r+   r?   auto_match_parensitemsauto_match_parens_raw_stringdouble_quotesingle_quotedocstring_double_quotesdocstring_single_quotes	skip_overdelete_pairAUTO_MATCH_BINDINGSaccept_or_jump_to_endacceptaccept_wordaccept_tokendiscardswap_autosuggestion_upswap_autosuggestion_downup_and_update_hintdown_and_update_hintaccept_characteraccept_and_move_cursor_leftaccept_and_keep_cursorbackspace_and_resume_hintresume_hintingAUTO_SUGGEST_BINDINGSbeginning_of_linebackward_char	kill_linebackward_kill_wordyankundoSIMPLE_CONTROL_BINDINGSedit_and_executebackward_wordcapitalize_word	kill_worddowncase_worduppercase_wordyank_popyank_last_arglistALT_AND_COMOBO_CONTROL_BINDINGSrZ   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   platformIPython.core.errorr   IPython.lib.clipboardr   r   r   r   rw   )keycmdr   s   000r%   <module>r+     s&   
  
  ! 0 0 6 2 B D C , / : 3 A * /%
&   
 [   k  #x #k
 //557	 8HC 	X	
 8	k ::@@B CHC 	UVWBk 		.k* 		.+k< %%		+=kL %%		+Mk\ 	G]kf 	Cgkp 	Aqkz # X{k@ # XAkF 		-GkV 		)Wkf 		'gkv 		&wkF 		&Gk d **	J
 **	J
 	J
 		J
   	3J
 !!	J
 	
 	F 	
E
 ++		$ --	
	$ ''	I
 ))	
I
 %%	7J
 00	
J
 ++	6E
 ..	9	 ##			}f X ##||$$wwww eg
 CJK
 " ++))))++..))**)) eg#	 CdOP# &+  4+ 4n/!61h#%/&
.
C(.
 <<7*  
F 
F   +		?
 	7H
 D6(/	1
 '	1
 )STL5'#;<%*ABME7$67		" )UV 4&*BCG2H I2J K2L )		#M2^ Iw ST_2` a2b %c2s^
#s   V5V;3WW