o
    œ©ZhB	  ã                   @   sR   d Z ddlZddlZddlmZ ddlZej d¡rdd„ Z	ndd„ Z	dd	„ Z
dS )
z;Enable pyglet to be used interactively with prompt_toolkit
é    N)Údefault_timerÚlinuxc                 C   s$   z|   ¡  W d S  ty   Y d S w ©N)ÚflipÚAttributeError©Úwindow© r	   ú\/var/www/html/lang_env/lib/python3.10/site-packages/IPython/terminal/pt_inputhooks/pyglet.pyr      s
   ÿr   c                 C   s   |   ¡  d S r   )r   r   r	   r	   r
   r      s   c                 C   s®   zLt ƒ }|  ¡ sJtj  ¡  tjjD ]}| ¡  | ¡  | d¡ t	|ƒ qt ƒ | }|dkr4t
 d¡ n|dkr>t
 d¡ nt
 d¡ |  ¡ rW dS W dS  tyV   Y dS w )aE  Run the pyglet event loop by processing pending events only.

    This keeps processing pending events until stdin is ready.  After
    processing all pending events, a call to time.sleep is inserted.  This is
    needed, otherwise, CPU usage is at 100%.  This sleep time should be tuned
    though for best performance.
    Zon_drawg      $@g      ð?gš™™™™™¹?gš™™™™™©?gü©ñÒMbP?N)ÚclockZinput_is_readyÚpygletZtickZappÚwindowsZ	switch_toZdispatch_eventsZdispatch_eventr   ÚtimeÚsleepÚKeyboardInterrupt)ÚcontextÚtr   Z	used_timer	   r	   r
   Ú	inputhook   s&   





äÿr   )Ú__doc__Úsysr   Ztimeitr   r   r   ÚplatformÚ
startswithr   r   r	   r	   r	   r
   Ú<module>   s    
