o
    ¹e  ã                   @   s|  d dl mZmZmZ d dlZd dlmZ d dlT d dlmZm	Z	 d dl
mZmZ ejjZejge_eje_ejjZejjZejge_eje_ejjZejeege_ejjZejejge_eje_ejjZege_ejjZg e_ejj Z eje!ge _ej"e _ejj#Z#ej"ge#_e$e#_ejj%Z%ege%_ejjj&Z'e(e'_e(e(e!ge'_dd„ Z)dd	„ Z*d
d„ Z+dd„ Z,e-dkr¼e+ƒ Z.e/e.ƒ dS dS )é    )Úabsolute_importÚprint_functionÚunicode_literalsN)Ú*)ÚCF_UNICODETEXTÚGHND)Ú
ensure_strÚensure_unicodec                  C   s*   t dƒ tdƒ} | rt| ƒ} | s
tƒ  d S ©Nr   )ÚOpenClipboardÚEnumClipboardFormatsÚCloseClipboard)Úq© r   úUD:\Projects\ConvertPro\env\Lib\site-packages\pyreadline3/clipboard/win32_clipboard.pyÚenumR   s   ÿ
r   c                 C   s0   t dƒ}t|ƒ}tdƒ t| ||ƒ tƒ  |jS )Nzd                                                                                                    r   )Úc_bufferÚsizeofr   ÚGetClipboardFormatNamer   Úvalue)ÚformatÚbufferÚ
bufferSizer   r   r   ÚgetformatnameZ   s   r   c                  C   s6   d} t dƒrttƒ}|rtt|ƒƒ} t|ƒ tƒ  | S )NÚ r   )r   ÚGetClipboardDatar   Ú
wstring_atÚ
GlobalLockÚGlobalUnlockr   )ÚtextZhClipMemr   r   r   ÚGetClipboardTextc   s   r    c                 C   s‚   t t| ƒƒ}t|ƒ}ttt|ƒƒ}tt_t|ƒ}t	t
|tƒt
t|ƒtƒt|ƒƒ tt|ƒƒ tdƒr?tƒ  tt|ƒ tƒ  d S d S r
   )Úcreate_unicode_bufferr	   r   ÚGlobalAllocr   Úc_size_tÚc_void_pr   ÚrestypeÚ_strncpyÚcastÚ	c_wchar_pÚ	addressofr   Úc_intr   ÚEmptyClipboardÚSetClipboardDatar   r   )r   r   r   Z
hGlobalMemZlpGlobalMemr   r   r   ÚSetClipboardTextn   s   
þ

ýr-   Ú__main__)0Ú
__future__r   r   r   ÚctypesZctypes.wintypesÚwintypesZ pyreadline3.keysyms.winconstantsr   r   Zpyreadline3.unicode_helperr   r	   ÚwindllZuser32r   ÚHWNDÚargtypesÚBOOLr%   r+   r   ÚUINTÚHANDLEZGetClipboardFormatNameAr   Úc_char_pr*   r,   r   r   Úkernel32r"   r#   ÚHGLOBALr   r$   r   Z	lstrcpynWr&   r(   r   r   r    r-   Ú__name__ÚtxtÚprintr   r   r   r   Ú<module>   sR   "



	þ