
                              S r SSKJr  SSKJr  SSKJ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.    )absolute_import)division)unicode_literalsN)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&   genrA   rJ   s           r   r;   r;   E   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.rH   rI   )rM   rN   rP   PrintFlagDefinitionrO   rR   rS   rT   r   rV   r	   rW   config
help_linesrX   r$   r[   r%   r]   markrJ   s         r   r=   r=   b   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.rH   rI   )rM   rN   rP   PrintPositionalDefinition
PositionalrO   rR   rS   rT   r   rV   r	   rW   r`   ra   rX   rb   s         r   r@   r@   n   s    ))#((CHH=# 3 3EJJ ?@	$
D#		)	)""jj335:=
??BsuEr   )r-   
__future__r   r   r   rS   googlecloudsdk.callioper   rM   &googlecloudsdk.command_lib.interactiver   &googlecloudsdk.core.document_renderersr   r	   prompt_toolkit.layoutr
   	UIControlr   r!   r;   r=   r@   r   r   r   <module>rm      sM     - &  ' 	 A 9 B A *)** ) ,:	E	Er   