o
    �õ±j
  ã                   @  sÎ   d dl mZ d dlZejdksJ ‚d dlmZmZ d dlmZm	Z	 d dl
mZmZ d dlmZ d dlmZ d	d
lmZ d	dlmZ d	dlmZ d	dlmZ dgZd	ZdZG dd„ dƒZe e¡ ddd„ZdS )é    )ÚannotationsNÚwin32)ÚbyrefÚwindll)ÚDWORDÚHANDLE)ÚAnyÚTextIO©ÚSize)ÚSTD_OUTPUT_HANDLEé   )ÚOutput)Ú
ColorDepth)ÚVt100_Output)ÚWin32OutputÚWindows10_Outputé   c                   @  sJ   e Zd ZdZ	ddd	d
„Zddd„Zeddd„ƒZddd„Zddd„Z	dS )r   zV
    Windows 10 output abstraction. This enables and uses vt100 escape sequences.
    NÚstdoutr	   Údefault_color_depthúColorDepth | NoneÚreturnÚNonec                 C  s>   || _ t||d�| _t|dd„ |d�| _ttj t	¡ƒ| _
d S )N)r   c                   S  s
   t ddƒS )Nr   r
   © r   r   ú’/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/prompt_toolkit/output/windows10.pyÚ<lambda>'   s   
 z+Windows10_Output.__init__.<locals>.<lambda>)r   r   Úwin32_outputr   Úvt100_outputr   r   Úkernel32ÚGetStdHandler   Ú	_hconsole)Úselfr   r   r   r   r   Ú__init__!   s   
ÿzWindows10_Output.__init__c              
   C  sh   t dƒ}tj | jt|ƒ¡ tj | jt ttB ƒ¡ z| j	 
¡  W tj | j|¡ dS tj | j|¡ w )z3
        Write to output stream and flush.
        r   N)r   r   r   ÚGetConsoleModer    r   ÚSetConsoleModeÚENABLE_PROCESSED_INPUTÚ"ENABLE_VIRTUAL_TERMINAL_PROCESSINGr   Úflush)r!   Úoriginal_moder   r   r   r'   +   s   
þ&zWindows10_Output.flushÚboolc                 C  s   dS )NFr   ©r!   r   r   r   Úresponds_to_cpr@   s   z Windows10_Output.responds_to_cprÚnameÚstrr   c                 C  s    |dv r
t | j|ƒS t | j|ƒS )N)Úget_sizeÚget_rows_below_cursor_positionÚscroll_buffer_to_promptÚget_win32_screen_buffer_info)Úgetattrr   r   )r!   r,   r   r   r   Ú__getattr__D   s   
zWindows10_Output.__getattr__r   c                 C  s   | j dur| j S tjS )z¨
        Return the default color depth for a windows terminal.

        Contrary to the Vt100 implementation, this doesn't depend on a $TERM
        variable.
        N)r   r   Ú
TRUE_COLORr*   r   r   r   Úget_default_color_depthX   s   
	z(Windows10_Output.get_default_color_depth)N)r   r	   r   r   r   r   )r   r   ©r   r)   )r,   r-   r   r   )r   r   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r"   r'   Úpropertyr+   r3   r5   r   r   r   r   r      s    ÿ


r   r)   c               
   C  sx   t jdkrdS ttj t¡ƒ} tdƒ}tj | t	|ƒ¡ ztj 
| tttB ƒ¡}|dkW tj 
| |¡ S tj 
| |¡ w )z_
    Returns True when we're running Windows and VT100 escape sequences are
    supported.
    r   Fr   r   )ÚsysÚplatformr   r   r   r   r   r   r#   r   r$   r%   r&   )Úhconsoler(   Úresultr   r   r   Úis_win_vt100_enabledo   s   
ÿ r@   r6   )Ú
__future__r   r<   r=   Úctypesr   r   Úctypes.wintypesr   r   Útypingr   r	   Úprompt_toolkit.data_structuresr   Úprompt_toolkit.win32_typesr   Úbaser   Úcolor_depthr   Úvt100r   r   r   Ú__all__r%   r&   r   Úregisterr@   r   r   r   r   Ú<module>   s&    ÿ
P