o
    )i	                     @   sP   d Z ddlmZmZ defddZdee fddZG d	d
 d
eZ	dd Z
dS )z
This file contains utilities for handling input from the user and registering specific keys to specific functions,
based on https://github.com/bchao1/bullet
   )KEYMAPget_characterkeyc                        fdd}|S )zR
    Mark the function with the key code so it can be handled in the register
    c                    s    t | dg }| g7 }|| _| S N
handle_keygetattrr   funchandler    [/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/accelerate/commands/menu/input.py	decorator   s   
zmark.<locals>.decoratorr   )r   r   r   r   r   mark      r   keysc                     r   )zS
    Mark the function with the key codes so it can be handled in the register
    c                    s   t | dg }| 7 }|| _| S r   r   r
   r   r   r   r   *   s   z mark_multiple.<locals>.decoratorr   )r   r   r   r   r   mark_multiple%   r   r   c                       s,   e Zd ZdZ fddZedd Z  ZS )
KeyHandlerz;
    Metaclass that adds the key handlers to the class
    c                    s\   t  | |||}t|dsi |_tj|_| D ]}t|dg }|D ]}||j|< q#q|S )Nkey_handlerr   )super__new__hasattrr   r   handle_inputvaluesr	   )clsnamebasesattrsnew_clsvaluehandled_keysr   	__class__r   r   r   8   s   
zKeyHandler.__new__c                 C   s<   t  }|td krt|}| j|}|r|| _|| S dS )zDFinds and returns the selected character if it exists in the handler	undefinedN)r   r   ordr   getcurrent_selection)r   charhandlerr   r   r   r   D   s   zKeyHandler.handle_input)__name__
__module____qualname____doc__r   staticmethodr   __classcell__r   r   r$   r   r   3   s
    r   c                 C   s   t | j| j| j S )z&Adds KeyHandler metaclass to the class)r   r,   	__bases____dict__copy)r   r   r   r   registerR   s   r5   N)r/   keymapr   r   strr   listr   typer   r5   r   r   r   r   <module>   s   