a
    þdì  ã                   @   sl   d Z ddlZddlZddlmZ ejdkrLddlZddlZG dd„ dejƒZ	dd„ Z
d	d
„ Zedd„ ƒZdS )zv
A utility for showing and hiding the terminal cursor on Windows and Linux, based on https://github.com/bchao1/bullet
é    N)ÚcontextmanagerÚntc                   @   s    e Zd ZdejfdejfgZdS )Ú
CursorInfoÚsizeÚvisibleN)Ú__name__Ú
__module__Ú__qualname__ÚctypesÚc_intÚc_byteÚ_fields_© r   r   úh/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/accelerate/commands/menu/cursor.pyr      s   r   c                  C   sv   t jdkrRtƒ } tjj d¡}tjj |t | ¡¡ d| _	tjj 
|t | ¡¡ n t jdkrrtj d¡ tj ¡  d S )Nr   éõÿÿÿFÚposixz[?25l©ÚosÚnamer   r
   ÚwindllÚkernel32ZGetStdHandleZGetConsoleCursorInfoÚbyrefr   ZSetConsoleCursorInfoÚsysÚstdoutÚwriteÚflush©ÚciÚhandler   r   r   Úhide_cursor"   s    

r   c                  C   sv   t jdkrRtƒ } tjj d¡}tjj |t | ¡¡ d| _	tjj 
|t | ¡¡ n t jdkrrtj d¡ tj ¡  d S )Nr   r   Tr   z[?25hr   r   r   r   r   Úshow_cursor.   s    

r    c                   c   s$   zt ƒ  dV  W tƒ  ntƒ  0 dS )z+Context manager to hide the terminal cursorN)r   r    r   r   r   r   Úhide:   s    r!   )Ú__doc__r   r   Ú
contextlibr   r   r
   ÚmsvcrtÚ	Structurer   r   r    r!   r   r   r   r   Ú<module>   s   
