
    H)                     "   d 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 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 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 ddlmZ ddlmZ ddlmZ e	j0                  d        Z	 	 	 	 	 	 	 	 	 	 	 ddZy)zgcloud interactive layout.

  This is the prompt toolkit layout for the shell prompt. It determines the
  positioning and layout of the prompt, toolbars, autocomplete, etc.
    )absolute_import)division)unicode_literals)help_window)enums)filters)layout)	shortcuts)token)
containers)controls)	dimension)margins)menus)
processors)prompt)screen)toolbarsc                     | j                   j                  j                  xr7 | j                   j                  j                  | j                  j                  k7  S )z&Determine if the input field is empty.)current_bufferdocumenttextconfigcontext)clis    4lib/googlecloudsdk/command_lib/interactive/layout.pyUserTypingFilterr   +   sI     


%
%
*
* A



%
%
*
*cjj.@.@
@B    Nc                     |t        |      sJ |t        |      sJ |t        |      sJ |t        |      sJ  j                  r|rJ t        j                   j                        }t        j                  |	      }	| fd}t        j                  |      \  }}}t        j                  t        j                  d      t        j                  t        j                              t        j                         t        j                  t        j                         t        j                  t        j                        t        j                           z        t        j                  t        j"                         |      g}|r|j%                  |       |j'                  t        j                  t        j(                  |      |	              g } j*                  rWt,        j.                  j1                   j2                        }|
t        j                           z  t        j4                         z  }n_t-        j.                   j2                   j2                        }|
t6        z  t        j                           z  t        j4                         z  }|j'                  t9        j:                  t=        j>                  t=        j@                  tC        jD                  tG        jH                  dtJ        jL                  jN                              t,        j.                  j1                  d            t=        j@                  tQ        jR                  tG        jH                  d	tJ        jL                  jT                        
      |      g      |              jV                  r|s jX                  r|s jZ                  r%|r"g }|j'                  t=        j@                  tC        jD                  tG        jH                  dtJ        jL                  jN                              t,        j.                  j1                  d                    jZ                  r|r|j'                  t=        j@                  tC        j\                  |tG        jH                  d	tJ        jL                  j^                        
      dt,        j.                  j1                  d                   |j'                  t=        j@                  tC        jD                  tG        jH                  dtJ        jL                  jN                              t,        j.                  j1                  d                    jV                  r|r|j'                  t=        j@                  tC        j\                  |tG        jH                  d	tJ        jL                  jT                        
      t,        j.                  j1                  d                    jX                  r|r|j'                  t=        j@                  tC        j\                  |tG        jH                  d	tJ        jL                  jT                        
      t,        j.                  j1                  d                   |j'                  t9        j:                  t=        j>                  |      t        j                           t        j4                         z               d }t=        j>                  t9        j`                  t=        j>                  t9        j:                  t=        j@                  tC        j\                  |      d|      t        jb                  |            t=        j@                  tC        jd                  ||d      |tg        jh                  tg        jj                  ||      |	      g|      g      t=        jl                  ddto        jp                  ddt        j                  t        j                        | z              t=        jl                  dto        jr                  dt        j                  t        j                        |z              g      tu        jv                         tu        jx                         t9        j:                  tu        jz                         |	      t9        j:                  tu        j|                         |	      g|z         S )z+Create a container instance for the prompt.c                 R    t         j                  j                  j                  fgS )N)r   TokenPromptr   )_r   s    r   <lambda>z$CreatePromptLayout.<locals>.<lambda>L   s    EKK$6$6#F"Gr   T)preview_search)	preferredmaxr#   )char   )height )default_char)filter   )
wrap_linesr*   c                    | j                   j                  r\| j                  sP| j                  }t	        |       s|j
                  r-t        j                  | j                   j                  dz         S t        j                         S )z*Determine the height for the input buffer.r)   )min)r   completion_menu_linesis_doner   r   complete_stater   LayoutDimension)r   bufs     r   	GetHeightz%CreatePromptLayout.<locals>.GetHeight   sh     zz'' c	#	#"4"4((

00146 	6$$&&r   )dont_extend_heightr/   )input_processorslexerr%   )
get_heightleft_marginsr/      )
max_heightscroll_offsetextra_filter)xcursorycursorcontent)	show_metar@   )rB   rC   )?callabler   r   to_cli_filtermulti_column_completion_menur
   _split_multiline_promptr   ConditionalProcessorHighlightSearchProcessorHasFocusr   SEARCH_BUFFERHighlightSelectionProcessorAppendAutoSuggestionDEFAULT_BUFFERIsDonePasswordProcessorextendappendDefaultPromptfixed_prompt_positionr   r5   exact
help_linesRendererHeightIsKnownr   r   ConditionalContainerr	   HSplitWindowr   FillControlr   Charr   r!   HSepr   HelpWindowControlToolbarbottom_status_linebottom_bindings_linedebugTokenListControlTextFloatContainer	ConditionBufferControlr   ConditionalMarginPromptMarginFloatr   CompletionsMenuMultiColumnCompletionsMenupt_toolbarsValidationToolbarSystemToolbar
ArgToolbarSearchToolbar)r   r:   is_passwordget_prompt_tokensget_continuation_tokensget_debug_tokensget_bottom_status_tokensget_bottom_toolbar_tokensextra_input_processors	multiline	show_helpr/   rG   has_before_tokensget_prompt_tokens_1get_prompt_tokens_2r9   r   help_heighthelp_filterwindowsr7   s   `                     r   CreatePromptLayoutr   2   s    
"	)X.    
 	"	*h/! ! 
!		"h/@&AA	A		!X.>%??	?mm 12	2!(!6!6))"+##I.)G ''(9: >(*= %% 
-
-T
B


5..
/1 ,,.%%j&E&E&G&-&6&6u7K7K&L)0)9(9':; %%j&B&B&D&13" 23 %%


2
3iZAB
 (!!++11&2C2CDK 0000023K ++##K //7>>3C2CC0023K
//%%
--mm&&FKKU[[=M=M,NO"2288;= mm//#);;sEKK4G4G#HJ$&	  
 $<!!&?ll'GNN6==&++c5;;3C3C"DE((..q13 4 ||(nn
--''"%{{30@0@AC ..44Q79: nnV]]


FKKU[[5E5E$F
G**0035 6   %=nn
--''*%{{30C0CDF ..44Q7	9: ""'@nn
--''+%{{30C0CDF ..44Q7	9: OO''MM'"NN$$w'D'D'FF	HI
'  

------//0CD)-!+
 ##$56 mm(('7! &* ' //!../B/FH!*  (% @ ll//!#$%!**5+?+?@778	 ll:: $!**5+?+?@67	?8r ##%! %%k&<&<&>	J%%k&?&?&A9MAAB CA A
 Ar   )NFNNNNNNFTT)__doc__
__future__r   r   r   &googlecloudsdk.command_lib.interactiver   prompt_toolkitr   r   r	   r
   r   prompt_toolkit.layoutr   r   r   r   r   r   r   r   r   rn   rg   r   r    r   r   <module>r      s     '  ' >   " ! $   , * + ) ' , ( ( 9 	B B "#()-/3(,0415.2!&!%"&Lr   