§
    ŒŸjcž  ã                  óö  — U d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZmZmZ ddlmZ ddlmZ ddlmZmZmZ d	gZ ej        d
¦  «        Z ej        d¦  «        Z ej        d¦  «        Z ej        d¦  «        Z ej        d¦  «        Z ej        d¦  «        Z ee	edf          ej         ¦   «         ¦  «        Z!de"d<    G d„ dee         ¦  «        Z# G d„ d¦  «        Z$ G d„ d	¦  «        Z%dS )zB
The `Document` that implements all the text operations/querying.
é    )ÚannotationsN)ÚCallableÚDictÚIterableÚListÚNoReturnÚPatternÚcasté   )ÚClipboardData)Úvi_mode)Ú	PasteModeÚSelectionStateÚSelectionTypeÚDocumentz ([a-zA-Z0-9_]+|[^a-zA-Z0-9_\s]+)z!^([a-zA-Z0-9_]+|[^a-zA-Z0-9_\s]+)z&^(([a-zA-Z0-9_]+|[^a-zA-Z0-9_\s]+)\s*)z([^\s]+)z	^([^\s]+)z^([^\s]+\s*)Ú_DocumentCachezdict[str, _DocumentCache]Ú_text_to_document_cachec                  ó>   — e Zd ZdZd	d„ZeZeZeZeZeZ	eZ
eZeZeZdS )
Ú_ImmutableLineListz‡
    Some protection for our 'lines' list, which is assumed to be immutable in the cache.
    (Useful for detecting obvious bugs.)
    ÚaÚobjectÚkwÚreturnr   c                ó    — t          d¦  «        ‚)Nz$Attempt to modify an immutable list.)ÚNotImplementedError)Úselfr   r   s      úd/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/prompt_toolkit/document.pyÚ_errorz_ImmutableLineList._error6   s   € Ý!Ð"HÑIÔIÐIó    N)r   r   r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__setitem__ÚappendÚclearÚextendÚinsertÚpopÚremoveÚreverseÚsort© r   r   r   r   0   s_   € € € € € ðð ð
Jð Jð Jð Jð €KØ€FØ€EØ€FØ€FØ
€CØ€FØ€GØ€D€D€Dr   r   c                  ó   — e Zd Zdd„ZdS )r   r   ÚNonec                ó"   — d | _         d | _        d S ©N)ÚlinesÚline_indexes©r   s    r   Ú__init__z_DocumentCache.__init__E   s   € à04ˆŒ
ð /3ˆÔÐÐr   N)r   r/   )r    r!   r"   r5   r-   r   r   r   r   D   s(   € € € € € ð3ð 3ð 3ð 3ð 3ð 3r   c                  óð  — e Zd ZdZdZ	 	 	 dydzd„Zd{d„Zd|d„Zed{d„¦   «         Z	ed}d„¦   «         Z
ed~d„¦   «         Zed{d„¦   «         Zed{d„¦   «         Zed{d„¦   «         Zed{d„¦   «         Zed{d„¦   «         Zed{d„¦   «         Zedd„¦   «         Zed€d „¦   «         Zedd!„¦   «         Zed}d"„¦   «         Zed{d#„¦   «         Zed{d$„¦   «         Zd�d‚d'„Zedƒd(„¦   «         Zedƒd)„¦   «         Zed}d*„¦   «         Zed}d+„¦   «         Zd„d.„Zd„d/„Zd…d2„Zedƒd3„¦   «         Z edƒd4„¦   «         Z!d†d6„Z"	 	 	 	 d‡dˆd=„Z#d‰dŠd>„Z$	 	 	 d‹dŒd?„Z%	 d�dŽdC„Z&	 d�d�dD„Z'	 d�d‘dE„Z(	 	 	 d’d“dH„Z)d‰d”dI„Z*	 d•d–dJ„Z+	 d—d˜dK„Z,	 d•d–dL„Z-	 d•d–dM„Z.	 d™dšdP„Z/	 d™dšdQ„Z0d™d›dR„Z1d™d›dS„Z2	 dœd�dU„Z3	 dœd�dV„Z4	 dždŸdZ„Z5	 džd d\„Z6	 d¡d¢d]„Z7d}d^„Z8d}d_„Z9d‰d£da„Z:d}db„Z;d}dc„Z<d¤de„Z=d¥df„Z>d¦dh„Z?d§dj„Z@d¨dl„ZAeBjC        d8fd©dq„ZDd}dr„ZEd•dªdt„ZFd•d«dv„ZGd¬dw„ZHd¬dx„ZIdS )­r   a¡  
    This is a immutable class around the text and cursor position, and contains
    methods for querying this data, e.g. to give the text before the cursor.

    This class is usually instantiated by a :class:`~prompt_toolkit.buffer.Buffer`
    object, and accessed as the `document` property of that class.

    :param text: string
    :param cursor_position: int
    :param selection: :class:`.SelectionState`
    )Ú_textÚ_cursor_positionÚ
_selectionÚ_cacheÚ NÚtextÚstrÚcursor_positionú
int | NoneÚ	selectionúSelectionState | Noner   r/   c           	     óp  — |�=|t          |¦  «        k    s*J t          d|›dt          |¦  «        ›�¦  «        ¦   «         ‚|€t          |¦  «        }|| _        || _        || _        	 t
          | j                 | _        d S # t          $ r+ t          ¦   «         | _        | j        t
          | j        <   Y d S w xY w)Nzcursor_position=z, len_text=)
ÚlenÚAssertionErrorr7   r8   r9   r   r<   r:   ÚKeyErrorr   )r   r<   r>   r@   s       r   r5   zDocument.__init__\   sÏ   € ð Ð&¨/½SÀ¹Y¼YÒ*FÐ*FÐ*FÍØJ˜ÐJÐJ½SÀ¹Y¼YÐJÐJñI
ô I
Ñ*FÔ*FÐ*Fð Ð"Ý! $™iœiˆOð
 ˆŒ
