o
    :F¶dð
  ã                   @   s.   d dl mZ d dlmZ dZG dd„ dƒZdS )é    )ÚFormattedText)Úget_appz:[Tab/Enter] Autocomplete/Execute command   [Ctrl + D] Quitc                   @   sN   e Zd ZdZdd„ Zdd„ Zdefdd„Zd	d
„ Zddd„Z	de
fdd„ZdS )ÚBottomToolbara  
    This class is for designing the bottom toolbar of the CLI Interactive.
    the method show_toolbar() is being called from the prompt toolkit whenever the user presses any key.
    The method set_toolbar_text() is being called whenever the caller needs to show a message in the bottom toolbar,
    this message can be error message, success message or any other message. if error message, then the parameter
    is_error need to be set to True this way the color of the text will indicate that this is an error message
    c                 C   s   d| _ d| _d| _d S )NÚ Fé   )Ú_toolbar_textÚ	_is_errorÚsize©Úself© r   ú>usr/lib/python3.10/site-packages/interactive/bottom_toolbar.pyÚ__init__   s   
zBottomToolbar.__init__c                 C   s   | j rd| jfS d| jfS )zƒ
        This function adds the message above the horizontal line in the bottom toolbar

        :return: (string, string)
        zclass:bottom-toolbar.error.textzclass:bottom-toolbar.text)r   r   r
   r   r   r   Ú_add_toolbar_message_window   s   

z)BottomToolbar._add_toolbar_message_windowÚreturnc                 C   s   t ƒ j ¡ jd S )zu
        This function adds a horizontal line in the bottom toolbar above shortcuts

        :return: string
        ú-)r   ÚoutputZget_sizeÚcolumnsr
   r   r   r   Ú_add_line_before_shortcuts$   s   z(BottomToolbar._add_line_before_shortcutsc                 C   s   d| _ d| _d S )Nr   F©r   r   r
   r   r   r   Ú_reset_toolbar_message,   ó   
z$BottomToolbar._reset_toolbar_messageFc                 C   s   || _ || _d S )Nr   )r   Ztoolbar_textZis_errorr   r   r   Úset_toolbar_text0   r   zBottomToolbar.set_toolbar_textc                 C   sB   |   ¡ \}}|  ¡ }|  ¡  t||d fd|d fdtfgƒ}|S )zW
        This function defines toolbar display

        :return: FormattedText
        Ú
r   )r   r   r   r   ÚSHORT_CUTS_TEXT)r   Ztoolbar_styleZtoolbar_msgZ	dash_lineÚmessager   r   r   Úshow_toolbar4   s   

ýzBottomToolbar.show_toolbarN)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ústrr   r   r   r   r   r   r   r   r   r      s    
r   N)Zprompt_toolkit.formatted_textr   Zprompt_toolkit.applicationr   r   r   r   r   r   r   Ú<module>   s   