o
    :Fd                     @   s~   d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	 d dl
mZ d dlmZ d dlmZmZ dd
dZG dd deZd	S )    )PromptSession)get_app)Style)	DimensionFormattedTextControlWindow)CommandsHistory)get_error_message)styles_dict&INTERACTIVE_COMMANDS_HISTORY_FILE_NAMETNc              
   C   s<   t t}tt}dg}t|| r|nddddd||d}|S )z7
    Setup resources and create Oci Prompt Session
    )z	class:ociz> oci NT      )messagestyleZcomplete_while_typingdynamic_size	min_space	max_space	b_toolbarhistory)r   r   r   	from_dictr
   OciPromptSession)Zcolors_enabledbottom_toolbarZcli_interactive_historyr   Zcli_commandZsession r   >usr/lib/python3.10/site-packages/interactive/prompt_session.pycreate_oci_prompt_session   s    

r   c                       s8   e Zd Z				d	 fdd	Zdef fddZ  ZS )
r   NFr   c                    s   t  j|d|ji| || _t|d| _t|d| _|r0|j| _|j	| _
t| j| j d| _n
d| _d | _
| j| _ttdtdfgd| jj_d S )Nr   r   zclass:window-too-smallterminal_too_small)text)super__init__Zshow_toolbarr   maxr   r   sizebottom_toolbar_sizeZset_toolbar_textbottom_toolbar_msgZreserve_space_for_menur   r   r	   Zlayout	containerZwindow_too_small)selfr   r   r   r   argskwargs	__class__r   r   r   0   s    	zOciPromptSession.__init__returnc                    s   t   }t j jd }| js|}nt| j|}t|| j	 d}| j
r8| jjjr8|jr8t| jjjd ||_| jrH|dkrH| jtddd |S )zn
        Controls the Dimension height for prompt session and window_too_small error message handling
           r   r   T)Zis_error)r   "_get_default_buffer_control_heightr   outputZget_sizeZrowsr   minr   r!   r   Z	completerr    r"   r	   )r$   Z	dimensionheightZmax_window_sizer'   r   r   r+   R   s   
z3OciPromptSession._get_default_buffer_control_height)NFr   r   )__name__
__module____qualname__r   r   r+   __classcell__r   r   r'   r   r   /   s    "r   )TN)Zprompt_toolkitr   Zprompt_toolkit.applicationr   Zprompt_toolkit.stylesr   Zprompt_toolkit.layoutr   r   r   Zinteractive.commands_historyr   Zinteractive.error_messagesr	   Zinteractive.utilsr
   r   r   r   r   r   r   r   <module>   s   