Ø /ˆÔØ#ˆŒð	=Ý1°$´)Ô<ˆDŒKˆKˆKøÝð 	=ð 	=ð 	=Ý(Ñ*Ô*ˆDŒKØ15´Õ# D¤IÑ.Ð.Ð.Ð.ð	=øøøs   Á'B  Â 1B5Â4B5c                ó@   — | j         j        › d| j        ›d| j        ›d�S )Nú(z, ú))Ú	__class__r    r<   r>   r4   s    r   Ú__repr__zDocument.__repr__ƒ   s+   € Ø”.Ô)ÐTÐT¨D¬IÐTÐT¸4Ô;OÐTÐTÐTÐTr   Úotherr   Úboolc                ó�   — t          |t          ¦  «        sdS | j        |j        k    o| j        |j        k    o| j        |j        k    S )NF)Ú
isinstancer   r<   r>   r@   )r   rK   s     r   Ú__eq__zDocument.__eq__†   sP   € Ý˜%¥Ñ*Ô*ð 	Ø�5ð ŒI˜œÒ#ð 2ØÔ$¨Ô(=Ò=ð2à” %¤/Ò1ð	
r   c                ó   — | j         S )zThe document text.)r7   r4   s    r   r<   zDocument.text�   s   € ð ŒzÐr   Úintc                ó   — | j         S )zThe document cursor position.)r8   r4   s    r   r>   zDocument.cursor_position•   s   € ð Ô$Ð$r   c                ó   — | j         S )z :class:`.SelectionState` object.)r9   r4   s    r   r@   zDocument.selectionš   s   € ð ŒÐr   c                ó0   — |                       d¦  «        pdS )z1Return character under cursor or an empty string.r   r;   ©Ú_get_char_relative_to_cursorr4   s    r   Úcurrent_charzDocument.current_charŸ   s   € ð ×0Ò0°Ñ3Ô3Ð9°rÐ9r   c                ó0   — |                       d¦  «        pdS )z6Return character before the cursor or an empty string.éÿÿÿÿr;   rU   r4   s    r   Úchar_before_cursorzDocument.char_before_cursor¤   s   € ð ×0Ò0°Ñ4Ô4Ð:¸Ð:r   c                ó*   — | j         d | j        …         S r1   ©r<   r>   r4   s    r   Útext_before_cursorzDocument.text_before_cursor©   s   € àŒyÐ1˜4Ô/Ð1Ô2Ð2r   c                ó*   — | j         | j        d …         S r1   r\   r4   s    r   Útext_after_cursorzDocument.text_after_cursor­   s   € àŒy˜Ô-Ð/Ð/Ô0Ð0r   c                óB   — | j                              d¦  «        \  }}}|S )z1Text from the start of the line until the cursor.ú
)r]   Ú
rpartition)r   Ú_r<   s      r   Úcurrent_line_before_cursorz#Document.current_line_before_cursor±   s%   € ð Ô,×7Ò7¸Ñ=Ô=‰
ˆˆ1ˆdØˆr   c                óB   — | j                              d¦  «        \  }}}|S )z/Text from the cursor until the end of the line.ra   )r_   Ú	partition)r   r<   rc   s      r   Úcurrent_line_after_cursorz"Document.current_line_after_cursor·   s%   € ð Ô+×5Ò5°dÑ;Ô;‰
ˆˆa�Øˆr   ú	list[str]c                ó”   — | j         j        €1t          | j                             d¦  «        ¦  «        | j         _        | j         j        S )z)
        Array of all the lines.
        Nra   )r:   r2   r   r<   Úsplitr4   s    r   r2   zDocument.lines½   s:   € ð Œ;ÔÐ$Ý 2°4´9·?²?À4Ñ3HÔ3HÑ IÔ IˆDŒKÔàŒ{Ô Ð r   ú	list[int]c                ó  — | j         j        €qt          t          | j        ¦  «        }dg}|j        }d}|D ]}||dz   z  } ||¦  «         Œt          |¦  «        dk    r|                     ¦   «          || j         _        | j         j        S )zG
        Array pointing to the start indexes of all the lines.
        Nr   r   )r:   r3   ÚmaprC   r2   r%   r)   )r   Úline_lengthsÚindexesr%   ÚposÚline_lengths         r   Ú_line_start_indexeszDocument._line_start_indexesÈ   s–   € ð Œ;Ô#Ð+å�s D¤JÑ/Ô/ˆLð �cˆGØ”^ˆFØˆCà+ð ð �Ø�{ Q‘Ñ&�Ø��s‘”��õ �7‰|Œ|˜aÒÐØ—’‘”�à'.ˆDŒKÔ$àŒ{Ô'Ð'r   c                ó*   — | j         | j        d…         S )zY
        Array of the lines starting from the current line, until the last line.
        N)r2   Úcursor_position_rowr4   s    r   Úlines_from_currentzDocument.lines_from_currentä   s   € ð
 Œz˜$Ô2Ð4Ð4Ô5Ð5r   c                ó*   — t          | j        ¦  «        S )z‰Return the number of lines in this document. If the document ends
        with a trailing \n, that counts as the beginning of a new line.)rC   r2   r4   s    r   Ú
line_countzDocument.line_countë   s   € õ �4”:‰ŒÐr   c                ó    — | j         | j        z   S )zuReturn the text on the line where the cursor is. (when the input
        consists of just one line, it equals `text`.)rd   rg   r4   s    r   Úcurrent_linezDocument.current_lineñ   s   € ð Ô.°Ô1OÑOÐOr   c                ó†   — | j         }t          |¦  «        t          |                     ¦   «         ¦  «        z
  }|d|…         S )z>The leading whitespace in the left margin of the current line.N)ry   rC   Úlstrip)r   ry   Úlengths      r   Ú"leading_whitespace_in_current_linez+Document.leading_whitespace_in_current_line÷   sA   € ð Ô(ˆÝ�\Ñ"Ô"¥S¨×)<Ò)<Ñ)>Ô)>Ñ%?Ô%?Ñ?ˆØ˜G˜V˜GÔ$Ð$r   r   Úoffsetc                óP   — 	 | j         | j        |z            S # t          $ r Y dS w xY w)zO
        Return character relative to cursor position, or empty string
        r;   )r<   r>   Ú
IndexError)r   r~   s     r   rV   z%Document._get_char_relative_to_cursorþ   s>   € ð	Ø”9˜TÔ1°FÑ:Ô;Ð;øÝð 	ð 	ð 	Ø�2�2ð	øøøs   ‚ —
%¤%c                ó   — | j         dk    S )z5
        True when we are at the first line.
        r   )rt   r4   s    r   Úon_first_linezDocument.on_first_line  s   € ð
 Ô'¨1Ò,Ð,r   c                ó(   — | j         | j        dz
  k    S )z4
        True when we are at the last line.
        r   )rt   rw   r4   s    r   Úon_last_linezDocument.on_last_line  s   € ð
 Ô'¨4¬?¸QÑ+>Ò>Ð>r   c                ó@   — |                       | j        ¦  «        \  }}|S )z)
        Current row. (0-based.)
        ©Ú_find_line_start_indexr>   )r   Úrowrc   s      r   rt   zDocument.cursor_position_row  s#   € ð
 ×,Ò,¨TÔ-AÑBÔB‰ˆˆQØˆ
r   c                óP   — |                       | j        ¦  «        \  }}| j        |z
  S )z,
        Current column. (0-based.)
        r†   )r   rc   Úline_start_indexs      r   Úcursor_position_colzDocument.cursor_position_col  s/   € ð #×9Ò9¸$Ô:NÑOÔOÑˆÐØÔ#Ð&6Ñ6Ð6r   Úindexútuple[int, int]c                óT   — | j         }t          j        ||¦  «        dz
  }|||         fS )z¦
        For the index of a character at a certain line, calculate the index of
        the first character on that line.

        Return (row, index) tuple.
        r   )rr   ÚbisectÚbisect_right)r   rŒ   ro   rp   s       r   r‡   zDocument._find_line_start_index(  s2   € ð Ô*ˆåÔ! '¨5Ñ1Ô1°AÑ5ˆØ�G˜C”LÐ Ð r   c                óD   — |                       |¦  «        \  }}||z
  }||fS )zˆ
        Given an index for the text, return the corresponding (row, col) tuple.
        (0-based. Returns (0, 0) for index=0.)
        )r‡   )r   rŒ   rˆ   Ú	row_indexÚcols        r   Útranslate_index_to_positionz$Document.translate_index_to_position4  s.   € ð ×4Ò4°UÑ;Ô;‰ˆˆYØ�iÑˆà�Cˆxˆr   rˆ   r“   c           
     ó�  — 	 | j         |         }| j        |         }nK# t          $ r> |dk     r| j         d         }| j        d         }n| j         d         }| j        d         }Y nw xY w|t          dt	          |t          |¦  «        ¦  «        ¦  «        z  }t          dt	          |t          | j        ¦  «        ¦  «        ¦  «        }|S )z¬
        Given a (row, col) tuple, return the corresponding index.
        (Row and col params are 0-based.)

        Negative row/col values are turned into zero.
        r   rY   )rr   r2   r€   ÚmaxÚminrC   r<   )r   rˆ   r“   ÚresultÚlines        r   Útranslate_row_col_to_indexz#Document.translate_row_col_to_index?  sÇ   € ð		&ØÔ-¨cÔ2ˆFØ”:˜c”?ˆDˆDøÝð 	&ð 	&ð 	&Ø�QŠwˆwØÔ1°!Ô4�Ø”z !”}��àÔ1°"Ô5�Ø”z "”~�øøð	&øøøð 	•#�a�˜S¥# d¡)¤)Ñ,Ô,Ñ-Ô-Ñ-ˆõ �Q�˜F¥C¨¬	¡N¤NÑ3Ô3Ñ4Ô4ˆØˆs   ‚ �AA%Á$A%c                ó<   — | j         t          | j        ¦  «        k    S )z/True when the cursor is at the end of the text.)r>   rC   r<   r4   s    r   Úis_cursor_at_the_endzDocument.is_cursor_at_the_endX  s   € ð Ô#¥s¨4¬9¡~¤~Ò5Ð5r   c                ó   — | j         dv S )z0True when the cursor is at the end of this line.)ra   r;   )rW   r4   s    r   Úis_cursor_at_the_end_of_linez%Document.is_cursor_at_the_end_of_line]  s   € ð Ô  JÐ.Ð.r   Úsubc                óT   — | j                              || j        ¦  «        | j        k    S )zM
        `True` when this substring is found at the cursor position.
        )r<   Úfindr>   )r   rŸ   s     r   Úhas_match_at_current_positionz&Document.has_match_at_current_positionb  s%   € ð Œy�~Š~˜c 4Ô#7Ñ8Ô8¸DÔ<PÒPÐPr   Fr   Úin_current_lineÚinclude_current_positionÚignore_caseÚcountc                óÎ  — t          |t          ¦  «        sJ ‚|r| j        }n| j        }|st	          |¦  «        dk    rdS |dd…         }|rt
          j        nd}t          j        t          j        |¦  «        ||¦  «        }	 t          |¦  «        D ]A\  }	}
