
    /h9                         S r SSKrSSKrSSKJr  SSKJrJr  SSKJ	r	J
r
JrJrJrJrJr  SSKJr  S	r \" S
5      r\R(                   " S S5      5       rg! \ a     N"f = f)zO
Main driver for the selection menu, based on https://github.com/bchao1/bullet
    N   )_is_package_available   )cursorinput)	Direction
clear_line
forceWrite	linebreakmove_cursorreset_cursor
writeColor)KEYMAPFzgoogle.colabc                      \ rS rSrSrS/ 4S\S\4S jjrSS\4S jjrS	\	4S
 jr
SS\S\	4S jjr\R                  " \S   5      S 5       r\R                  " \S   5      S 5       r\R                  " \S   5      S 5       r\R                  " \S   5      S 5       r\R(                  " \" S5       V VVVs/ s H  n[        [        U5         PM     snnnn 6 S 5       rSS\	4S jjrSrgs  snnnn f )
BulletMenu#   zJ
A CLI menu to select a choice from a list of choices using the keyboard.
Npromptchoicesc                 p    SU l         X l        Xl        [        R                  S:X  a  SU l        g SU l        g )Nr   win32*u   ➔ )positionr   r   sysplatform
arrow_char)selfr   r   s      a/home/james-whalen/.local/lib/python3.13/site-packages/accelerate/commands/menu/selection_menu.py__init__BulletMenu.__init__)   s-    <<7"!DO$DO    endc                     [         R                  S:w  a  [        U R                  U   SU5        g [	        U R                  U   U5        g )Nr       )r   r   r   r   r
   )r   indexr!   s      r   write_choiceBulletMenu.write_choice2   s6    <<7"t||E*B4t||E*C0r    r$   c                     XR                   :X  a+  [        SU R                   S35        U R                  U5        O[        SU R                  U    35        [        5         g)z$Prints the choice at the given index z    N)r   r
   r   r%   r   r   )r   r$   s     r   print_choiceBulletMenu.print_choice8   sN    MM!4??+1-.e$dll51234r    	direction
num_spacesc                    U R                   nU[        R                  :X  a=  U R                   S-   [        U R                  5      :  a  gU =R                   U-  sl         O)U R                   S-
  S:  a  gU =R                   U-  sl         [        5         U R                  U5        [        X!R                  5        U R                  U R                   5        g)zLShould not be directly called, used to move a direction of either up or downr   Nr   )	r   r   DOWNlenr   r	   r)   r   name)r   r+   r,   old_positions       r   move_directionBulletMenu.move_directionA   s    }}	&}}q C$55MMZ'M}}q 1$MMZ'M,'J/$--(r    upc                 B    U R                  [        R                  5        g N)r2   r   UPr   s    r   move_upBulletMenu.move_upQ   s    ILL)r    downc                 B    U R                  [        R                  5        g r6   )r2   r   r.   r8   s    r   	move_downBulletMenu.move_downU   s    INN+r    newlinec                 r    [        [        U R                  5      U R                  -
  S5        U R                  $ Nr.   )r   r/   r   r   r8   s    r   selectBulletMenu.selectY   s(    C%5v>}}r    	interruptc                 f    [        [        U R                  5      U R                  -
  S5        [        erA   )r   r/   r   r   KeyboardInterruptr8   s    r   rD   BulletMenu.interrupt^   s$    C%5v>r    
   c                 v   [        [        U R                  5      5      nXR                  -
  nXR                  :X  a  g U[	        U R
                  5      :  ad  U R                  U:  a"  U R                  [        R                  U* 5        g U R                  U:  a!  U R                  [        R                  U5        g g g r6   )
intchrcurrent_selectionr   r/   r   r2   r   r7   r.   )r   r$   movements      r   
select_rowBulletMenu.select_rowc   s    C../0==(MM!3t||$$}}u$##ILL8)<&##INNH=r    default_choicec                 P   U R                   (       aD  [        5         [        U R                   S5        [        (       a  [        SS5        O[        SS5        Xl        [        [        U R                  5      5       H  nU R                  U5        [        S5        M!     [        [        U R                  5      U R                  -
  S5        [        R                  " 5           [        (       a    [        [        R                  " 5       5      nOU R!                  5       nUbe  [#        5         [        [        U R                  5      S-   5       H  n[        SS5        [%        5         M     U R'                  US5        UsSSS5        $ M  ! [         a    Un Nxf = f! , (       d  f       g= f)z-Start the menu and return the selected choice
z>Please input a choice index (starting from 0), and press enterzOPlease select a choice using the arrow or number keys, and selecting with enterr7   Nr   )r   r   r
   in_colabr   ranger/   r   r)   r   r   hiderJ   builtinsr   
ValueErrorhandle_inputr   r	   r%   )r   rP   ichoice_s        r   runBulletMenu.runs   s5   ;;Kt{{D)x[]ablnrs&s4<<()Aa t * 	C%5t<[[]80!$X^^%5!6 "..0F% N"3t||#4q#89#At," : %%fd3! ] & 0!/0 ]s7   F,F
A/FFFFFF
F%)r   r   r   r   ) )r   )r   )__name__
__module____qualname____firstlineno____doc__strlistr   r%   rJ   r)   r   r2   r   markr   r9   r=   rB   rD   mark_multiplerT   rN   r\   __static_attributes__).0numberr   rd   s   0000r   r   r   #   s%    &*2 %s %D %1s 1# )	 )s )  ZZt* * ZZv,  , ZZy!" # ZZ{#$  %  U2YGY66#f+.YGH I"# " "! Hs   6C+r   )rc   rV   r   utils.importsr   r^   r   r   helpersr   r	   r
   r   r   r   r   keymapr   rS   ModuleNotFoundErrorregisterr    r    r   <module>rq      sn     
 2  h h h  	$^4H
 l" l" l"  		s   A AA