o
    j)                     @  s@  d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
mZmZmZmZ d dlmZ d dlmZmZmZmZ d dlmZ d d	lmZmZ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l%m&Z& d dl'm(Z(m)Z)m*Z*m+Z+ ddgZ,edZ-eZ.d2ddZ/G dd dee- Z0dddddddde1dd
d3d1dZ2dS )4    )annotations)Sequence)GenericTypeVar)Application)	ConditionFilterOrBoolis_donerenderer_height_is_known	to_filter)AnyFormattedText)DynamicKeyBindingsKeyBindingsKeyBindingsBasemerge_key_bindings)KeyPressEvent)AnyContainerConditionalContainerHSplitLayoutWindow)FormattedTextControl)	Dimension)	BaseStyleStyle)suspend_to_background_supported)BoxFrameLabel	RadioListChoiceInputchoice_Treturnr   c                   C  s   t dddS )Nz#884444bold)zframe.borderzselected-option)r   	from_dict r&   r&   /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/prompt_toolkit/shortcuts/choice_input.py!create_default_choice_input_style,   s
   r(   c                   @  sR   e Zd ZdZdddddddddeddd)dd Zd*d"d#Zd+d%d&Zd+d'd(ZdS ),r    aX  
    Input selection prompt. Ask the user to choose among a set of options.

    Example usage::

        input_selection = ChoiceInput(
            message="Please select a dish:",
            options=[
                ("pizza", "Pizza with mushrooms"),
                ("salad", "Salad with tomatoes"),
                ("sushi", "Sushi"),
            ],
            default="pizza",
        )
        result = input_selection.prompt()

    :param message: Plain text or formatted text to be shown before the options.
    :param options: Sequence of ``(value, label)`` tuples. The labels can be
        formatted text.
    :param default: Default value. If none is given, the first option is
        considered the default.
    :param mouse_support: Enable mouse support.
    :param style: :class:`.Style` instance for the color scheme.
    :param symbol: Symbol to be displayed in front of the selected choice.
    :param bottom_toolbar: Formatted text or callable that returns formatted
        text to be displayed at the bottom of the screen.
    :param show_frame: `bool` or
        :class:`~prompt_toolkit.filters.Filter`. When True, surround the input
        with a frame.
    :param show_numbers: Whether to show the option numbers in front of each choice.
    :param enable_interrupt: `bool` or
        :class:`~prompt_toolkit.filters.Filter`. When True, raise
        the ``interrupt_exception`` (``KeyboardInterrupt`` by default) when
        control-c has been pressed.
    :param interrupt_exception: The exception type that will be raised when
        there is a keyboard interrupt (control-c keypress).
    NF>T)defaultmouse_supportstylesymbolbottom_toolbar
show_frameshow_numbersenable_suspendenable_interruptinterrupt_exceptionkey_bindingsmessager   options%Sequence[tuple[_T, AnyFormattedText]]r*   	_T | Noner+   boolr,   BaseStyle | Noner-   strr.   r/   r   r0   r1   r2   r3   type[BaseException]r4   KeyBindingsBase | Noner#   Nonec                C  s`   |d u rt  }|| _|| _|| _|| _|| _|| _|| _|	| _|
| _	|| _
|| _|| _|| _d S N)r(   r5   r*   r6   r+   r,   r-   r/   r0   r1   r3   r2   r.   r4   )selfr5   r6   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r&   r&   r'   __init__\   s   
zChoiceInput.__init__Application[_T]c                   s  t jjddjddjddddddd tttjdd	d
ddd
dt d
ddd
dg}t	d1fdd}t	fddt
 @ t@ }tt|||d}tttfddddddtddd|d}tt|tt |d|g d}t }|jdddd2 fd"d#}t	d1fd$d%}|jd&|d|jd'|dd2fd(d)}	t	t}
t	d1fd*d+}|jd,|
|@ dd2d-d.}t|djt|tfd/dgjd0S )3NT Fzclass:input-selectionzclass:optionzclass:selected-optionzclass:number)valuesr*   select_on_focusopen_characterselect_characterclose_charactershow_cursorr0   container_styledefault_styleselected_stylechecked_stylenumber_styleshow_scrollbar)textdont_extend_heightr      )padding_toppadding_leftpadding_rightpadding_bottom   r#   r9   c                        t  j S r?   )r   r/   r&   r@   r&   r'   show_frame_filter      z:ChoiceInput._create_application.<locals>.show_frame_filterc                     s
    j d uS r?   r.   r&   rY   r&   r'   <lambda>   s   
 z1ChoiceInput._create_application.<locals>.<lambda>)alternative_contentfilterc                         j S r?   r\   r&   rY   r&   r'   r]          zclass:bottom-toolbar.text)r,   zclass:bottom-toolbar)min)r,   rQ   height)r_   )focused_elemententer)eagereventEr>   c                   s   | j j jdd dS )z)Accept input when enter has been pressed.zclass:accepted)resultr,   N)appexitcurrent_valuerg   )