|	dz   |k    r3|r|
 
                    d¦  «        c S |
 
                    d¦  «        dz   c S ŒBn# t          $ r Y nw xY wdS )z½
        Find `text` after the cursor, return position relative to the cursor
        position. Return `None` if nothing was found.

        :param count: Find the n-th occurrence.
        r   Nr   )rN   rL   rg   r_   rC   ÚreÚ
IGNORECASEÚfinditerÚescapeÚ	enumerateÚstartÚStopIteration)r   rŸ   r£   r¤   r¥   r¦   r<   ÚflagsÚiteratorÚiÚmatchs              r   r¡   zDocument.findh  s  € õ ˜+¥tÑ,Ô,Ð,Ð,Ð,àð 	*ØÔ1ˆDˆDàÔ)ˆDà'ð 	 Ý�4‰yŒy˜AŠ~ˆ~Ø�tà˜A˜B˜B”x�à!,Ð3•”�°!ˆÝ”;�rœy¨™~œ~¨t°UÑ;Ô;ˆð	Ý% hÑ/Ô/ð 2ð 2‘��5Ø�q‘5˜E’>�>Ø/ð 2Ø$Ÿ{š{¨1™~œ~Ð-Ð-Ð-à$Ÿ{š{¨1™~œ~°Ñ1Ð1Ð1Ð1ð	 "ð2øõ ð 	ð 	ð 	ØˆDð	øøøàˆts   Â5C Â9C ÃC Ã
C"Ã!C"c                ó�   — |rt           j        nd}d„ t          j        t          j        |¦  «        | j        |¦  «        D ¦   «         S )zu
        Find all occurrences of the substring. Return a list of absolute
        positions in the document.
        r   c                ó6   — g | ]}|                      ¦   «         ‘ŒS r-   )r­   )Ú.0r   s     r   ú
<listcomp>z%Document.find_all.<locals>.<listcomp>—  s    € ÐQÐQÐQ˜a�—’‘	”	ÐQÐQÐQr   )r¨   r©   rª   r«   r<   )r   rŸ   r¥   r¯   s       r   Úfind_allzDocument.find_all‘  s@   € ð
 "-Ð3•”�°!ˆØQÐQ¥2¤;­r¬y¸©~¬~¸t¼yÈ%Ñ#PÔ#PÐQÑQÔQÐQr   c                ó~  — |r| j         ddd…         }n| j        ddd…         }|rt          j        nd}t          j        t          j        |ddd…         ¦  «        ||¦  «        }	 t          |¦  «        D ]6\  }}	|dz   |k    r(|	                     d¦  «         t          |¦  «        z
  c S Œ7n# t          $ r Y nw xY wdS )z¾
        Find `text` before the cursor, return position relative to the cursor
        position. Return `None` if nothing was found.

        :param count: Find the n-th occurrence.
        NrY   r   r   )
rd   r]   r¨   r©   rª   r«   r¬   r­   rC   r®   )
r   rŸ   r£   r¥   r¦   Úbefore_cursorr¯   r°   r±   r²   s
             r   Úfind_backwardszDocument.find_backwards™  sì   € ð ð 	:Ø Ô;¸D¸D¸b¸DÔAˆMˆMà Ô3°D°D°b°DÔ9ˆMà!,Ð3•”�°!ˆÝ”;�rœy¨¨T¨T¨r¨T¬Ñ3Ô3°]ÀEÑJÔJˆð	Ý% hÑ/Ô/ð 6ð 6‘��5Ø�q‘5˜E’>�>Ø!ŸKšK¨™NœN˜?­S°©X¬XÑ5Ð5Ð5Ð5ð "ð6øõ ð 	ð 	ð 	ØˆDð	øøøàˆts   Á&AB- Â+B- Â-
B:Â9B:ÚWORDÚpatternúPattern[str] | Nonec                ó¨   — |                       ||¬¦  «        rdS | j        }|                      ||¬¦  «        pd}|t          |¦  «        |z   d…         S )zã
        Give the word before the cursor.
        If we have whitespace before the cursor this returns an empty string.

        :param pattern: (None or compiled regex). When given, use this regex
            pattern.
        ©r»   r¼   r;   r   N)Ú_is_word_before_cursor_completer]   Úfind_start_of_previous_wordrC   )r   r»   r¼   r]   r­   s        r   Úget_word_before_cursorzDocument.get_word_before_cursor¶  sj   € ð ×/Ò/°TÀ7Ð/ÑKÔKð 	à�2à!Ô4ÐØ×0Ò0°dÀGÐ0ÑLÔLÐQÐPQˆà!¥#Ð&8Ñ"9Ô"9¸EÑ"AÐ"CÐ"CÔDÐDr   c                ó�   — |r|                       ||¬¦  «        d u S | j        dk    p | j        dd …                              ¦   «         S )Nr¿   r;   rY   )rÁ   r]   Úisspace)r   r»   r¼   s      r   rÀ   z(Document._is_word_before_cursor_completeÉ  sZ   € ð ð 	Ø×3Ò3¸ÀwÐ3ÑOÔOÐSWÐWÐWð Ô'¨2Ò-ÐW°Ô1HÈÈÈÔ1M×1UÒ1UÑ1WÔ1Wðr   c                ó  — |r|rJ ‚| j         ddd…         }|r|}n|rt          }nt          }|                     |¦  «        }	 t	          |¦  «        D ]&\  }}|dz   |k    r|                     d¦  «         c S Œ'n# t          $ r Y nw xY wdS )zü
        Return an index relative to the cursor position pointing to the start
        of the previous word. Return `None` if nothing was found.

        :param pattern: (None or compiled regex). When given, use this regex
            pattern.
        NrY   r   r   )r]   Ú_FIND_BIG_WORD_REÚ_FIND_WORD_RErª   r¬   Úendr®   )	r   r¦   r»   r¼   r]   Úregexr°   r±   r²   s	            r   rÁ   z$Document.find_start_of_previous_wordÓ  sÖ   € ð Ð%˜WÐ%Ð%Ð%ð "Ô4°T°T°r°TÔ:Ðàð 	"ØˆEˆEØð 	"Ý%ˆEˆEå!ˆEà—>’>Ð"4Ñ5Ô5ˆð	Ý% hÑ/Ô/ð )ð )‘��5Ø�q‘5˜E’>�>Ø!ŸIšI a™LœL˜=Ð(Ð(Ð(ð "ð)øõ ð 	ð 	ð 	ØˆDð	øøøàˆts   Á4A: Á8A: Á:
BÂBÚinclude_leading_whitespaceÚinclude_trailing_whitespacec                ó¬  ‡— | j         ddd…         }| j        }dˆfd„} ||¦  «                             |¦  «        } ||¦  «                             |¦  «        }‰sF|rD|rB| j        | j        dz
           }	| j        | j                 }
t
          j        d	z   }|	|v |
