
    bi                         d Z ddlZddlZddlmZ ej
                  dk(  rddlZddlZ G d dej                        Z	d Z
d Zed	        Zy)
zv
A utility for showing and hiding the terminal cursor on Windows and Linux, based on https://github.com/bchao1/bullet
    N)contextmanagerntc                   D    e Zd Zdej                  fdej
                  fgZy)
CursorInfosizevisibleN)__name__
__module____qualname__ctypesc_intc_byte_fields_     Z/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/accelerate/commands/menu/cursor.pyr   r      s    V\\*Y,FGr   r   c                  6   t         j                  dk(  rt               } t        j                  j
                  j                  d      }t        j                  j
                  j                  |t        j                  |              d| _	        t        j                  j
                  j                  |t        j                  |              y t         j                  dk(  r>t        j                  j                  d       t        j                  j                          y y )Nr   Fposixz[?25losnamer   r   windllkernel32GetStdHandleGetConsoleCursorInfobyrefr   SetConsoleCursorInfosysstdoutwriteflushcihandles     r   hide_cursorr&   "   s    	ww$\''44S933FFLL<LM
33FFLL<LM	G	

%

 
r   c                  6   t         j                  dk(  rt               } t        j                  j
                  j                  d      }t        j                  j
                  j                  |t        j                  |              d| _	        t        j                  j
                  j                  |t        j                  |              y t         j                  dk(  r>t        j                  j                  d       t        j                  j                          y y )Nr   r   Tr   z[?25hr   r#   s     r   show_cursorr(   .   s    	ww$\''44S933FFLL<LM
33FFLL<LM	G	

%

 
r   c               #   \   K   	 t                d t                y# t                w xY ww)z+Context manager to hide the terminal cursorN)r&   r(   r   r   r   hider*   :   s     s   , ,),)__doc__r   r   
contextlibr   r   r   msvcrt	Structurer   r&   r(   r*   r   r   r   <module>r/      sZ    
 
 % 77d?HV%% H
		  r   