
    Mh                     r    d Z ddlZddlZddlmZ ddlmc mZ  G d de          Z	d Z
defdZd	 Zd
 ZdS )z3 Utilities for accessing the platform's clipboard.
    N)TryNextc                       e Zd ZdS )ClipboardEmptyN)__name__
__module____qualname__     U/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/IPython/lib/clipboard.pyr   r      s        Dr
   r   c                     	 ddl } n"# t          $ r}t          d          |d}~ww xY w|                                  	 |                     | j                  }ns# t          | j        f$ r_ 	 |                     | j                  }t          j
        |t          j                  }n!# t          | j        f$ r}t          |d}~ww xY wY nw xY w|                                  n# |                                  w xY w|S )zc Get the current clipboard's text on Windows.

    Requires Mark Hammond's pywin32 extensions.
    r   NziGetting text from the clipboard requires the pywin32 extensions: http://sourceforge.net/projects/pywin32/)win32clipboardImportErrorr   OpenClipboardGetClipboardDataCF_UNICODETEXT	TypeErrorerrorCF_TEXT	py3compatcast_unicodeDEFAULT_ENCODINGr   CloseClipboard)r   etexts      r   win32_clipboard_getr      sH   
U U U U M N NST	UU   """	(..~/LMM~+, ( ( (	(!22>3IJJD)$	0JKKDD>/0 	( 	( 	( a'	( D( 	%%''''%%''''Ks]    
&!&A C! C	+9B%$C	%C6B>>CC	C! C		C! !C7returnc                      t          j        g dt           j                  } |                                 \  }}|                    dd          }t          j        |          }|S )z' Get the clipboard's text on OS X.
    )pbpastez-Preferasciistdout      
)
subprocessPopenPIPEcommunicatereplacer   decode)pbytes_stderrr   s       r   osx_clipboard_getr-   '   sb     	888	  	  	 A]]__NFF^^E5))FF##DKr
   c                     	 ddl m} m} n"# t          $ r}t	          d          |d}~ww xY w |             }|                                 	 |                                }n# |$ r}t          |d}~ww xY w	 |                                 n# |                                 w xY wt          j
        |t          j                  }|S )z Get the clipboard's text using Tkinter.

    This is the default on systems that are not Windows or OS X. It may
    interfere with other UI toolkits and should be replaced with an
    implementation that uses that toolkit.
    r   )TkTclErrorzBGetting text from the clipboard on this platform requires tkinter.N)tkinterr/   r0   r   r   withdrawclipboard_getr   destroyr   r   r   )r/   r0   r   rootr   s        r   tkinter_clipboard_getr6   3   s    c((((((((( c c cZ[[abbc 244DMMOOO!!## $ $ $!#$ 	 	!$	(BCCDKs:    
*%*A!  B !A3&A..A33B B"c                     t           j                            d          dk    rt          d          	 t	          j        dgt          j                  5 } |                                 \  }}|                                 rt          |          	 ddd           n# 1 swxY w Y   n"# t          $ r}t          d          |d}~ww xY w|st          	 t          j        |          }n# t          $ r}t          |d}~ww xY w|S )zGet the clipboard's text under Wayland using wl-paste command.

    This requires Wayland and wl-clipboard installed and running.
    XDG_SESSION_TYPEwaylandzwayland is not detectedzwl-paster    NzzGetting text from the clipboard under Wayland requires the wl-clipboard extension: https://github.com/bugaevc/wl-clipboard)osenvirongetr   r$   r%   r&   r'   waitFileNotFoundErrorr   r   r)   UnicodeDecodeError)r*   rawerrr   r   s        r   wayland_clipboard_getrB   K   sd   
 
z~~())Y66/000	zl:?CCC 	#q}}HCvvxx #cll"#	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#    A
 
 	  $$$ $ $ $!#$ KsS   !B) ;BB) B!!B) $B!%B) )
C3CCC* *
D4C<<D)__doc__r:   r$   IPython.core.errorr   IPython.utils.py3compatutilsr   
ValueErrorr   r   strr-   r6   rB   r	   r
   r   <module>rI      s     
			     & & & & & & + + + + + + + + +	 	 	 	 	Z 	 	 	  0	3 	 	 	 	  0    r
   