|v k    rd}|r|                     d¦  «         nd
|r|                     d¦  «        nd
fS )a  
        Return the relative boundaries (startpos, endpos) of the current word under the
        cursor. (This is at the current line, because line boundaries obviously
        don't belong to any word.)
        If not on a word, this returns (0,0)
        NrY   Úinclude_whitespacerL   r   úPattern[str]c                óJ   •— t           t          t          t          dœ‰| f         S )N))FF)FT)TF)TT)Ú_FIND_CURRENT_WORD_REÚ1_FIND_CURRENT_WORD_INCLUDE_TRAILING_WHITESPACE_REÚ_FIND_CURRENT_BIG_WORD_REÚ5_FIND_CURRENT_BIG_WORD_INCLUDE_TRAILING_WHITESPACE_RE)rÍ   r»   s    €r   Ú	get_regexz;Document.find_boundaries_of_current_word.<locals>.get_regex  s.   ø€ å 5ÝPÝ8ÝSð	ð ð
 Ð'Ð(ô*ð *r   r   Ú0123456789_r   )rÍ   rL   r   rÎ   )rd   rg   Úsearchr<   r>   ÚstringÚascii_lettersrÈ   )r   r»   rÊ   rË   r]   r_   rÔ   Úmatch_beforeÚmatch_afterÚc1Úc2Úalphabets    `          r   Úfind_boundaries_of_current_wordz(Document.find_boundaries_of_current_wordô  s#  ø€ ð "Ô<¸T¸T¸r¸TÔBÐØ Ô:Ðð	*ð 	*ð 	*ð 	*ð 	*ð 	*ð !�yÐ!;Ñ<Ô<×CÒCÐDVÑWÔWˆØ�iÐ ;Ñ<Ô<×CÒCÐDUÑVÔVˆð ð 	$˜ð 	$¨ð 	$Ø”˜4Ô/°!Ñ3Ô4ˆBØ”˜4Ô/Ô0ˆBÝÔ+¨mÑ;ˆHà�h� B¨( NÒ3Ð3Ø#�ð %1Ð7ˆ\×Ò˜aÑ Ô Ð Ð °aØ"-Ð4ˆK�OŠO˜AÑÔÐ°1ð
ð 	
r   c                ór   — |                       |¬¦  «        \  }}| j        | j        |z   | j        |z   …         S )zŽ
        Return the word, currently below the cursor.
        This returns an empty string when the cursor is on a whitespace region.
        )r»   )rÞ   r<   r>   )r   r»   r­   rÈ   s       r   Úget_word_under_cursorzDocument.get_word_under_cursor  s@   € ð
 ×9Ò9¸tÐ9ÑDÔD‰
ˆˆsØŒy˜Ô-°Ñ5¸Ô8LÈsÑ8RÐRÔSÐSr   c                ól  — |dk     r|                       | |¬¦  «        S |rt          nt          }|                     | j        ¦  «        }	 t          |¦  «        D ]I\  }}|dk    r|                     d¦  «        dk    r|dz  }|dz   |k    r|                     d¦  «        c S ŒJn# t          $ r Y nw xY wdS )z•
        Return an index relative to the cursor position pointing to the start
        of the next word. Return `None` if nothing was found.
        r   ©r¦   r»   r   N)Úfind_previous_word_beginningrÆ   rÇ   rª   r_   r¬   r­   r®   ©r   r¦   r»   rÉ   r°   r±   r²   s          r   Úfind_next_word_beginningz!Document.find_next_word_beginning'  sæ   € ð �1Š9ˆ9Ø×4Ò4¸E¸6ÈÐ4ÑMÔMÐMà%)Ð<Õ!Ð!­}ˆØ—>’> $Ô"8Ñ9Ô9ˆð		Ý% hÑ/Ô/ð *ð *‘��5à˜’6�6˜eŸkšk¨!™nœn°Ò1Ð1Ø˜Q‘J�Eà�q‘5˜E’>�>Ø Ÿ;š; q™>œ>Ð)Ð)Ð)ð "ð*øõ ð 	ð 	ð 	ØˆDð	øøøàˆts   Á
AB$ Â"B$ Â$
B1Â0B1c                ób  — |dk     r|                       | |¬¦  «        S |r| j        }n| j        dd…         }|rt          nt          }|                     |¦  «        }	 t          |¦  «        D ]0\  }}|dz   |k    r"|                     d¦  «        }	|r|	c S |	dz   c S Œ1n# t          $ r Y nw xY wdS )z“
        Return an index relative to the cursor position pointing to the end
        of the next word. Return `None` if nothing was found.
        r   râ   r   N)Úfind_previous_word_endingr_   rÆ   rÇ   rª   r¬   rÈ   r®   )
r   r¤   r¦   r»   r<   rÉ   Úiterabler±   r²   Úvalues
             r   Úfind_next_word_endingzDocument.find_next_word_ending@  sú   € ð �1Š9ˆ9Ø×1Ò1¸¸ÀTÐ1ÑJÔJÐJà#ð 	.ØÔ)ˆDˆDàÔ)¨!¨"¨"Ô-ˆDà%)Ð<Õ!Ð!­}ˆØ—>’> $Ñ'Ô'ˆð	Ý% hÑ/Ô/ð )ð )‘��5Ø�q‘5˜E’>�>Ø!ŸIšI a™LœL�Eà/ð )Ø$˜˜˜à$ q™yÐ(Ð(Ð(ð "ð)øõ ð 	ð 	ð 	ØˆDð	øøøàˆts   Á7B ÂB ÂB Â
