
    Qf?                    d    d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZ dgZeZddZdS )zD
Key bindings for auto suggestion (for fish-style auto suggestion).
    )annotationsN)get_app)	Condition
emacs_mode)KeyBindings)KeyPressEventload_auto_suggest_bindingsreturnr   c                    t                      } | j        }t          dd            } |d|           |d|           |d|          dd                                    } |dd|t          z            dd            }| S )z
    Key bindings for accepting auto suggestion text.

    (This has to come after the Vi bindings, because they also have an
    implementation for the "right arrow", but we really want the suggestion
    binding when a suggestion is available.)
    r
   boolc                     t                      } | j        j        d uo2t          | j        j        j                  dk    o| j        j        j        S )Nr   )r   current_buffer
suggestionlentextdocumentis_cursor_at_the_end)apps    b/var/www/html/env/lib/python3.11/site-packages/prompt_toolkit/key_binding/bindings/auto_suggest.pysuggestion_availablez8load_auto_suggest_bindings.<locals>.suggestion_available    sO    ii)5 AC&1677!;A"+@	
    zc-f)filterzc-erighteventENonec                ^    | j         }|j        }|r|                    |j                   dS dS )z$
        Accept suggestion.
        N)r   r   insert_textr   )r   br   s      r   _acceptz+load_auto_suggest_bindings.<locals>._accept)   s?      \
 	+MM*/*****	+ 	+r   escapefc                    | j         }|j        }|rHt          j        d|j                  }|                    t          d |D                                  dS dS )z*
        Fill partial suggestion.
        z([^\s/]+(?:\s+|/))c              3     K   | ]}||V  	d S )N ).0xs     r   	<genexpr>z<load_auto_suggest_bindings.<locals>._fill.<locals>.<genexpr>@   s'      11Qq1q111111r   N)r   r   resplitr   r   next)r   r   r   ts       r   _fillz)load_auto_suggest_bindings.<locals>._fill6   sh    
  \
 	3.
@@AMM$11!1111122222	3 	3r   )r
   r   )r   r   r
   r   )r   addr   r   )key_bindingshandler   r    r-   s        r   r	   r	      s     ==LF
 
 
 Y
 VE.///VE.///VG0111+ + + 21 0/ 0/+ VHc"6"CDDD	3 	3 	3 ED	3 r   )r
   r   )__doc__
__future__r   r)   "prompt_toolkit.application.currentr   prompt_toolkit.filtersr   r   'prompt_toolkit.key_binding.key_bindingsr   (prompt_toolkit.key_binding.key_processorr   __all__r   r	   r%   r   r   <module>r8      s     # " " " " " 				 6 6 6 6 6 6 8 8 8 8 8 8 8 8 ? ? ? ? ? ? B B B B B B ! - - - - - -r   