
                             S r SSK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	\R                  5      rS
 rS rS rS rg)z&Code for the gcloud shell help window.    N)cli_tree_markdown)parser)render_document)token_renderer)controlsc                   (    \ rS rSrSrSS jrS rSrg)HelpWindowControl   z"Implementation of the help window.Nc                     Xl         g N_default_char)selfdefault_chars     9lib/googlecloudsdk/command_lib/interactive/help_window.py__init__HelpWindowControl.__init__   s    %    c                 v   ^ [        X5      m[        R                  " U4S j[        T5      SU R                  S9$ )Nc                    > TU    $ r    )idatas    r   <lambda>2HelpWindowControl.create_content.<locals>.<lambda>&   s	    $q'r   F)
line_countshow_cursorr   )GenerateHelpContentr   	UIContentlenr   )r   cliwidthheightr   s       @r   create_content HelpWindowControl.create_content"   s6    s*Dt9''	) )r   r   r   )__name__
__module____qualname____firstlineno____doc__r   r$   __static_attributes__r   r   r   r	   r	      s    *&)r   r	   c                    US:  a  SnU R                   R                  nU R                  R                  UR                  5      nU(       d  / $ US   nUR
                  [        R                  R                  [        R                  R                  4;   a  [        XU5      $ UR
                  [        R                  R                  :X  a  [        XU5      $ UR
                  [        R                  R                  :X  a  [        XS   U5      $ UR
                  [        R                  R                  :X  a  [        XU5      $ / $ )z)Returns help lines for the current token.P   )current_bufferdocumentr   ParseCommandtext_before_cursor
token_typeArgTokenTypeGROUPCOMMANDGenerateHelpForCommandFLAGGenerateHelpForFlagFLAG_ARG
POSITIONALGenerateHelpForPositional)r!   r"   docargsargs        r   r   r   ,   s    
RZE###		 	 !7!7	8$	IR#^^++1163F3F3N3NOO!#E22
~~,,111s//
~~,,555sHe44
~~,,777$Su55	)r   c           
         / nSn[         R                  " UR                  U R                  5      nUR	                  SSS9  UR                  5       n[        R                  " U5      nUR                  [        R                  " [        R                  " X$S9US9R                  5       5        UR                  / 5        Sn[         R                  " UR                  U R                  5      nUR                  5         UR                  5       n[        R                  " U5      nUR                  [        R                  " [        R                  " X$SS	9US9R                  5       5        U$ )
z'Returns help lines for a command token.   DESCRIPTIONT)disable_headerr"   r#   fin   F)r"   r#   compact)markdownCliTreeMarkdownGeneratortreerootPrintSectionIfExistsEditioStringIOextendr   MarkdownRendererr   TokenRendererRunappendPrintSynopsisSection)r!   tokenr"   linesr#   genr>   rG   s           r   r8   r8   B   s   
% &))%**chh?#=>
#
C#,,//""&+.0037 ,,r &))%**chh?#
#
C#,,//""e5:=??BsuF 
,r   c                 l   [         R                  " U R                  U R                  5      nUR                  UR                  5        UR                  5       n[        R                  " U5      n[        R                  " [        R                  " X R                  R                  S9US9R                  5       $ )z$Returns help lines for a flag token.rE   rF   )rJ   rK   rM   PrintFlagDefinitionrL   rO   rP   rQ   r   rS   r   rT   config
help_linesrU   r!   rX   r"   rZ   markrG   s         r   r:   r:   _   s    ))#((CHH=#%**%	$
D#		)	)""jj335:=
??BsuEr   c                    [         R                  " U R                  U R                  5      nUR                  [         R                  " UR
                  5      5        UR                  5       n[        R                  " U5      n[        R                  " [        R                  " X R                  R                  S9US9R                  5       $ )z*Returns help lines for a positional token.rE   rF   )rJ   rK   rM   PrintPositionalDefinition
PositionalrL   rO   rP   rQ   r   rS   r   rT   r]   r^   rU   r_   s         r   r=   r=   k   s    ))#((CHH=# 3 3EJJ ?@	$
D#		)	)""jj335:=
??BsuEr   )r*   rP   googlecloudsdk.callioper   rJ   &googlecloudsdk.command_lib.interactiver   &googlecloudsdk.core.document_renderersr   r   prompt_toolkit.layoutr   	UIControlr	   r   r8   r:   r=   r   r   r   <module>ri      sF     - 
 A 9 B A *)** ) ,:	E	Er   