B,Â+B,c                ó8  — |dk     r|                       | |¬¦  «        S |rt          nt          }|                     | j        ddd…         ¦  «        }	 t          |¦  «        D ]&\  }}|dz   |k    r|                     d¦  «         c S Œ'n# t          $ r Y nw xY wdS )z™
        Return an index relative to the cursor position pointing to the start
        of the previous word. Return `None` if nothing was found.
        r   râ   NrY   r   )rå   rÆ   rÇ   rª   r]   r¬   rÈ   r®   rä   s          r   rã   z%Document.find_previous_word_beginning`  sÍ   € ð �1Š9ˆ9Ø×0Ò0¸°vÀDÐ0ÑIÔIÐIà%)Ð<Õ!Ð!­}ˆØ—>’> $Ô"9¸$¸$¸B¸$Ô"?Ñ@Ô@ˆð	Ý% hÑ/Ô/ð )ð )‘��5Ø�q‘5˜E’>�>Ø!ŸIšI a™LœL˜=Ð(Ð(Ð(ð "ð)øõ ð 	ð 	ð 	ØˆDð	øøøàˆts   Á4B
 ÂB
 Â

BÂBc                óª  — |dk     r|                       | |¬¦  «        S | j        dd…         | j        ddd…         z   }|rt          nt          }|                     |¦  «        }	 t          |¦  «        D ]M\  }}|dk    r|                     d¦  «        dk    r|dz  }|dz   |k    r|                     d¦  «         dz   c S ŒNn# t          $ r Y nw xY wdS )z—
        Return an index relative to the cursor position pointing to the end
        of the previous word. Return `None` if nothing was found.
        r   râ   Nr   rY   )	rê   r_   r]   rÆ   rÇ   rª   r¬   r­   r®   )r   r¦   r»   r]   rÉ   r°   r±   r²   s           r   rç   z"Document.find_previous_word_endingu  s  € ð �1Š9ˆ9Ø×-Ò-°U°FÀÐ-ÑFÔFÐFà!Ô3°B°Q°BÔ7¸$Ô:QÐRVÐRVÐTVÐRVÔ:WÑWÐà%)Ð<Õ!Ð!­}ˆØ—>’>Ð"4Ñ5Ô5ˆð		Ý% hÑ/Ô/ð /ð /‘��5à˜’6�6˜eŸkšk¨!™nœn°Ò1Ð1Ø˜Q‘J�Eà�q‘5˜E’>�>Ø!ŸKšK¨™NœN˜?¨QÑ.Ð.Ð.Ð.ð "ð/øõ ð 	ð 	ð 	ØˆDð	øøøàˆts   Á%AC ÃC Ã
CÃCÚ
match_funcúCallable[[str], bool]c                ó˜   — d}t          | j        | j        dz   d…         ¦  «        D ]"\  }} ||¦  «        r
d|z   }|dz  }|dk    r nŒ#|S )zn
        Look downwards for empty lines.
        Return the line index, relative to the current line.
        Nr   r   ©r¬   r2   rt   ©r   rí   r¦   r˜   rŒ   r™   s         r   Úfind_next_matching_linez Document.find_next_matching_line�  sw   € ð ˆå$ T¤Z°Ô0HÈ1Ñ0LÐ0NÐ0NÔ%OÑPÔPð 	ð 	‰KˆE�4Øˆz˜$ÑÔð Ø˜U™�Ø˜‘
�à˜ŠzˆzØ�ð ð ˆr   c                ó¤   — d}t          | j        d| j        …         ddd…         ¦  «        D ]"\  }} ||¦  «        r
d|z
  }|dz  }|dk    r nŒ#|S )zl
        Look upwards for empty lines.
        Return the line index, relative to the current line.
        NrY   r   r   rð   rñ   s         r   Úfind_previous_matching_linez$Document.find_previous_matching_line£  s}   € ð ˆå$ T¤ZÐ0J°$Ô2JÐ0JÔ%KÈDÈDÈbÈDÔ%QÑRÔRð 	ð 	‰KˆE�4Øˆz˜$ÑÔð Ø˜e™�Ø˜‘
�à˜ŠzˆzØ�ð ð ˆr   c                óf   — |dk     r|                       | ¦  «        S t          | j        |¦  «         S )z4
        Relative position for cursor left.
        r   )Úget_cursor_right_positionr—   r‹   ©r   r¦   s     r   Úget_cursor_left_positionz!Document.get_cursor_left_position¶  s9   € ð �1Š9ˆ9Ø×1Ò1°5°&Ñ9Ô9Ð9å�DÔ,¨eÑ4Ô4Ð4Ð4r   c                ó~   — |dk     r|                       | ¦  «        S t          |t          | j        ¦  «        ¦  «        S )z5
        Relative position for cursor_right.
        r   )rø   r—   rC   rg   r÷   s     r   rö   z"Document.get_cursor_right_position¿  s>   € ð �1Š9ˆ9Ø×0Ò0°%°Ñ8Ô8Ð8å�5�#˜dÔ<Ñ=Ô=Ñ>Ô>Ð>r   Úpreferred_columnc                ó�   — |dk    sJ ‚|€| j         n|}|                      t          d| j        |z
  ¦  «        |¦  «        | j        z
  S )a  
        Return the relative cursor position (character index) where we would be if the
        user pressed the arrow-up button.

        :param preferred_column: When given, go to this column instead of
                                 staying at the current column.
        r   Nr   )r‹   rš   r–   rt   r>   ©r   r¦   rú   Úcolumns       r   Úget_cursor_up_positionzDocument.get_cursor_up_positionÈ  se   € ð ˜Šzˆzˆzˆzà(8Ð(@ˆDÔ$Ð$ÐFVð 	ð
 ×+Ò+Ý�A�tÔ/°%Ñ7Ñ8Ô8¸&ñô ð Ô"ñ#ð	
r   c                ót   — |dk    sJ ‚|€| j         n|}|                      | j        |z   |¦  «        | j        z
  S )a  
        Return the relative cursor position (character index) where we would be if the
        user pressed the arrow-down button.

        :param preferred_column: When given, go to this column instead of
                                 staying at the current column.
        r   )r‹   rš   rt   r>   rü   s       r   Úget_cursor_down_positionz!Document.get_cursor_down_positionÞ  sT   € ð ˜Šzˆzˆzˆzà(8Ð(@ˆDÔ$Ð$ÐFVð 	ð
 ×+Ò+¨DÔ,DÀuÑ,LÈfÑUÔUØÔ"ñ#ð	
r   Úleft_chÚright_chÚend_posc                ó8  — | j         |k    rdS |€t          | j        ¦  «        }n"t          t          | j        ¦  «        |¦  «        }d}t	          | j        dz   |¦  «        D ]8}| j        |         }||k    r|dz  }n||k    r|dz  }|dk    r|| j        z
  c S Œ9dS )zÁ
        Find the right bracket enclosing current position. Return the relative
        position to the cursor position.

        When `end_pos` is given, don't look past the position.
        r   Nr   )rW   rC   r<   r—   Úranger>   )r   r  r  r  Ústackr±   Úcs          r   Úfind_enclosing_bracket_rightz%Document.find_enclosing_bracket_rightò  sÄ   € ð Ô Ò(Ð(Ø�1àˆ?Ý˜$œ)‘n”nˆGˆGå�#˜dœi™.œ.¨'Ñ2Ô2ˆGàˆõ �tÔ+¨aÑ/°Ñ9Ô9ð 		0ð 		0ˆAØ”	˜!”ˆAà�GŠ|ˆ|Ø˜‘
��Ø�h’�Ø˜‘
�à˜ŠzˆzØ˜4Ô/Ñ/Ð/Ð/Ð/ð ð ˆtr   Ú	start_posc                óø   — | j         |k    rdS |€d}nt          d|¦  «        }d}t          | j        dz
  |dz
  d¦  «        D ]8}| j        |         }||k    r|dz  }n||k    r|dz  }|dk    r|| j        z
  c S Œ9dS )zÂ
        Find the left bracket enclosing current position. Return the relative
        position to the cursor position.

        When `start_pos` is given, don't look past the position.
        r   Nr   rY   )rW   r–   r  r>   r<   )r   r  r  r	  r  r±   r  s          r   Úfind_enclosing_bracket_leftz$Document.find_enclosing_bracket_left  s»   € ð Ô Ò'Ð'Ø�1àÐØˆIˆIå˜A˜yÑ)Ô)ˆIàˆõ �tÔ+¨aÑ/°¸Q±ÀÑCÔCð 		0ð 		0ˆAØ”	˜!”ˆAà�HŠ}ˆ}Ø˜‘
��Ø�g’�Ø˜‘
�à˜ŠzˆzØ˜4Ô/Ñ/Ð/Ð/Ð/ð ð ˆtr   c                óÌ   — dD ]`}|d         }|d         }| j         |k    r|                      |||¬¦  «        pdc S | j         |k    r|                      |||¬¦  «        pdc S ŒadS )z¤
        Return relative cursor position of matching [, (, { or < bracket.

        When `start_pos` or `end_pos` are given. Don't look past the positions.
        )z()z[]z{}z<>r   r   )r  )r	  )rW   r  r  )r   r	  r  ÚpairÚAÚBs         r   Úfind_matching_bracket_positionz'Document.find_matching_bracket_position4  s�   € ð +ð 	Xð 	XˆDØ�Q”ˆAØ�Q”ˆAØÔ  AÒ%Ð%Ø×8Ò8¸¸AÀwÐ8ÑOÔOÐTÐSTÐTÐTÐTØÔ" aÒ'Ð'Ø×7Ò7¸¸1È	Ð7ÑRÔRÐWÐVWÐWÐWÐWð (ð ˆqr   c                ó   — | j          S )z0Relative position for the start of the document.)r>   r4   s    r   Úget_start_of_document_positionz'Document.get_start_of_document_positionH  s   € àÔ$Ð$Ð$r   c                ó:   — t          | j        ¦  «        | j        z
  S )z.Relative position for the end of the document.)rC   r<   r>   r4   s    r   Úget_end_of_document_positionz%Document.get_end_of_document_positionL  s   € å�4”9‰~Œ~ Ô 4Ñ4Ð4r   Úafter_whitespacec                ó°   — |r@| j         }t          |¦  «        t          |                     ¦   «         ¦  «        z
  | j        z
  S t          | j        ¦  «         S )z-Relative position for the start of this line.)ry   rC   r{   r‹   rd   )r   r  ry   s      r   Úget_start_of_line_positionz#Document.get_start_of_line_positionP  s_   € àð 	9ØÔ,ˆLå�LÑ!Ô!Ý�l×)Ò)Ñ+Ô+Ñ,Ô,ñ-àÔ*ñ+ðõ ˜Ô7Ñ8Ô8Ð8Ð8r   c                ó*   — t          | j        ¦  «        S )z+Relative position for the end of this line.)rC   rg   r4   s    r   Úget_end_of_line_positionz!Document.get_end_of_line_position\  s   € å�4Ô1Ñ2Ô2Ð2r   c                ód   — t          | j                             ¦   «         ¦  «        | j        z
  dz
  S )zR
        Relative position for the last non blank character of this line.
        r   )rC   ry   Úrstripr‹   r4   s    r   Ú'last_non_blank_of_current_line_positionz0Document.last_non_blank_of_current_line_position`  s.   € õ �4Ô$×+Ò+Ñ-Ô-Ñ.Ô.°Ô1IÑIÈAÑMÐMr   rý   c                ó~   — t          | j        ¦  «        }| j        }t          dt	          ||¦  «        ¦  «        }||z
  S )z¸
        Return the relative cursor position for this column at the current
        line. (It will stay between the boundaries of the line in case of a
        larger number.)
        r   )rC   ry   r‹   r–   r—   )r   rý   rq   Úcurrent_columns       r   Úget_column_cursor_positionz#Document.get_column_cursor_positionf  s@   € õ ˜$Ô+Ñ,Ô,ˆØÔ1ˆÝ�Q�˜K¨Ñ0Ô0Ñ1Ô1ˆà˜Ñ&Ð&r   c                ó|   — | j         r$t          | j        | j         j        g¦  «        \  }}n| j        | j        }}||fS )zÌ
        Return (from, to) tuple of the selection.
        start and end position are included.

        This doesn't take the selection type into account. Use
        `selection_ranges` instead.
        )r@   Úsortedr>   Úoriginal_cursor_position)r   Úfrom_Útos      r   Úselection_rangezDocument.selection_ranger  sO   € ð Œ>ð 	CÝØÔ% t¤~Ô'NÐOñô ‰IˆE�2�2ð Ô,¨dÔ.B�2ˆEà�bˆyÐr   úIterable[tuple[int, int]]c           	   #  ó–  K  — | j         �r¾t          | j        | j         j        g¦  «        \  }}| j         j        t
          j        k    rÍ|                      |¦  «        \  }}|                      |¦  «        \  }}t          ||g¦  «        \  }}| j        }t          ¦   «         r|dz  }t          ||dz   ¦  «        D ]Y}t          ||         ¦  «        }	||	k    r<|                      ||¦  «        |                      |t          |	|¦  «        ¦  «        fV — ŒZdS | j         j        t
          j        k    rt          d| j                             dd|¦  «        dz   ¦  «        }| j                             d|¦  «        dk    r| j                             d|¦  «        }nt          | j        ¦  «        dz
  }t          ¦   «         r|dz  }||fV — dS dS )aE  
        Return a list of `(from, to)` tuples for the selection or none if
        nothing was selected. The upper boundary is not included.

        This will yield several (from, to) tuples in case of a BLOCK selection.
        This will return zero ranges, like (8,8) for empty lines in a block
        selection.
        r   r   ra   N)r@   r!  r>   r"  Útyper   ÚBLOCKr”   r2   r   r  rC   rš   r—   ÚLINESr–   r<   Úrfindr¡   )
