
    ;i                        S r SSKrSSKrSSKrSr\" S5      \" S5      SS\-   S\-   S	\-   S
\-   S\R                  SSSSSS.r\S   \S'   \S   \S'   \R                  S:X  a=  / r	\S   \-
  \S   \-
  \S   \-
  \S   \-
  \S   \-
  \S   \-
  \S   \-
  \S   \-
  S.r
\" S5       H  r\" \" \5      5      \\" \5      '   M     S rS rg)zk
Utilities relating to parsing raw characters from the keyboard, based on https://github.com/bchao1/bullet
    N   	   A   B   C   D   [      2   3   5   6   )tabnewlineescupdownrightleftmod_int	undefined	interruptinsertdeletepg_uppg_downr   arrow_beginr   	arrow_endwin32r   r   )s   Hs    Hs   Ps    Ps   Ms    Ms   Ks    K
   c                     [         R                  S:X  Gap  SSKn SnU R                  5       (       a'  U R	                  5         U R                  5       (       a  M'  [        [        5      S:X  Ga  U R	                  5       nUS;   a  X R	                  5       -   n [        [        U   5      n[        R                  [        [        S   5      5        [        R                  U5        [        U5      [        S   S-
  S	-  [        S
   S-
  S	-  [        S   S-
  S	-  [        S   S-
  S	-  4;   a  [        R                  [        S5      5        [        [        S   5      nU$ UR                  U5      n U$ [        R                  S5      n U$ [         R                  S:X  a  SSKnSSKn["        R$                  R'                  5       nUR)                  U5      n UR+                  U5        ["        R$                  R-                  S5      nUR/                  XuR0                  U5        U$ W$ ! [         a	    US   n U$ f = f! UR/                  XuR0                  U5        f = f)zGets raw characters from inputsntr   Nmbcs)       r   r      	   r   r   r   ~   r   posix)osnamemsvcrtkbhitgetchlenWIN_CH_BUFFERchr
WIN_KEYMAPappendKEYMAPordKeyErrordecodepoptermiosttysysstdinfileno	tcgetattrsetrawread	tcsetattr	TCSADRAIN)	r.   encodingchch2chxr;   r<   fdold_settingss	            o/home/dmtnaga/Documents/work/airagagent/rag_env/lib/python3.13/site-packages/accelerate/commands/menu/keymap.pyget_raw_charsrL   ?   s   	ww$llnnLLN llnn}"B ''<<>) jo.C!((VI->)?@!((-3xx(1,1x(1,1w!+q0y)A-2	$  &,,SX6VE]+B$ I YYx( I ""1%B I 
G	YY((,	CJJrN"Bb"3"3\BI2I#    QB  I#   b"3"3\Bs   CH" 0H8 "H54H58Ic                     [        5       n [        U 5      [        S   [        S   4;   a  U $ [        U 5      [        S   :X  a  [        5       n[        U5      [        S   :X  ah  [        5       n[        U5      [        S   [        -
  :  a8  [        U5      [        S   [        -
  ::  a  [	        [        U5      [        -   5      $ [        S   $ [        5       $ U [
        R                  ;   a  U $ [        S   $ )z;Gets a character from the keyboard and returns the key coder   r   r   r   r   r    r   )rL   r7   r6   ARROW_KEY_FLAGr3   string	printable)charcombokeys      rK   get_characterrT   p   s    ?D
4yVK(&*;<<	TfUm	#u:	**/C3x6-0>AAc#hRXYdRehvRvFv3s8n455k** ?" 6###K+&&    )__doc__r,   rO   r=   rN   r7   maxsizer6   platformr2   r4   rangeistrrL   rT    rU   rK   <module>r]      s5   
  
  t94y
~
. 
" t} Vn{ <<7M,/,/.>1.>1/N2/N2.>1.>1	J 
rAQ[F3q6N 
.b'rU   