
    G@d	                     L    d Z ddlZddlmZ ddlmZ d Z G d de          ZdS )z7This module contains the close quotes editor extension.    N)QTextCursor)EditorExtensionc                     t          j        dd|           } t          j        dd|           } |                     d          dz  rdS |                     d          dz  rdS dS )a  Return whether a string has open quotes.

    This simply counts whether the number of quote characters of either
    type in the string is odd.

    Take from the IPython project (in IPython/core/completer.py in v0.13)
    Spyder team: Add some changes to deal with escaped quotes

    - Copyright (C) 2008-2011 IPython Development Team
    - Copyright (C) 2001-2007 Fernando Perez. <fperez@colorado.edu>
    - Copyright (C) 2001 Python Software Foundation, www.python.org

    Distributed under the terms of the BSD License.
    z
(?<!\\)\\' z
(?<!\\)\\""   ')resubcount)texts    Llib/python3.11/site-packages/spyder/plugins/editor/extensions/closequotes.pyunmatched_quotes_in_liner      si    $ 6-T**D6-T**D zz# s	C1	 sr    c                   $    e Zd ZdZd Zd Zd ZdS )CloseQuotesExtensionz9Editor Extension for insert closing quotes automatically.c                     |r&| j         j                            | j                   dS | j         j                            | j                   dS )z*Connect/disconnect sig_key_pressed signal.N)editorsig_key_pressedconnect_on_key_pressed
disconnect)selfstates     r   on_state_changedz%CloseQuotesExtension.on_state_changed4   sO     	IK'//0DEEEEEK'2243GHHHHHr   c                    |                                 rd S |                                }|dv rP| j        rK| j        j                                         |                     |           |                                 d S d S d S )N)r   r	   )
isAcceptedr   enabledr   completion_widgethide_autoinsert_quotesaccept)r   eventchars      r   r   z$CloseQuotesExtension._on_key_pressed;   s     	F
 zz||;4<K)..000##D)))LLNNNNN r   c                 0   | j                             dd          }| j                             dd          }| j                                         }| j                             dd          dd         }| j                             dd          dd         }| j                             dd                                          }| j                                         r| j                                         }| j                             d                    ||                     |                    t          j
        t          j        d           |                    t          j
        t          j        t          |                     | j                             |           dS | j                                         r| j                             |           dS t          |          d	k    r9t!          |          |k    s&|d	         d
vr| j                             |           dS t!          |          r%|d|z  k    s| j                             |           dS | j                                         |k    r[|                    t          j        t          j        d           |                                 | j                             |           dS |d|z  k    r| j                             d|z             | j                                         }|                    t          j        t          j        d           |                                 | j                             |           dS |d|z  k    r5| j                             |           | j                                          dS | j                             d|z             | j                                         }|                    t          j                   | j                             |           dS )zAControl how to automatically insert quotes in various situations.soleolcursorNz	{0}{1}{0}   r   ),:;)]}   r   )r   get_text
textCursorstriphas_selected_textget_selected_textinsert_textformatmovePositionr   Left
MoveAnchor
KeepAnchorlensetTextCursor
in_commentr   	next_charNextCharacterclearSelectionPreviousCharacterdelayed_popup_docstring)	r   r$   	line_textline_to_cursorr(   
last_threelast_twotrailing_textr   s	            r   r!   z'CloseQuotesExtension._autoinsert_quotesH   s   K((66	--eX>>''))[))%::233?
;''x88=,,Xu==CCEE;((** )	.;0022DK##K$6$6tT$B$BCCC 0+2H!LLL 0+2H #D		+ + +K%%f-----[##%% !	.K##D)))))-  1$$,^<<DD!!$(FFFK##D)))))&y11 	.1T6))K##D)))))[""$$,, 9 + 6; ; ;!!###K%%f-----1T6!!K##AdF+++[++--F = + 6; ; ;!!###K%%f----- 4K##D)))K//11111 K##AdF+++[++--F =>>>K%%f-----r   N)__name__
__module____qualname____doc__r   r   r!    r   r   r   r   1   sJ        CCI I I  2. 2. 2. 2. 2.r   r   )rN   r
   
qtpy.QtGuir   spyder.api.editorextensionr   r   r   rO   r   r   <module>rR      s    > = 				 # " " " " " 7 6 6 6 6 6  >I. I. I. I. I.? I. I. I. I. I.r   