radio_listr&   r'   _accept_input   s   z6ChoiceInput._create_application.<locals>._accept_inputc                     rX   r?   )r   r2   r&   rY   r&   r'   r2      r[   z9ChoiceInput._create_application.<locals>.enable_interruptzc-cz<sigint>c                   s   | j j  dd dS )z&Abort when Control-C has been pressed.zclass:aborting)	exceptionr,   N)rj   rk   r3   rm   rY   r&   r'   _keyboard_interrupt   s   z<ChoiceInput._create_application.<locals>._keyboard_interruptc                     rX   r?   )r   r1   r&   rY   r&   r'   r1      r[   z7ChoiceInput._create_application.<locals>.enable_suspendzc-zc                 S  s   | j   dS )z8
            Suspend process to background.
            N)rj   suspend_to_backgroundrm   r&   r&   r'   _suspend   s   z1ChoiceInput._create_application.<locals>._suspendc                     r`   r?   )r4   r&   rY   r&   r'   r]      ra   )layoutfull_screenr+   r4   r,   )r#   r9   )rg   rh   r#   r>   )r   r6   r*   r-   r0   r   r   r   r5   r   r	   r
   r   r   r   r   r   r   r   addr   r   r+   r   r   r,   )r@   	containerrZ   show_bottom_toolbarr.   rt   kbro   r2   rq   suspend_supportedr1   rs   r&   )rn   r@   r'   _create_application~   s   zChoiceInput._create_applicationr"   c                 C  s   |    S r?   )r{   runrY   r&   r&   r'   prompt   s   zChoiceInput.promptc                   s   |    I d H S r?   )r{   	run_asyncrY   r&   r&   r'   prompt_async   s   zChoiceInput.prompt_async)r5   r   r6   r7   r*   r8   r+   r9   r,   r:   r-   r;   r.   r   r/   r   r0   r9   r1   r   r2   r   r3   r<   r4   r=   r#   r>   )r#   rB   )r#   r"   )	__name__
__module____qualname____doc__KeyboardInterruptrA   r{   r}   r   r&   r&   r&   r'   r    5   s"    +
"
wNFr)   T)
r*   r+   r,   r-   r.   r/   r1   r2   r3   r4   r5   r   r6   r7   r*   r8   r+   r9   r,   r:   r-   r;   r.   r/   r1   r   r2   r3   r<   r4   r=   c                C  s(   t t | |||||||||	|
|d S )a  
    Choice selection prompt. Ask the user to choose among a set of options.

    Example usage::

        result = choice(
            message="Please select a dish:",
            options=[
                ("pizza", "Pizza with mushrooms"),
                ("salad", "Salad with tomatoes"),
                ("sushi", "Sushi"),
            ],
            default="pizza",
        )

    :param message: Plain text or formatted text to be shown before the options.
    :param options: Sequence of ``(value, label)`` tuples. The labels can be
        formatted text.
    :param default: Default value. If none is given, the first option is
        considered the default.
    :param mouse_support: Enable mouse support.
    :param style: :class:`.Style` instance for the color scheme.
    :param symbol: Symbol to be displayed in front of the selected choice.
    :param bottom_toolbar: Formatted text or callable that returns formatted
        text to be displayed at the bottom of the screen.
    :param show_frame: `bool` or
        :class:`~prompt_toolkit.filters.Filter`. When True, surround the input
        with a frame.
    :param enable_interrupt: `bool` or
        :class:`~prompt_toolkit.filters.Filter`. When True, raise
        the ``interrupt_exception`` (``KeyboardInterrupt`` by default) when
        control-c has been pressed.
    :param interrupt_exception: The exception type that will be raised when
        there is a keyboard interrupt (control-c keypress).
    r5   r6   r*   r+   r,   r-   r.   r/   r1   r2   r3   r4   )r    r"   r}   r   r&   r&   r'   r!      s    2)r#   r   )r5   r   r6   r7   r*   r8   r+   r9   r,   r:   r-   r;   r.   r   r/   r9   r1   r   r2   r   r3   r<   r4   r=   r#   r"   )3
__future__r   collections.abcr   typingr   r   prompt_toolkit.applicationr   prompt_toolkit.filtersr   r   r	   r
   r   prompt_toolkit.formatted_textr   'prompt_toolkit.key_binding.key_bindingsr   r   r   r   (prompt_toolkit.key_binding.key_processorr   prompt_toolkit.layoutr   r   r   r   r   prompt_toolkit.layout.controlsr   prompt_toolkit.layout.dimensionr   prompt_toolkit.stylesr   r   prompt_toolkit.utilsr   prompt_toolkit.widgetsr   r   r   r   __all__r"   rh   r(   r    r   r!   r&   r&   r&   r'   <module>   sB    
	 L