
                         r    d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 ddl
mZ dd	lmZ ddlZd
 Zy)zAgcloud interactive specific vi key binding additions / overrides.    )absolute_import)division)unicode_literalsN)
IsReadOnly)create_operator_decorator)	InputMode)Keysc                     t         j                  r t        j                  j	                  d      }nt        j                  }|dz   t        |       dfd	} |d        |d       y)z1Adds gcloud interactive specific vi key bindings.ascii
0123456789Fc                 l      rdt         j                  df}nd} |dt                i fd       }y)zCreates and registers change operators.

    Args:
      with_register: Copy the changed text to this named register instead of
        the clipboard.
    "cfilterc                    d}| j                   }|r|j                  |j                  k  r|j                  |j                  kD  rU|j                  |j                  |j                  z   dz
     j                         r|xj                  dz  c_        |j                  |j                  kD  r|j                  |j                  |j                  z   dz
     j                         rfn|j                  |j                  kD  r|j                  |j                  |j                  z   dz
     j                         rf|xj                  dz  c_        |j                  |j                  kD  r8|j                  |j                  |j                  z   dz
     j                         rf|j                  |      \  }}||_        |rt|j                  rhrA| j                  d   j                  }|v rI|| j                  j                  j                  |<   n%| j                  j                  j                  |       t        j                   | j                  j                  _        y)zA change operator.N   )current_bufferstartendtextcursor_positionisspacecutdocumentkey_sequencedataclivi_statenamed_registers	clipboardset_datar   INSERT
input_mode)eventtext_objectclipboard_databufnew_documentreg_namevi_register_nameswith_registers         9lib/googlecloudsdk/command_lib/interactive/bindings_vi.pyChangeOperatorzELoadViBindings.<locals>.CreateChangeOperators.<locals>.ChangeOperator7   s    n  c	 {.;#4#44#--%//*,-. //6wy9OOq O ;#4#44#--%//*,-. //6wy9 ""[__4#--%++,./0 118;" ""[__4#--%++,./0 118; (3s';$n# 
N//''*//(**;IEII..x8
))


&
&~
6 '0&6&6eii#    N)r	   Anyr   )r+   handler_keysr-   operatorr*   s   `  r,   CreateChangeOperatorsz-LoadViBindings.<locals>.CreateChangeOperators+   s=     488S)ll|2Z\M2 7 3 7r.   TN)F)sixPY2stringascii_lowercasedecoder   )registryr6   r2   r1   r*   s      @@r,   LoadViBindingsr9       sZ     	WW,,33G<O,,O%4&x0(-7^ r.   )__doc__
__future__r   r   r   r5   prompt_toolkit.filtersr   &prompt_toolkit.key_binding.bindings.vir   #prompt_toolkit.key_binding.vi_stater   prompt_toolkit.keysr	   r3   r9    r.   r,   <module>rA      s+     H &  '  - L 9 $ 
;r.   