r   r#  r$  Ú	from_lineÚfrom_columnÚto_lineÚ	to_columnr2   Úlrq   s
             r   Úselection_rangeszDocument.selection_ranges‡  sê  è è € ð Œ>ñ '	 ÝØÔ% t¤~Ô'NÐOñô ‰IˆE�2ð Œ~Ô"¥mÔ&9Ò9Ð9Ø)-×)IÒ)IÈ%Ñ)PÔ)PÑ&�	˜;Ø%)×%EÒ%EÀbÑ%IÔ%IÑ"�˜Ý)/°¸iÐ0HÑ)IÔ)IÑ&�˜YØœ
�å‘9”9ð #Ø ‘N�Iå˜y¨'°A©+Ñ6Ô6ð 	ð 	�AÝ"% e¨A¤h¡-¤-�Kà" kÒ1Ð1à ×;Ò;¸A¸{ÑKÔKØ ×;Ò;Ø !¥3 {°IÑ#>Ô#>ñô ðð ð ð øð		ð 	ð ”>Ô&­-Ô*=Ò=Ð=Ý  4¤9§?¢?°4¸¸EÑ#BÔ#BÀQÑ#FÑGÔG�Eà”y—~’~ d¨BÑ/Ô/°1Ò4Ð4Ø!œYŸ^š^¨D°"Ñ5Ô5˜˜å  ¤™^œ^¨aÑ/˜õ ‘9”9ð Ø˜!‘G�Bà˜R�i�����ðO'	 ð '	 r   útuple[int, int] | Nonec                ó@  — | j         �r•| j        |         }|                      |d¦  «        }|                      |t          |¦  «        ¦  «        }t	          | j        | j         j        g¦  «        \  }}t          ||¦  «        }t          ||¦  «        }||k    �r| j         j	        t          j        k    r|}|}nŸ| j         j	        t          j        k    r…|                      |¦  «        \  }	}
|                      |¦  «        \  }	}t	          |
|g¦  «        \  }
}|
t          |¦  «        k    rdS |                      ||
¦  «        }|                      ||¦  «        }|                      |¦  «        \  }	}|                      |¦  «        \  }	}t          ¦   «         r|dz  }||fS dS )aB  
        If the selection spans a portion of the given line, return a (from, to) tuple.

        The returned upper boundary is not included in the selection, so
        `(0, 0)` is an empty selection.  `(0, 1)`, is a one character selection.

        Returns None if the selection doesn't cover this line at all.
        r   Nr   )r@   r2   rš   rC   r!  r>   r"  r–   r—   r(  r   r*  r)  r”   r   )r   rˆ   r™   Ú	row_startÚrow_endr#  r$  Úintersection_startÚintersection_endrc   Úcol1Úcol2r-  r/  s                 r   Úselection_range_at_linez Document.selection_range_at_line¹  s«  € ð Œ>ñ &	.Ø”:˜c”?ˆDà×7Ò7¸¸QÑ?Ô?ˆIØ×5Ò5°c½3¸t¹9¼9ÑEÔEˆGåØÔ% t¤~Ô'NÐOñô ‰IˆE�2õ
 "% Y°Ñ!6Ô!6ÐÝ" 7¨BÑ/Ô/Ðà!Ð%5Ò5Ñ5Ø”>Ô&­-Ô*=Ò=Ð=Ø)2Ð&Ø'.Ð$Ð$à”^Ô(­MÔ,?Ò?Ð?Ø"×>Ò>¸uÑEÔE‘G�A�tØ"×>Ò>¸rÑBÔB‘G�A�tÝ!'¨¨t¨Ñ!5Ô!5‘J�D˜$à�c $™iœiÒ'Ð'Ø#˜tà)-×)HÒ)HÈÈdÑ)SÔ)SÐ&Ø'+×'FÒ'FÀsÈDÑ'QÔ'QÐ$à!%×!AÒ!AÐBTÑ!UÔ!U‘��;Ø#×?Ò?Ð@PÑQÔQ‘��9õ ‘9”9ð #Ø ‘N�Ià" IÐ-Ð-Øˆtr   útuple[Document, ClipboardData]c                ó~  — | j         �r%g }g }| j        }d}|                      ¦   «         D ]S\  }}|dk    r|}|                     | j        ||…         ¦  «         |                     | j        ||…         ¦  «         |}ŒT|                     | j        |d…         ¦  «         d                     |¦  «        }d                     |¦  «        }| j         j        t          j        k    r| 	                    d¦  «        r
