
    ;i	                     V    S r SSKJrJr  S\4S jrS\\   4S jr " S S\5      r	S	 r
g
)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                    ^  U 4S jnU$ )zJ
Mark the function with the key code so it can be handled in the register
c                 :   > [        U S/ 5      nUT/-  nXl        U $ N
handle_keygetattrr	   )funchandler   s     n/home/dmtnaga/Documents/work/airagagent/rag_env/lib/python3.13/site-packages/accelerate/commands/menu/input.py	decoratormark.<locals>.decorator   s&    |R03%      )r   r   s   ` r   markr          
 r   keysc                     ^  U 4S jnU$ )zK
Mark the function with the key codes so it can be handled in the register
c                 8   > [        U S/ 5      nUT-  nXl        U $ r   r
   )r   r   r   s     r   r    mark_multiple.<locals>.decorator*   s$    |R0$ r   r   )r   r   s   ` r   mark_multipler   %   r   r   c                   <   ^  \ rS rSrSrU 4S jr\S 5       rSrU =r	$ )
KeyHandler3   z3
Metaclass that adds the key handlers to the class
c                    > [         TU ]  XX#5      n[        US5      (       d  0 Ul        [        R
                  Ul        UR                  5        H'  n[        US/ 5      nU H  nXTR                  U'   M     M)     U$ )Nkey_handlerr	   )super__new__hasattrr   r   handle_inputvaluesr   )	clsnamebasesattrsnew_clsvaluehandled_keysr   	__class__s	           r   r    KeyHandler.__new__8   ss    '/#U:w.."$G)66\\^E"5,;L#+0##C( $ $ r   c                     [        5       nU[        S   :w  a  [        U5      nU R                  R	                  U5      nU(       a  Xl        U" U 5      $ g)zDFinds and returns the selected character if it exists in the handler	undefinedN)r   r   ordr   getcurrent_selection)r$   charhandlers      r   r"   KeyHandler.handle_inputD   sK     6+&&t9D//%%d+$(!3<r   r   )
__name__
__module____qualname____firstlineno____doc__r    staticmethodr"   __static_attributes____classcell__)r+   s   @r   r   r   3   s!    
 
 
r   r   c                 t    [        U R                  U R                  U R                  R	                  5       5      $ )z&Adds KeyHandler metaclass to the class)r   r5   	__bases____dict__copy)r$   s    r   registerrA   R   s&    cllCMM3<<3D3D3FGGr   N)r9   keymapr   r   strr   listr   typer   rA   r   r   r   <module>rF      s=   
 *c c  >Hr   