|dd…         }t          ||¬¦  «        t          || j         j        ¦  «        fS | t          d¦  «        fS )zõ
        Return a (:class:`.Document`, :class:`.ClipboardData`) tuple, where the
        document represents the new document when the selection is cut, and the
        clipboard data, represents whatever has to be put on the clipboard.
        r   Nra   r;   rY   r\   )r@   r>   r1  r%   r<   Újoinr(  r   r*  Úendswithr   r   )	r   Ú	cut_partsÚremaining_partsÚnew_cursor_positionÚlast_tor#  r$  Úcut_textÚremaining_texts	            r   Úcut_selectionzDocument.cut_selectionë  sT  € ð Œ>ñ 	+ØˆIØ ˆOØ"&Ô"6ÐàˆGØ!×2Ò2Ñ4Ô4ð ð ‘	��rØ˜a’<�<Ø*/Ð'à×&Ò& t¤y°¸°Ô'?Ñ@Ô@Ð@Ø× Ò  ¤¨5°¨8Ô!4Ñ5Ô5Ð5Ø��à×"Ò" 4¤9¨W¨X¨XÔ#6Ñ7Ô7Ð7à—y’y Ñ+Ô+ˆHØŸWšW _Ñ5Ô5ˆNð Œ~Ô"¥mÔ&9Ò9Ð9¸h×>OÒ>OÐPTÑ>UÔ>UÐ9Ø# C R Cœ=�õ ˜nÐ>QÐRÑRÔRÝ˜h¨¬Ô(;Ñ<Ô<ðð ð
 � rÑ*Ô*Ð*Ð*r   Údatar   Ú
paste_moder   c                óª  — |t           j        k    }|t           j        k    }|j        t          j        k    r|r;| j        d| j        dz   …         |j        |z  z   | j        | j        dz   d…         z   }n| j        |j        |z  z   | j	        z   }| j        t          |j        ¦  «        |z  z   }|r|dz  }�n|j        t          j        k    rü| j        }|rt| j        d|…         |j        g|z  z   | j        |d…         z   }	d                     |	¦  «        }t          d                     | j        d|…         ¦  «        ¦  «        |z   }�n}| j        d|dz   …         |j        g|z  z   | j        |dz   d…         z   }	t          d                     | j        d|dz   …         ¦  «        ¦  «        |z   dz   }d                     |	¦  «        }nþ|j        t          j        k    ré| j        dd…         }	| j        }
| j        |rdndz   }t#          |j                             d¦  «        ¦  «        D ]z\  }}||
z   }|t          |	¦  «        k    r|	                     d¦  «         |	|                              |¦  «        |	|<   |	|         d|…         ||z  z   |	|         |d…         z   |	|<   Œ{d                     |	¦  «        }| j        |rdndz   }t+          ||¬¦  «        S )a  
        Return a new :class:`.Document` instance which contains the result if
        we would paste this data at the current cursor position.

        :param paste_mode: Where to paste. (Before/after/emacs.)
        :param count: When >1, Paste multiple times.
        Nr   ra   r;   r   r\   )r   Ú	VI_BEFOREÚVI_AFTERr(  r   Ú
CHARACTERSr<   r>   r]   r_   rC   r*  rt   r2   r=  r)  r‹   r¬   rj   r%   Úljustr   )r   rF  rG  r¦   ÚbeforeÚafterÚnew_textrA  r0  r2   Ú
start_lineÚstart_columnr±   r™   rŒ   s                  r   Úpaste_clipboard_datazDocument.paste_clipboard_data  s   € ð �yÔ2Ò2ˆØ�iÔ0Ò0ˆàŒ9�Ô0Ò0Ð0Øð 	à”IÐ8 Ô 4°qÑ 8Ð8Ô9Ø”i %Ñ'ñ(à”i Ô 4°qÑ 8Ð :Ð :Ô;ñ<ð �ð Ô+¨d¬i¸%Ñ.?Ñ?À$ÔBXÑXð ð #'Ô"6½¸T¼Y¹¼È%Ñ9OÑ"OÐØð )Ø# qÑ(Ð#ùàŒY�-Ô-Ò-Ð-ØÔ(ˆAØð ,Øœ
 2 A 2œ¨$¬)¨°uÑ)<Ñ<¸t¼zÈ!È"È"¼~ÑM�ØŸ9š9 UÑ+Ô+�Ý&)¨"¯'ª'°$´*¸R¸a¸R´.Ñ*AÔ*AÑ&BÔ&BÀQÑ&FÐ#Ñ#àœ
 7 Q¨¡U 7Ô+¨t¬y¨k¸EÑ.AÑAÀDÄJÈqÐSTÉuÈwÈwÔDWÑW�Ý&)¨"¯'ª'°$´*¸W¸qÀ1¹u¸WÔ2EÑ*FÔ*FÑ&GÔ&GÈ!Ñ&KÈaÑ&OÐ#ØŸ9š9 UÑ+Ô+��àŒY�-Ô-Ò-Ð-Ø”J˜q˜q˜q”MˆEØÔ1ˆJØÔ3¸FÐ7I°q°qÈÑJˆLå$ T¤Y§_¢_°TÑ%:Ô%:Ñ;Ô;ð 
ð 
‘��4Ø˜J™�Ø�C ™JœJÒ&Ð&Ø—L’L Ñ$Ô$Ð$à$ Uœ|×1Ò1°,Ñ?Ô?��e‘à˜%”L  , Ô/Ø˜U‘lñ#à˜E”l < = =Ô1ñ2ð �e‘�ð —y’y Ñ'Ô'ˆHØ"&Ô"6¸vÐ:L¸!¸!È1Ñ"MÐå˜XÐ7JÐKÑKÔKÐKr   c                óh   — d}| j         ddd…         D ]}|r|                     ¦   «         r|dz  }Œ |S )zJ
        Return number of empty lines at the end of the document.
        r   NrY   r   )r2   rÄ   )r   r¦   r™   s      r   Úempty_line_count_at_the_endz$Document.empty_line_count_at_the_endP  sO   € ð ˆØ”J˜t˜t ˜tÔ$ð 	ð 	ˆDØð ˜4Ÿ<š<™>œ>ð Ø˜‘
��ààˆr   rM  c                ó¨   — dd„}|                       ||¬¦  «        }|r.|rdnd}t          d|                      | ¬	¦  «        |z   ¦  «        S | j         S )zX
        Return the start of the current paragraph. (Relative cursor position.)
        r<   r=   r   rL   c                ó0   — |  p|                       ¦   «         S r1   ©rÄ   ©r<   s    r   rí   z/Document.start_of_paragraph.<locals>.match_funcb  ó   € Ø�8Ð-˜tŸ|š|™~œ~Ð-r   ©rí   r¦   r   r   ©r¦   N©r<   r=   r   rL   )rô   r—   rþ   r>   )r   r¦   rM  rí   Ú
line_indexÚadds         r   Ústart_of_paragraphzDocument.start_of_paragraph]  sƒ   € ð
	.ð 	.ð 	.ð 	.ð ×5Ò5Ø!¨ð 6ñ 
ô 
ˆ
ð ð 	)ØÐ$�!�! 1ˆCÝ�q˜$×5Ò5¸Z¸KÐ5ÑHÔHÈ3ÑNÑOÔOÐOàÔ(Ð(Ð(r   rN  c                ó¾   — dd„}|                       ||¬¦  «        }|r-|rdnd}t          d|                      |¬	¦  «        |z
  ¦  «        S t          | j        ¦  «        S )zV
        Return the end of the current paragraph. (Relative cursor position.)
        r<   r=   r   rL   c                ó0   — |  p|                       ¦   «         S r1   rW  rX  s    r   rí   z-Document.end_of_paragraph.<locals>.match_funct  rY  r   rZ  r   r   r[  Nr\  )rò   r–   r   rC   r_   )r   r¦   rN  rí   r]  r^  s         r   Úend_of_paragraphzDocument.end_of_paragrapho  s}   € ð
	.ð 	.ð 	.ð 	.ð ×1Ò1¸ZÈuÐ1ÑUÔUˆ
àð 	/ØÐ#�!�! !ˆCÝ�q˜$×7Ò7¸jÐ7ÑIÔIÈCÑOÑPÔPÐPå�tÔ-Ñ.Ô.Ð.r   c                óJ   — t          | j        |z   | j        | j        ¬¦  «        S )z‘
        Create a new document, with this text inserted after the buffer.
        It keeps selection ranges and cursor position in sync.
        ©r<   r>   r@   )r   r<   r>   r@   )r   r<   s     r   Úinsert_afterzDocument.insert_after�  s0   € õ
 Ø”˜TÑ!Ø Ô0Ø”nð
ñ 
ô 
ð 	
r   c                óÈ   — | j         }|r+t          |j        t          |¦  «        z   |j        ¬¦  «        }t          || j        z   | j        t          |¦  «        z   |¬¦  «        S )z’
        Create a new document, with this text inserted before the buffer.
        It keeps selection ranges and cursor position in sync.
        )r"  r(  rd  )r@   r   r"  rC   r(  r   r<   r>   )r   r<   Úselection_states      r   Úinsert_beforezDocument.insert_beforeŒ  sx   € ð
 œ.ˆàð 	Ý,Ø)8Ô)QÝ�d‘)”)ñ*à$Ô)ðñ ô ˆOõ Ø˜œ	Ñ!Ø Ô0µ3°t±9´9Ñ<Ø%ð
ñ 
ô 
ð 	
r   )r;   NN)r<   r=   r>   r?   r@   rA   r   r/   )r   r=   )rK   r   r   rL   )r   rQ   )r   rA   )r   rh   )r   rk   )r   )r~   rQ   r   r=   )r   rL   )rŒ   rQ   r   r�   )rˆ   rQ   r“   rQ   r   rQ   )rŸ   r=   r   rL   )FFFr   )rŸ   r=   r£   rL   r¤   rL   r¥   rL   r¦   rQ   r   r?   )F)rŸ   r=   r¥   rL   r   rk   )FFr   )
rŸ   r=   r£   rL   r¥   rL   r¦   rQ   r   r?   )FN)r»   rL   r¼   r½   r   r=   )r»   rL   r¼   r½   r   rL   )r   FN)r¦   rQ   r»   rL   r¼   r½   r   r?   )FFF)r»   rL   rÊ   rL   rË   rL   r   r�   )r»   rL   r   r=   )r   F)r¦   rQ   r»   rL   r   r?   )Fr   F)r¤   rL   r¦   rQ   r»   rL   r   r?   )r   )rí   rî   r¦   rQ   r   r?   )r¦   rQ   r   rQ   )r   N)r¦   rQ   rú   r?   r   rQ   r1   )r  r=   r  r=   r  r?   r   r?   )r  r=   r  r=   r	  r?   r   r?   )NN)r	  r?   r  r?   r   rQ   )r  rL   r   rQ   )rý   rQ   r   rQ   )r   r�   )r   r&  )rˆ   rQ   r   r2  )r   r;  )rF  r   rG  r   r¦   rQ   r   r   )r¦   rQ   rM  rL   r   rQ   )r¦   rQ   rN  rL   r   rQ   )r<   r=   r   r   )Jr    r!   r"   r#   Ú	__slots__r5   rJ   rO   Úpropertyr<   r>   r@   rW   rZ   r]   r_   rd   rg   r2   rr   ru   rw   ry   r}   rV   r‚   r„   rt   r‹   r‡   r”   rš   rœ   rž   r¢   r¡   r·   rº   rÂ   rÀ   rÁ   rÞ   rà   rå   rê   rã   rç   rò   rô   rø   rö   rþ   r   r  r  r  r  r  r  r  r  r  r%  r1  r:  rE  r   ÚEMACSrR  rT  r_  rb  re  rh  r-   r   r   r   r   M   s‘  € € € € € ð
ð 
ð F€Ið Ø&*Ø+/ð	=ð =ð =ð =ð =ðNUð Uð Uð Uð
ð 
ð 
ð 
ð ðð ð ñ „Xðð ð%ð %ð %ñ „Xð%ð ðð ð ñ „Xðð ð:ð :ð :ñ „Xð:ð ð;ð ;ð ;ñ „Xð;ð ð3ð 3ð 3ñ „Xð3ð ð1ð 1ð 1ñ „Xð1ð ðð ð ñ „Xðð
 ðð ð ñ „Xðð
 ð!ð !ð !ñ „Xð!ð ð(ð (ð (ñ „Xð(ð6 ð6ð 6ð 6ñ „Xð6ð ðð ð ñ „Xðð
 ðPð Pð Pñ „XðPð
 ð%ð %ð %ñ „Xð%ðð ð ð ð ð ð-ð -ð -ñ „Xð-ð ð?ð ?ð ?ñ „Xð?ð ðð ð ñ „Xðð ð7ð 7ð 7ñ „Xð7ð
!ð 
!ð 
!ð 
!ð	ð 	ð 	ð 	ðð ð ð ð2 ð6ð 6ð 6ñ „Xð6ð ð/ð /ð /ñ „Xð/ðQð Qð Qð Qð !&Ø).Ø!Øð'ð 'ð 'ð 'ð 'ðRRð Rð Rð Rð Rð !&Ø!Øðð ð ð ð ð< BFðEð Eð Eð Eð Eð( BFðð ð ð ð ð RVðð ð ð ð ðF Ø+0Ø,1ð	)
ð )
ð )
ð )
ð )
ðVTð Tð Tð Tð Tð ,1ðð ð ð ð ð4 TYðð ð ð ð ðB ,1ðð ð ð ð ð, ,1ðð ð ð ð ð8 ?@ðð ð ð ð ð( ?@ðð ð ð ð ð&5ð 5ð 5ð 5ð 5ð?ð ?ð ?ð ?ð ?ð >Bð
ð 
ð 
ð 
ð 
ð. >Bð
ð 
ð 
ð 
ð 
ð* BFðð ð ð ð ðD DHðð ð ð ð ðD CGðð ð ð ð ð(%ð %ð %ð %ð5ð 5ð 5ð 5ð
9ð 
9ð 
9ð 
9ð 
9ð3ð 3ð 3ð 3ðNð Nð Nð Nð
'ð 
'ð 
'ð 
'ðð ð ð ð*0 ð 0 ð 0 ð 0 ðd0ð 0ð 0ð 0ðd"+ð "+ð "+ð "+ðN !*¤Øð	?Lð ?Lð ?Lð ?Lð ?LðBð ð ð ð)ð )ð )ð )ð )ð$/ð /ð /ð /ð /ð$	
ð 	
ð 	
ð 	
ð
ð 
ð 
ð 
ð 
ð 
r   )&r#   Ú
__future__r   r�   r¨   r×   ÚweakrefÚtypingr   r   r   r   r   r	   r
   Ú	clipboardr   Úfiltersr   r@   r   r   r   Ú__all__ÚcompilerÇ   rÐ   rÑ   rÆ   rÒ   rÓ   r=   ÚWeakValueDictionaryr   Ú__annotations__r   r   r   r-   r   r   ú<module>ru     s  ððð ð ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø 	€	€	€	Ø €€€Ø €€€Ø JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ Jà $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?ð ð€ð �”
Ð>Ñ?Ô?€Ø"˜œ
Ð#GÑHÔHÐ Ø4>°B´JØ-ñ5ô 5Ð 1ð �B”J˜{Ñ+Ô+Ð Ø&˜BœJ |Ñ4Ô4Ð Ø8B¸¼
À?Ñ8SÔ8SÐ 5ð 6:°TØˆÐÐ	ÔØ€GÔÑ!Ô!ñ6ô 6Ð ð ð ð ñ ðð ð ð ð ˜˜cœñ ô ð ð(3ð 3ð 3ð 3ð 3ñ 3ô 3ð 3ðQ
ð Q
ð Q
ð Q
ð Q
ñ Q
ô Q
ð Q
ð Q
ð Q
r   