ó
    NÎh# ã            	      ó²  • S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKJr  SSKJr  SSKJr  SSKJrJrJrJrJrJr  SS	KJr  SS
KJr  SSKJrJr  SSKJ r   SSK!J"r"  SSK#J$r$J%r%J&r&J'r'J(r(  SSK)J*r*  SSK+J,r,  SSK-J.r.J/r/  SSK0J1r1J2r2  SSK3J4r4J5r5  SSK6J7r7J8r8J9r9  SSK:J;r;J<r<  SSK=J>r>J?r?  / SQr@\R‚                  " \B5      rC " S S\D5      rE " S S\5      rF " S S5      rG\R�                  " S5      rI " S S 5      rJ\S!/S4   rK\S!/\L4   rM " S" S!5      rN\" S#\S$\\\S4   4   S%9rOS,S& jrP " S' S(\D5      rQS-S.S) jjrRS-S.S* jjrSS/S+ jrTg)0zU
Data structures for the Buffer.
It holds the text, cursor position, history, etc...
é    )ÚannotationsN)Údeque)ÚEnum)Úwraps)ÚAnyÚCallableÚ	CoroutineÚIterableÚTypeVarÚcasté   )Úget_app)Úrun_in_terminal)ÚAutoSuggestÚ
Suggestion)ÚFastDictCache)ÚClipboardData)ÚCompleteEventÚ	CompleterÚ
CompletionÚDummyCompleterÚget_common_complete_suffix)ÚDocument)Úaclosing)ÚFilterOrBoolÚ	to_filter)ÚHistoryÚInMemoryHistory)ÚSearchDirectionÚSearchState)Ú	PasteModeÚSelectionStateÚSelectionType)ÚEventÚto_str)ÚValidationErrorÚ	Validator)ÚEditReadOnlyBufferÚBufferÚCompletionStateÚindentÚunindentÚreshape_textc                  ó   • \ rS rSrSrSrg)r(   é6   z.Attempt editing of read-only :class:`.Buffer`.© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r0   ó    ÚR/home/mande/repo/quber/.venv/lib/python3.13/site-packages/prompt_toolkit/buffer.pyr(   r(   6   s   † Ü4r8   r(   c                  ó$   • \ rS rSrSrSrSrSrSrg)ÚValidationStateé:   zCThe validation state of a buffer. This is set after the validation.ÚVALIDÚINVALIDÚUNKNOWNr0   N)	r2   r3   r4   r5   r6   r=   r>   r?   r7   r0   r8   r9   r;   r;   :   s   † ÙIà€EØ€GØƒGr8   r;   c                  ój   • \ rS rSrSr  S
       SS jjrSS jrSS jrSS jr\	SS j5       r
S	rg)r*   éB   z3
Immutable class that contains a completion state.
Nc                ó<   • Xl         U=(       d    / U l        X0l        g ©N)Úoriginal_documentÚcompletionsÚcomplete_index)ÚselfrD   rE   rF   s       r9   Ú__init__ÚCompletionState.__init__G   s!   € ð "3Ôð '×,¨"ˆÔð -Õr8   c                óš   • U R                   R                   SU R                  < S[        U R                  5      < SU R
                  < S3$ )NÚ(z, <z> completions, index=Ú))Ú	__class__r2   rD   ÚlenrE   rF   ©rG   s    r9   Ú__repr__ÚCompletionState.__repr__X   s_   € Ø—.‘.×)Ñ)Ð*¨!¨D×,BÑ,BÑ+EÀSÌÈT×M]ÑM]ÓI^ÑHaÐavÐw{÷  xKñ  xKñ  wNð  NOð  Pð  	Pr8   c                ó„   • U R                   (       a/  Ub%  SUs=::  a  [        U R                   5      :  d   e   eXl        gg)zt
Create a new :class:`.CompletionState` object with the new index.

When `index` is `None` deselect the completion.
Nr   )rE   rN   rF   ©rG   Úindexs     r9   Úgo_to_indexÚCompletionState.go_to_index[   sC   € ð ××Ø‘= A¨Õ$F´°T×5EÑ5EÓ1FÓ$FÐFÐFÐ$FÐFÐFØ"'Õð r8   c                ó¬  • U R                   c,  U R                  R                  U R                  R                  4$ U R                  R                  nU R                  R
                  nU R                  U R                      nUR                  S:X  a  UnOUSUR                   nXCR                  -   U-   n[        U5      [        UR                  5      -   nXV4$ )z=
Return (new_text, new_cursor_position) for this completion.
Nr   )	rF   rD   ÚtextÚcursor_positionÚtext_before_cursorÚtext_after_cursorrE   Ústart_positionrN   )rG   Úoriginal_text_before_cursorÚoriginal_text_after_cursorÚcÚbeforeÚnew_textÚnew_cursor_positions          r9   Únew_text_and_positionÚ%CompletionState.new_text_and_positione   sÄ   € ð ×ÑÑ&Ø×)Ñ)×.Ñ.°×0FÑ0F×0VÑ0VÐVÐVà*.×*@Ñ*@×*SÑ*SÐ'Ø)-×)?Ñ)?×)QÑ)QÐ&à× Ñ  ×!4Ñ!4Ñ5ˆAØ×Ñ 1Ó$Ø4‘à4Ð5G°q×7GÑ7GÐH�à§¡‘Ð)CÑCˆHÜ"% f£+´°A·F±F³Ñ";ÐØÐ0Ð0r8   c                óP   • U R                   b  U R                  U R                      $ g)zQ
Return the current completion, or return `None` when no completion is
selected.
N)rF   rE   rO   s    r9   Úcurrent_completionÚ"CompletionState.current_completiony   s*   € ð ×ÑÑ*Ø×#Ñ# D×$7Ñ$7Ñ8Ð8Ør8   )rF   rE   rD   )NN)rD   r   rE   zlist[Completion] | NonerF   ú
int | NoneÚreturnÚNone©ri   Ústr©rT   rh   ri   rj   )ri   ztuple[str, int])ri   zCompletion | None)r2   r3   r4   r5   r6   rH   rP   rU   rc   Úpropertyrf   r7   r0   r8   r9   r*   r*   B   s^   † ñð 04Ø%)ð	-à#ð-ð -ð-ð #ð	-ð
 
õ-ô"Pô(ô1ð( óó ór8   r*   z(\s+|".*?"|'.*?')c                  ó@   • \ rS rSrSr S       SS jjrS	S jrSrg)
ÚYankNthArgStateé‡   zL
For yank-last-arg/yank-nth-arg: Keep track of where we are in the history.
c                ó(   • Xl         X0l        X l        g rC   )Úhistory_positionÚprevious_inserted_wordÚn)rG   rs   ru   rt   s       r9   rH   ÚYankNthArgState.__init__Œ   s   € ð !1ÔØ&<Ô#Ø�r8   c                óˆ   • U R                   R                   SU R                  < SU R                  < SU R                  < S3$ )Nz(history_position=z, n=z, previous_inserted_word=rL   )rM   r2   rs   ru   rt   rO   s    r9   rP   ÚYankNthArgState.__repr__“   sa   € Ø—.‘.×)Ñ)Ð*Ð*<¸T×=RÑ=RÑ<UÐUYÐZ^×Z`ÑZ`ÑYcÐc|ð  ~B÷  ~Yñ  ~Yñ  }\ð  \]ð  ^ð  	^r8   )rs   ru   rt   N)r   éÿÿÿÿÚ )rs   Úintru   r{   rt   rl   ri   rj   rk   )r2   r3   r4   r5   r6   rH   rP   r7   r0   r8   r9   rp   rp   ‡   s9   † ñð
 UWðØ #ðØ,/ðØNQðà	õ÷^r8   rp   r)   c                  óž  • \ rS rSrSr                    SP                                         SQS jjrSRS jr SS     STS jjrSUS jrSVS jr	SWS	 jr
\SRS
 j5       r\R                  SXS j5       r\SYS j5       r\R                  SZS j5       r\SYS j5       r\R                  SZS j5       rSUS jrSUS jr\S[S j5       r\R                  S\S j5       rS]S^S jjr\S_S j5       rS`SaS jjr      SbS jrScS jr        SdS jrSeSfS jjrSeSfS jjrSeSfS jjrSeSfS jjr Sg     ShS jjr Sg     ShS  jjrSeSiS! jjrSeSiS" jjr SjSkS# jjr!SjSkS$ jjr"SUS% jr#SlS& jr$SgSmS' jjr% Sg     SmS( jjr&SUS) jr'SnS* jr(SUS+ jr)SoS, jr*SpS- jr+SUS. jr,SqS/ jr-SeSfS0 jjr.SeSfS1 jjr/SSSrS2 jjr0SsStS3 jjr1\2Rf                  4   SuS4 jjr4S]SvS5 jjr5SwS6 jr6\7Rp                  S4       SxS7 jjr9S`SyS8 jjr:S`SyS9 jjr;S`SyS: jjr<   Sz         S{S; jjr=SUS< jr>SUS= jr?S]S|S> jjr@SUS? jrASUS@ jrB  S}       S~SA jjrCSSB jrD  S€       S�SC jjrE  S€       S‚SD jjrFSUSE jrGSƒSF jrHSƒSG jrIS]S„SH jjrJS…SI jrK    S†         S‡SJ jjrLSˆSK jrMS‰SL jrN  S‰SM jrOSUSN jrPSOrQg)Šr)   é›   a  
The core data structure that holds the text and cursor position of the
current input line and implements all text manipulations on top of it. It
also implements the history, undo stack and the completion state.

:param completer: :class:`~prompt_toolkit.completion.Completer` instance.
:param history: :class:`~prompt_toolkit.history.History` instance.
:param tempfile_suffix: The tempfile suffix (extension) to be used for the
    "open in editor" function. For a Python REPL, this would be ".py", so
    that the editor knows the syntax highlighting to use. This can also be
    a callable that returns a string.
:param tempfile: For more advanced tempfile situations where you need
    control over the subdirectories and filename. For a Git Commit Message,
    this would be ".git/COMMIT_EDITMSG", so that the editor knows the syntax
    highlighting to use. This can also be a callable that returns a string.
:param name: Name for this buffer. E.g. DEFAULT_BUFFER. This is mostly
    useful for key bindings where we sometimes prefer to refer to a buffer
    by their name instead of by reference.
:param accept_handler: Called when the buffer input is accepted. (Usually
    when the user presses `enter`.) The accept handler receives this
    `Buffer` as input and should return True when the buffer text should be
    kept instead of calling reset.

    In case of a `PromptSession` for instance, we want to keep the text,
    because we will exit the application, and only reset it during the next
    run.
:param max_number_of_completions: Never display more than this number of
    completions, even when the completer can produce more (limited by
    default to 10k for performance).

Events:

:param on_text_changed: When the buffer text changes. (Callable or None.)
:param on_text_insert: When new text is inserted. (Callable or None.)
:param on_cursor_position_changed: When the cursor moves. (Callable or None.)
:param on_completions_changed: When the completions were changed. (Callable or None.)
:param on_suggestion_set: When an auto-suggestion text has been set. (Callable or None.)

Filters:

:param complete_while_typing: :class:`~prompt_toolkit.filters.Filter`
    or `bool`. Decide whether or not to do asynchronous autocompleting while
    typing.
:param validate_while_typing: :class:`~prompt_toolkit.filters.Filter`
    or `bool`. Decide whether or not to do asynchronous validation while
    typing.
:param enable_history_search: :class:`~prompt_toolkit.filters.Filter` or
    `bool` to indicate when up-arrow partial string matching is enabled. It
    is advised to not enable this at the same time as
    `complete_while_typing`, because when there is an autocompletion found,
    the up arrows usually browse through the completions, rather than
    through the history.
:param read_only: :class:`~prompt_toolkit.filters.Filter`. When True,
    changes will not be allowed.
:param multiline: :class:`~prompt_toolkit.filters.Filter` or `bool`. When
    not set, pressing `Enter` will call the `accept_handler`.  Otherwise,
    pressing `Esc-Enter` is required.
Nc                óð  • [        U
5      n
[        U5      n[        U	5      n	[        U5      n[        U5      nU=(       d
    [        5       U l        X l        X@l        XPl        X`l        Xpl        XÀl        X€l	        X�l
        X l        XÐl        Xàl        Xðl        SU l        Uc
  [!        5       OUU l        SU l        ['        U U5      U l        ['        U U5      U l        ['        U U5      U l        ['        U U5      U l        ['        U U5      U l        [3        [4        SS9U l        U R9                  5       U l        U R=                  5       U l        U RA                  5       U l!        S U l"        U RG                  US9  g )Nr   é
   )Úsize)Údocument)$r   r   Ú	completerÚauto_suggestÚ	validatorÚtempfile_suffixÚtempfileÚnameÚaccept_handlerÚcomplete_while_typingÚvalidate_while_typingÚenable_history_searchÚ	read_onlyÚ	multilineÚmax_number_of_completionsÚ
text_widthr   ÚhistoryÚ_Buffer__cursor_positionr$   Úon_text_changedÚon_text_insertÚon_cursor_position_changedÚon_completions_changedÚon_suggestion_setr   r   Ú_document_cacheÚ_create_auto_suggest_coroutineÚ_async_suggesterÚ_create_completer_coroutineÚ_async_completerÚ_create_auto_validate_coroutineÚ_async_validatorÚ_load_history_taskÚreset)rG   r‚   rƒ   r�   r„   r…   r†   r‡   r‰   rŠ   r‹   r�   rˆ   rŒ   r�   rŽ   r’   r“   r”   r•   r–   s                        r9   rH   ÚBuffer.__init__×   sm  € ô0 !*Ð*?Ó @ÐÜ )Ð*?Ó @ÐÜ )Ð*?Ó @ÐÜ˜iÓ(ˆ	Ü˜iÓ(ˆ	à"×6¤nÓ&6ˆŒØ(ÔØ"ŒØ.ÔØ ŒØŒ	Ø,Ôð &;Ô"Ø%:Ô"Ø%:Ô"Ø"ŒØ"ŒØ)BÔ&ð ˆŒð
 -4©O”Ô(ÀˆŒà!"ˆÔô /4°D¸/Ó.JˆÔÜ-2°4¸Ó-HˆÔÜ9>ØÐ,ó:
ˆÔ'ô 6;¸4ÐAWÓ5XˆÔ#Ü05°dÐ<MÓ0NˆÔô
 œ(¨Ñ,ð 	Ôð
 !%× CÑ CÓ EˆÔØ $× @Ñ @Ó BˆÔØ $× DÑ DÓ FˆÔð @DˆÔð 	�
‰
˜Hˆ
Ò%r8   c                ó¶   • [        U R                  5      S:  a  U R                  nOU R                  S S S-   nSU R                  < SU< S[        U 5      < S3$ )Né   é   z...z<Buffer(name=z, text=z) at Ú>)rN   rX   r‡   Úid)rG   rX   s     r9   rP   ÚBuffer.__repr__(  sR   € Üˆt�y‰y‹>˜BÓØ—9‘9‰Dà—9‘9˜S˜b�> EÑ)ˆDà˜tŸy™y™m¨7°4±(¸%ÄÀ4Ã¹|È1ÐMÐMr8   c                óÞ  • U(       a  U R                  5         U=(       d
    [        5       nUR                  U l        SU l        [
        R                  U l        SU l        / U l	        SU l
        SU l        SU l        SU l        SU l        SU l        / U l        / U l        U R$                  b  U R$                  R'                  5         SU l        [)        UR*                  /5      U l        SU l        g)zB
:param append_to_history: Append current input to history first.
Nr   )Úappend_to_historyr   rY   r‘   Úvalidation_errorr;   r?   Úvalidation_stateÚselection_stateÚmultiple_cursor_positionsÚpreferred_columnÚcomplete_stateÚyank_nth_arg_stateÚdocument_before_pasteÚ
suggestionÚhistory_search_textÚ_undo_stackÚ_redo_stackrž   Úcancelr   rX   Ú_working_linesÚ_Buffer__working_index)rG   r�   r¨   s      r9   rŸ   ÚBuffer.reset0  së   € ö Ø×"Ñ"Ô$à×)œx›zˆà!)×!9Ñ!9ˆÔð 9=ˆÔÜ8G×8OÑ8OˆÔð 7;ˆÔð
 57ˆÔ&ð -1ˆÔð 7;ˆÔð ;?ˆÔð 7;ˆÔ"ð .2ˆŒð 04ˆÔ ð 35ˆÔØ24ˆÔð
 ×"Ñ"Ñ.Ø×#Ñ#×*Ñ*Ô,Ø"&ˆÔô +0°·±°Ó*@ˆÔØ ˆÕr8   c                ó¸   ^ • T R                   cL  SU 4S jjn[        5       R                  U" 5       5      T l         SS jnT R                   R                  U5        gg)a~  
Create task for populating the buffer history (if not yet done).

Note::

    This needs to be called from within the event loop of the
    application, because history loading is async, and we need to be
    sure the right event loop is active. Therefor, we call this method
    in the `BufferControl.create_content`.

    There are situations where prompt_toolkit applications are created
    in one thread, but will later run in a different thread (Ptpython
    is one example. The REPL runs in a separate thread, in order to
    prevent interfering with a potential different event loop in the
    main thread. The REPL UI however is still created in the main
    thread.) We could decide to not support creating prompt_toolkit
    objects in one thread and running the application in a different
    thread, but history loading is the only place where it matters, and
    this solves it.
Nc               “  ó¾   >#   • TR                   R                  5         S h  v•N n TR                  R                  U 5        T=R                  S-  sl        M;   N6
 g 7f)Nr   )r�   Úloadr¶   Ú
appendleftr·   )ÚitemrG   s    €r9   Úload_historyÚ;Buffer.load_history_if_not_yet_loaded.<locals>.load_historyˆ  sJ   øé € Ø"&§,¡,×"3Ñ"3Ô"5÷ .˜$Ø×'Ñ'×2Ñ2°4Ô8Ø×(Ò(¨AÑ-×(ñ.Ñ"5ùs%   ƒAžA¢A£A¦3AÁAÁAc                ó°   •  U R                  5         g! [        R                   a     g[         a     g[         a    [
        R                  S5         gf = f)z\
Handle `load_history` result when either done, cancelled, or
when an exception was raised.
zLoading history failedN)ÚresultÚasyncioÚCancelledErrorÚGeneratorExitÚBaseExceptionÚloggerÚ	exception)Úfs    r9   Úload_history_doneÚ@Buffer.load_history_if_not_yet_loaded.<locals>.load_history_done�  sP   € ð
?Ø—H‘H•JøÜ×-Ñ-ó ñ Ü$ó ñ Ü$ó ?ô ×$Ñ$Ð%=Ö>ð?ús   ‚ “A©	A´AÁA©ri   rj   )rÈ   zasyncio.Future[None]ri   rj   )rž   r   Úcreate_background_taskÚadd_done_callback)rG   r¾   rÉ   s   `  r9   Úload_history_if_not_yet_loadedÚ%Buffer.load_history_if_not_yet_loadedq  sP   ø€ ð* ×"Ñ"Ñ*÷.ô
 '.£i×&FÑ&FÁ|Ã~Ó&VˆDÔ#ô?ð* ×#Ñ#×5Ñ5Ð6GÕHð= +r8   c                ó‚   • U R                   nU R                  nX2   nXU'   [        U5      [        U5      :w  a  gX:w  a  gg)z=set text at current working_index. Return whether it changed.TF)Úworking_indexr¶   rN   )rG   ÚvaluerÑ   Úworking_linesÚoriginal_values        r9   Ú	_set_textÚBuffer._set_text¨  sL   € à×*Ñ*ˆØ×+Ñ+ˆà&Ñ5ˆØ',�mÑ$ô ˆu‹:œ˜^Ó,Ó,ð ØÓ$ØØr8   c                óZ   • U R                   n[        SU5      U l         U R                   U:g  $ )z/Set cursor position. Return whether it changed.r   )r‘   Úmax)rG   rÒ   Úoriginal_positions      r9   Ú_set_cursor_positionÚBuffer._set_cursor_position¼  s.   € à ×2Ñ2ÐÜ!$ Q¨£ˆÔà×%Ñ%Ð):Ñ:Ð:r8   c                ó4   • U R                   U R                     $ rC   )r¶   rÑ   rO   s    r9   rX   ÚBuffer.textÃ  s   € à×"Ñ" 4×#5Ñ#5Ñ6Ð6r8   c                óô   • U R                   [        U5      :”  a  [        U5      U l         U R                  5       (       a
  [        5       eU R	                  U5      nU(       a  U R                  5         SU l        gg)z¶
Setting text. (When doing this, make sure that the cursor_position is
valid for this text. text/cursor_position should be consistent at any time,
otherwise set a Document instead.)
N)rY   rN   rŒ   r(   rÕ   Ú_text_changedr²   ©rG   rÒ   Úchangeds      r9   rX   rÝ   Ç  sf   € ð ×Ñ¤# e£*Ó,Ü#& u£:ˆDÔ ð �>‰>×ÑÜ$Ó&Ð&à—.‘. Ó'ˆæØ×ÑÔ ð (,ˆDÕ$ð r8   c                ó   • U R                   $ rC   )r‘   rO   s    r9   rY   ÚBuffer.cursor_positioná  s   € à×%Ñ%Ð%r8   c                óð   • [        U[        5      (       d   eU[        U R                  5      :”  a  [        U R                  5      nUS:  a  SnU R	                  U5      nU(       a  U R                  5         gg)z
Setting cursor position.
r   N)Ú
isinstancer{   rN   rX   rÚ   Ú_cursor_position_changedrà   s      r9   rY   rã   å  sf   € ô
 ˜%¤×%Ñ%Ð%Ð%ð ”3�t—y‘y“>Ó!Ü˜Ÿ	™	“NˆEØ�1‹9ØˆEà×+Ñ+¨EÓ2ˆæØ×)Ñ)Õ+ð r8   c                ó   • U R                   $ rC   )r·   rO   s    r9   rÑ   ÚBuffer.working_index÷  s   € à×#Ñ#Ð#r8   c                ó`   • U R                   U:w  a  Xl         SU l        U R                  5         g g )Nr   )r·   rY   rß   ©rG   rÒ   s     r9   rÑ   rè   û  s1   € à×Ñ 5Ó(Ø#(Ô ð $%ˆDÔ Ø×ÑÕ ð )r8   c                ób  • S U l         [        R                  U l        S U l        S U l        S U l        S U l        S U l        S U l	        U R                  R                  5         U R                  (       a>  U R                  5       (       a(  [        5       R                  U R!                  5       5        g g g rC   )r©   r;   r?   rª   r®   r¯   r°   r«   r±   r­   r’   Úfirer„   rŠ   r   rÌ   r�   rO   s    r9   rß   ÚBuffer._text_changed  s’   € à $ˆÔÜ /× 7Ñ 7ˆÔØ"ˆÔØ"&ˆÔØ%)ˆÔ"Ø#ˆÔØˆŒØ $ˆÔð 	×Ñ×!Ñ!Ô#ð
 �>�>˜d×8Ñ8×:Ñ:Ü‹I×,Ñ,¨T×-BÑ-BÓ-DÕEð ;ˆ>r8   c                óp   • S U l         S U l        S U l        S U l        U R                  R                  5         g rC   )r®   r¯   r°   r­   r”   rì   rO   s    r9   ræ   ÚBuffer._cursor_position_changed  s:   € ð #ˆÔØ"&ˆÔØ%)ˆÔ"ð !%ˆÔð 	×'Ñ'×,Ñ,Õ.r8   c                ób   • U R                   U R                  U R                  U R                  4   $ )zx
Return :class:`~prompt_toolkit.document.Document` instance from the
current text, cursor position and selection state.
)r—   rX   rY   r«   rO   s    r9   r�   ÚBuffer.document+  s1   € ð ×#Ñ#Ø�I‰I�t×+Ñ+¨T×-AÑ-AÐAñ
ð 	
r8   c                ó&   • U R                  U5        g)zÎ
Set :class:`~prompt_toolkit.document.Document` instance.

This will set both the text and cursor position at the same time, but
atomically. (Change events will be triggered only after both have been set.)
N)Úset_documentrê   s     r9   r�   rñ   5  s   € ð 	×Ñ˜%Õ r8   c                ó(  • U(       d  U R                  5       (       a
  [        5       eU R                  UR                  5      nU R	                  UR
                  5      nU(       a  U R                  5         SU l        U(       a  U R                  5         gg)aË  
Set :class:`~prompt_toolkit.document.Document` instance. Like the
``document`` property, but accept an ``bypass_readonly`` argument.

:param bypass_readonly: When True, don't raise an
                        :class:`.EditReadOnlyBuffer` exception, even
                        when the buffer is read-only.

.. warning::

    When this buffer is read-only and `bypass_readonly` was not passed,
    the `EditReadOnlyBuffer` exception will be caught by the
    `KeyProcessor` and is silently suppressed. This is important to
    keep in mind when writing key bindings, because it won't do what
    you expect, and there won't be a stack trace. Use try/finally
    around this function if you need some cleanup code.
N)	rŒ   r(   rÕ   rX   rÚ   rY   rß   r²   ræ   )rG   rÒ   Úbypass_readonlyÚtext_changedÚcursor_position_changeds        r9   ró   ÚBuffer.set_document?  st   € ö&  4§>¡>×#3Ñ#3Ü$Ó&Ð&ð —~‘~ e§j¡jÓ1ˆØ"&×";Ñ";¸E×<QÑ<QÓ"RÐö Ø×ÑÔ Ø'+ˆDÔ$æ"Ø×)Ñ)Õ+ð #r8   c                ó,   • [        U R                  5      $ )z/
True when there is something handling accept.
)Úboolrˆ   rO   s    r9   Úis_returnableÚBuffer.is_returnableb  s   € ô
 �D×'Ñ'Ó(Ð(r8   c                ó>  • U R                   (       aL  U R                   S   S   U R                  :X  a,  U R                   S   S   U R                  4U R                   S'   O1U R                   R                  U R                  U R                  45        U(       a  / U l        gg)za
Safe current state (input text and cursor position), so that we can
restore it by calling undo.
ry   r   N)r³   rX   rY   Úappendr´   )rG   Úclear_redo_stacks     r9   Úsave_to_undo_stackÚBuffer.save_to_undo_stackk  sˆ   € ð ×× × 0Ñ 0°Ñ 4°QÑ 7¸4¿9¹9Ó DØ$(×$4Ñ$4°RÑ$8¸Ñ$;¸T×=QÑ=QÐ#RˆD×Ñ˜RÒ à×Ñ×#Ñ# T§Y¡Y°×0DÑ0DÐ$EÔFö Ø!ˆDÕð r8   c                ó¨   • U R                   R                  S5      nU H  n U" X4   5      X4'   M     SR                  U5      $ ! [         a     M2  f = f)aß  
Transforms the text on a range of lines.
When the iterator yield an index not in the range of lines that the
document contains, it skips them silently.

To uppercase some lines::

    new_text = transform_lines(range(5,10), lambda text: text.upper())

:param line_index_iterator: Iterator of line numbers (int)
:param transform_callback: callable that takes the original text of a
                           line, and return the new text for this line.

:returns: The new text.
Ú
)rX   ÚsplitÚ
IndexErrorÚjoin)rG   Úline_index_iteratorÚtransform_callbackÚlinesrT   s        r9   Útransform_linesÚBuffer.transform_lines{  sZ   € ð* —	‘	—‘ Ó%ˆó )ˆEðÙ1°%±,Ó?�“ñ )ð �y‰y˜ÓÐøô ó Úðús   ¢AÁ
AÁAc                ó  • U R                   nUR                  UR                  5       -   nUR                  UR                  5       -   nUR                  SU U" UR                  X4 5      -   UR                  US -   U l        g)z�
Apply the given transformation function to the current line.

:param transform_callback: callable that takes a string and return a new string.
N)r�   rY   Úget_start_of_line_positionÚget_end_of_line_positionrX   )rG   r  r�   ÚaÚbs        r9   Útransform_current_lineÚBuffer.transform_current_line›  s}   € ð —=‘=ˆØ×$Ñ$ x×'JÑ'JÓ'LÑLˆØ×$Ñ$ x×'HÑ'HÓ'JÑJˆà�M‰M˜"˜1ÐÙ  §¡¨qÐ!3Ó4ñ5à�m‰m˜A˜BÐñ ð 	�	r8   c                ó¤   • X:  d   eSR                  U R                  SU U" U R                  X 5      -   U R                  US -   /5      U l        g)zÎ
Transform a part of the input string.

:param from_: (int) start position.
:param to: (int) end position.
:param transform_callback: Callable which accepts a string and returns
    the transformed string.
rz   N)r  rX   )rG   Úfrom_Útor  s       r9   Útransform_regionÚBuffer.transform_regionª  sY   € ð ‹zÐˆzà—G‘Gà—	‘	˜&˜5Ð!Ù$ T§Y¡Y¨uÐ%8Ó9ñ:à—)‘)˜B˜C�.ñ!ðó
ˆ�	r8   r   c                ó\   • U =R                   U R                  R                  US9-  sl         g ©N©Úcount)rY   r�   Úget_cursor_left_position©rG   r  s     r9   Úcursor_leftÚBuffer.cursor_left¿  s%   € Ø×Ò §¡× FÑ FÈUÐ FÐ SÑSÖr8   c                ó\   • U =R                   U R                  R                  US9-  sl         g r  )rY   r�   Úget_cursor_right_positionr  s     r9   Úcursor_rightÚBuffer.cursor_rightÂ  s%   € Ø×Ò §¡× GÑ GÈeÐ GÐ TÑTÖr8   c                óº   • U R                   =(       d    U R                  R                  nU =R                  U R                  R	                  XS9-  sl        X l         g)z7(for multiline edit). Move cursor to the previous line.©r  r­   N)r­   r�   Úcursor_position_colrY   Úget_cursor_up_position©rG   r  Úoriginal_columns      r9   Ú	cursor_upÚBuffer.cursor_upÅ  sO   € à×/Ñ/×T°4·=±=×3TÑ3TˆØ×Ò §¡× DÑ DØð !Eð !
ñ 	
Õð
 !0Õr8   c                óº   • U R                   =(       d    U R                  R                  nU =R                  U R                  R	                  XS9-  sl        X l         g)z3(for multiline edit). Move cursor to the next line.r%  N)r­   r�   r&  rY   Úget_cursor_down_positionr(  s      r9   Úcursor_downÚBuffer.cursor_downÏ  sO   € à×/Ñ/×T°4·=±=×3TÑ3TˆØ×Ò §¡× FÑ FØð !Gð !
ñ 	
Õð
 !0Õr8   c                óF  • U R                   (       a  U R                  US9  gU R                  R                  S:”  a  U R	                  US9  gU R
                  (       dE  U R                  US9  U(       a.  U =R                  U R                  R                  5       -  sl        ggg)z}
If we're not on the first line (of a multiline input) go a line up,
otherwise go back in history. (If nothing is selected.)
r  r   N)	r®   Úcomplete_previousr�   Úcursor_position_rowr*  r«   Úhistory_backwardrY   r  ©rG   r  Ú&go_to_start_of_line_if_history_changess      r9   Úauto_upÚBuffer.auto_upÙ  s…   € ð ××Ø×"Ñ"¨Ð"Ò/Ø�]‰]×.Ñ.°Ó2Ø�N‰N ˆNÒ'Ø×%×%Ø×!Ñ!¨Ð!Ñ.ö 6Ø×$Ò$¨¯©×(PÑ(PÓ(RÑRÖ$ð 6ð	 &r8   c                ót  • U R                   (       a  U R                  US9  gU R                  R                  U R                  R                  S-
  :  a  U R                  US9  gU R                  (       dE  U R                  US9  U(       a.  U =R                  U R                  R                  5       -  sl        ggg)z�
If we're not on the last line (of a multiline input) go a line down,
otherwise go forward in history. (If nothing is selected.)
r  r   N)
r®   Úcomplete_nextr�   r2  Ú
line_countr.  r«   Úhistory_forwardrY   r  r4  s      r9   Ú	auto_downÚBuffer.auto_downë  s—   € ð ××Ø×Ñ UÐÒ+Ø�]‰]×.Ñ.°·±×1IÑ1IÈAÑ1MÓMØ×Ñ 5ÐÒ)Ø×%×%Ø× Ñ  uÐ Ñ-ö 6Ø×$Ò$¨¯©×(PÑ(PÓ(RÑRÖ$ð 6ð	 &r8   c                óB  • US:¼  d   eSnU R                   S:”  a„  U R                  U R                   U-
  U R                    nU R                  SU R                   U-
   U R                  U R                   S -   nU R                   [        U5      -
  n[        X45      U l        U$ )zR
Delete specified number of characters before cursor and return the
deleted text.
r   rz   N)rY   rX   rN   r   r�   )rG   r  Údeletedra   rb   s        r9   Údelete_before_cursorÚBuffer.delete_before_cursorý  s©   € ð
 ˜‹zÐˆzØˆà×Ñ !Ó#Ø—i‘i × 4Ñ 4°uÑ <¸t×?SÑ?SÐTˆGð —	‘	Ð8˜D×0Ñ0°5Ñ8Ð9Ø—)‘)˜D×0Ñ0Ð2Ð3ñ4ð ð #'×"6Ñ"6¼¸W»Ñ"EÐô % XÓCˆDŒMàˆr8   c                ó  • U R                   [        U R                  5      :  a_  U R                  R                  SU nU R                  SU R                    U R                  U R                   [        U5      -   S -   U l        U$ g)zD
Delete specified number of characters and Return the deleted text.
Nrz   )rY   rN   rX   r�   r[   )rG   r  r?  s      r9   ÚdeleteÚBuffer.delete  sz   € ð ×Ñ¤# d§i¡i£.Ó0Ø—m‘m×5Ñ5°f°uÐ=ˆGà—	‘	Ð0˜D×0Ñ0Ð1Ø—)‘)˜D×0Ñ0´3°w³<Ñ?ÐAÐBñCð ŒIð ˆNàr8   c                ó>  • U R                   R                  (       d‚  U =R                  U R                   R                  5       -  sl        U R	                  5         U R                   R
                  U-   U R                   R                  R                  S5      -   U l        gg)z[
Join the next line to the current one by deleting the line ending after
the current line.
Ú N)	r�   Úon_last_linerY   r  rC  rZ   r[   ÚlstriprX   )rG   Ú	separators     r9   Újoin_next_lineÚBuffer.join_next_line!  sx   € ð
 �}‰}×)×)Ø× Ò  D§M¡M×$JÑ$JÓ$LÑLÕ Ø�K‰KŒMð —‘×0Ñ0Øñà—-‘-×1Ñ1×8Ñ8¸Ó=ñ>ð �Ið *r8   c                óÒ  • U R                   (       d   e[        U R                  U R                   R                  /5      u  p#U R                  SU nU R                  X# R                  5       nU R                  US nU Vs/ s H  owR                  S5      U-   PM     nn[        USR                  U5      -   U-   [        USR                  USS 5      -   5      S-
  S9U l
        gs  snf )z
Join the selected lines.
NrF  rz   ry   r   ©rX   rY   )r«   ÚsortedrY   Úoriginal_cursor_positionrX   Ú
splitlinesrH  r   r  rN   r�   )rG   rI  r  r  r`   r	  ÚafterÚls           r9   Újoin_selected_linesÚBuffer.join_selected_lines1  sÝ   € ð ×#×#Ð#Ð#ô Ø×!Ñ! 4×#7Ñ#7×#PÑ#PÐQó
‰	ˆð —‘˜6˜EÐ"ˆØ—	‘	˜%Ð#×.Ñ.Ó0ˆØ—	‘	˜"˜#�ˆñ 5:Ó:²E¨q—‘˜#“ Ô*±EˆÐ:ô !Ø˜"Ÿ'™' %›.Ñ(¨5Ñ0Ü ¨¯©°°s¸°Ó)<Ñ <Ó=ÀÑAñ
ˆ�ùò ;s   Á?C$c                óÌ   • U R                   nUS:¼  aR  U R                  US-
     nU R                  US-
     nU R                  SUS-
   U-   U-   U R                  US -   U l        gg)z1
Swap the last two characters before the cursor.
é   r   N)rY   rX   )rG   Úposr  r  s       r9   Úswap_characters_before_cursorÚ$Buffer.swap_characters_before_cursorI  sn   € ð ×"Ñ"ˆà�!‹8Ø—	‘	˜# ™'Ñ"ˆAØ—	‘	˜# ™'Ñ"ˆAàŸ	™	 ) C¨!¡GÐ,¨qÑ0°1Ñ4°t·y±yÀÀ°ÑFˆD�Ið	 r8   c                óx   • U[        U R                  5      :  a!  Xl        [        U R                  5      U l        gg)z!
Go to this item in the history.
N)rN   r¶   rÑ   rX   rY   rS   s     r9   Úgo_to_historyÚBuffer.go_to_historyU  s2   € ð ”3�t×*Ñ*Ó+Ó+Ø!&ÔÜ#& t§y¡y£>ˆDÕ ð ,r8   c                óX  • U R                   (       a™  [        U R                   R                  5      nU R                   R                  c  SnONU R                   R                  US-
  :X  a  SnU(       a  gO&[	        US-
  U R                   R                  U-   5      nU R                  U5        gg)zL
Browse to the next completions.
(Does nothing if there are no completion.)
Nr   r   )r®   rN   rE   rF   ÚminÚgo_to_completion)rG   r  Údisable_wrap_aroundÚcompletions_countrT   s        r9   r9  ÚBuffer.complete_next]  s¢   € ð ××Ü # D×$7Ñ$7×$CÑ$CÓ DÐà×"Ñ"×1Ñ1Ñ9Ø‘Ø×$Ñ$×3Ñ3Ð7HÈ1Ñ7LÓLØ�æ&Øð 'ô Ø%¨Ñ)¨4×+>Ñ+>×+MÑ+MÐPUÑ+Uó�ð ×!Ñ! %Õ(ð r8   c                óN  • U R                   (       a”  U R                   R                  S:X  a  SnU(       a  gO]U R                   R                  c#  [        U R                   R                  5      S-
  nO#[	        SU R                   R                  U-
  5      nU R                  U5        gg)zP
Browse to the previous completions.
(Does nothing if there are no completion.)
r   Nr   )r®   rF   rN   rE   rØ   r_  )rG   r  r`  rT   s       r9   r1  ÚBuffer.complete_previoust  sŽ   € ð ××Ø×"Ñ"×1Ñ1°QÓ6Ø�æ&Øð 'à×$Ñ$×3Ñ3Ñ;Ü˜D×/Ñ/×;Ñ;Ó<¸qÑ@‘ä˜A˜t×2Ñ2×AÑAÀEÑIÓJ�à×!Ñ! %Õ(ð r8   c                óX   • U R                   (       a  U R                  S5        SU l         gg)z2
Cancel completion, go back to the original text.
N)r®   r_  rO   s    r9   Úcancel_completionÚBuffer.cancel_completionŠ  s(   € ð ××Ø×!Ñ! $Ô'Ø"&ˆDÕð r8   c                ó€   • [        U R                  US9U l        U R                  R	                  5         U R                  $ )zp
Start completions. (Generate list of completions and initialize.)

By default, no completion will be selected.
)rD   rE   )r*   r�   r®   r•   rì   )rG   rE   s     r9   Ú_set_completionsÚBuffer._set_completions’  s:   € ô .Ø"Ÿm™m¸ñ
ˆÔð
 	×#Ñ#×(Ñ(Ô*à×"Ñ"Ð"r8   c           
     óX  • [        5       n/ nU R                  R                  R                  5       n[	        U R
                  5       H»  u  pE[	        UR                  S5      5       H˜  u  pgUR                  5       nU(       d  M  UR                  U5      (       d  M6  Xq;  d  M=  UR                  U5        X@R                  :X  a	  SUS-   -  nOSUS-    SUS-    3nUR                  [        U[        U5      * US95        Mš     M½     U R                  USSS2   S	9  U R                  S
5        g)zR
Start a completion based on all the other lines in the document and the
history.
r  zCurrent, line %sr   zHistory z, line )rX   r\   Údisplay_metaNry   ©rE   r   )Úsetr�   Úcurrent_line_before_cursorrH  Ú	enumerater¶   r  ÚstripÚ
startswithÚaddrÑ   rþ   r   rN   ri  r_  )	rG   Úfound_completionsrE   Úcurrent_lineÚiÚstringÚjrR  rl  s	            r9   Ústart_history_lines_completionÚ%Buffer.start_history_lines_completion¡  s  € ô
 '*£eÐØˆð —}‘}×?Ñ?×FÑFÓHˆä" 4×#6Ñ#6Ö7‰IˆAÜ! &§,¡,¨tÓ"4Ö5‘�Ø—G‘G“I�ß�1˜Ÿ™ l×3Ó3àÕ1Ø)×-Ñ-¨aÔ0ð × 2Ñ 2Ó2Ø+=ÀÀQÁÑ+G™Là-5°a¸!±e°W¸GÀAÈÁEÀ7Ð+K˜Là#×*Ñ*Ü&Ø%&Ü03°LÓ0AÐ/AØ-9ñöó 6ñ 8ð, 	×Ñ¨+±d¸°dÑ*;ÐÑ<Ø×Ñ˜aÕ r8   c                ó´   • U R                   (       d   eU R                   nUR                  U5        UR                  5       u  p4[        X45      U l        X l         g)z;
Select a completion from the list of current completions.
N)r®   rU   rc   r   r�   )rG   rT   Ústatera   rb   s        r9   r_  ÚBuffer.go_to_completionÅ  sU   € ð ×"×"Ð"Ð"ð ×#Ñ#ˆØ×Ñ˜%Ô ð ).×(CÑ(CÓ(EÑ%ˆÜ  Ó?ˆŒð $Õr8   c                óÄ   • U R                   (       a  U R                  S5        SU l         U R                  UR                  * 5        U R	                  UR
                  5        g)z
Insert a given completion.
N)r®   r_  r@  r\   Úinsert_textrX   )rG   Ú
completions     r9   Úapply_completionÚBuffer.apply_completionÖ  sN   € ð
 ××Ø×!Ñ! $Ô'Ø"ˆÔð 	×!Ñ! :×#<Ñ#<Ð"<Ô=Ø×Ñ˜Ÿ™Õ)r8   c                ó�   • U R                  5       (       a*  U R                  c  U R                  R                  U l        ggSU l        g)za
Set `history_search_text`.
(The text before the cursor will be used for filtering the history.)
N)r‹   r²   r�   rZ   rO   s    r9   Ú_set_history_searchÚBuffer._set_history_searchã  s@   € ð
 ×%Ñ%×'Ñ'Ø×'Ñ'Ñ/Ø+/¯=©=×+KÑ+K�Õ(ð 0ð (,ˆDÕ$r8   c                ó|   • U R                   SL =(       d(    U R                  U   R                  U R                   5      $ )zn
True when the current entry matches the history search.
(when we don't have history search, it's also True.)
N)r²   r¶   rr  )rG   rv  s     r9   Ú_history_matchesÚBuffer._history_matchesî  s=   € ð
 ×'Ñ'¨4Ð/÷ 
°4×3FÑ3FÀqÑ3I×3TÑ3TØ×$Ñ$ó4
ð 	
r8   c                ó\  • U R                  5         Sn[        U R                  S-   [        U R                  5      5       H.  nU R                  U5      (       a  X0l        US-  nSnUS:X  d  M.    O   U(       a5  SU l        U =R                  U R                  R                  5       -  sl        gg)zT
Move forwards through the history.

:param count: Amount of items to move forward.
Fr   Tr   N)	r„  ÚrangerÑ   rN   r¶   r‡  rY   r�   r  ©rG   r  Úfound_somethingrv  s       r9   r;  ÚBuffer.history_forward÷  sž   € ð 	× Ñ Ô"ð  ˆä�t×)Ñ)¨AÑ-¬s°4×3FÑ3FÓ/GÖHˆAØ×$Ñ$ Q×'Ñ'Ø%&Ô"Ø˜‘
�Ø"&�Ø˜�zÙñ Iö Ø#$ˆDÔ Ø× Ò  D§M¡M×$JÑ$JÓ$LÑLÖ ð r8   c                ó  • U R                  5         Sn[        U R                  S-
  SS5       H.  nU R                  U5      (       a  X0l        US-  nSnUS:X  d  M.    O   U(       a  [	        U R
                  5      U l        gg)z!
Move backwards through history.
Fr   ry   Tr   N)r„  rŠ  rÑ   r‡  rN   rX   rY   r‹  s       r9   r3  ÚBuffer.history_backward  s~   € ð 	× Ñ Ô"ð  ˆä�t×)Ñ)¨AÑ-¨r°2Ö6ˆAØ×$Ñ$ Q×'Ñ'Ø%&Ô"Ø˜‘
�Ø"&�Ø˜�zÙñ 7ö Ü#& t§y¡y£>ˆDÕ ð r8   c                óà  • Ub  [        U[        5      (       d   eU R                  R                  5       n[	        U5      (       d  gU R
                  c  [        U(       a  SOSS9nOU R
                  nUb  Xl        UR                  S-
  nU* [	        U5      :”  a  SnX5   n[        R                  U5       Vs/ s H  owR                  5       PM     nnU Vs/ s H  ow(       d  M  UPM     nn X„R                     n	UR                  (       a$  U R                  [	        UR                  5      5        U R                  U	5        X”l        XTl        X@l        gs  snf s  snf ! [         a    Sn	 Nqf = f)aA  
Pick nth word from previous history entry (depending on current
`yank_nth_arg_state`) and insert it at current position. Rotate through
history if called repeatedly. If no `n` has been given, take the first
argument. (The second word.)

:param n: (None or int), The index of the word from the previous line
    to take.
Nry   r   )ru   rz   )rå   r{   r�   Úget_stringsrN   r¯   rp   ru   rs   Ú_QUOTED_WORDS_REr  rq  r  rt   r@  r  )
rG   ru   Ú_yank_last_argÚhistory_stringsr|  Únew_posÚlineÚwÚwordsÚwords
             r9   Úyank_nth_argÚBuffer.yank_nth_arg$  sL  € ð ‰yœJ q¬#×.Ñ.Ð.Ð.ØŸ,™,×2Ñ2Ó4ˆä�?×#Ñ#Øð ×"Ñ"Ñ*Ü#®N¡bÀÑB‰Eà×+Ñ+ˆEà‰=ØŒGð ×(Ñ(¨1Ñ,ˆØˆ8”c˜/Ó*Ó*ØˆGð Ñ'ˆä$4×$:Ñ$:¸4Ô$@ÓAÒ$@˜q—‘–Ñ$@ˆÐAÙ!Ó'šE�q£Q—™EˆÐ'ð	ØŸ™‘>ˆDð
 ×'×'Ø×%Ñ%¤c¨%×*FÑ*FÓ&GÔHØ×Ñ˜Ôð (,Ô$Ø!(ÔØ"'Õùò! BùÚ'øô ó 	ØŠDð	ús$   Â7EÃ
EÃ$EÃ-E ÅE-Å,E-c                ó$   • U R                  USS9  g)zX
Like `yank_nth_arg`, but if no argument has been given, yank the last
word by default.
T)ru   r“  N)rš  )rG   ru   s     r9   Úyank_last_argÚBuffer.yank_last_argW  s   € ð
 	×Ñ˜A¨dÐÒ3r8   c                ó:   • [        U R                  U5      U l        g)zB
Take the current cursor position as the start of this selection.
N)r"   rY   r«   )rG   Úselection_types     r9   Ústart_selectionÚBuffer.start_selection^  s   € ô  .¨d×.BÑ.BÀNÓSˆÕr8   c                óf   • U R                   R                  5       u  p#U(       a  X l         SU l        U$ )a   
Copy selected text and return :class:`.ClipboardData` instance.

Notice that this doesn't store the copied data on the clipboard yet.
You can store it like this:

.. code:: python

    data = buffer.copy_selection()
    get_app().clipboard.set_data(data)
N)r�   Úcut_selectionr«   )rG   Ú_cutÚnew_documentÚclipboard_datas       r9   Úcopy_selectionÚBuffer.copy_selectionf  s/   € ð (,§}¡}×'BÑ'BÓ'DÑ$ˆÞØ(ŒMà#ˆÔØÐr8   c                ó    • U R                  SS9$ )zC
Delete selected text and return :class:`.ClipboardData` instance.
T)r¥  )r¨  rO   s    r9   r¤  ÚBuffer.cut_selectiony  s   € ð ×"Ñ"¨Ð"Ð-Ð-r8   c                óþ   • [        U[        5      (       d   eU[        R                  [        R                  [        R
                  4;   d   eU R                  nU R                  R                  XUS9U l        X@l        g)z%
Insert the data from the clipboard.
)Ú
paste_moder  N)	rå   r   r!   Ú	VI_BEFOREÚVI_AFTERÚEMACSr�   Úpaste_clipboard_datar°   )rG   Údatar­  r  rD   s        r9   r±  ÚBuffer.paste_clipboard_data  sn   € ô ˜$¤×.Ñ.Ð.Ð.Øœi×1Ñ1´9×3EÑ3EÄyÇÁÐWÓWÐWÐWà ŸM™MÐØŸ™×:Ñ:Ø¨uð ;ð 
ˆŒð &7Õ"r8   c                ó†   • U(       a)  U R                  SU R                  R                  -   5        gU R                  S5        g)z/
Insert a line ending at the current position.
r  N)r  r�   Ú"leading_whitespace_in_current_line)rG   Úcopy_margins     r9   ÚnewlineÚBuffer.newline”  s2   € ö Ø×Ñ˜T D§M¡M×$TÑ$TÑTÕUà×Ñ˜TÕ"r8   c                óð   • U(       a  U R                   R                  S-   nOSnU =R                  U R                   R                  5       -  sl        U R	                  U5        U =R                  S-  sl        g)z*
Insert a new line above the current one.
r  r   N)r�   rµ  rY   r  r  ©rG   r¶  Úinserts      r9   Úinsert_line_aboveÚBuffer.insert_line_above�  s]   € ö Ø—]‘]×EÑEÈÑL‰FàˆFà×Ò §¡× HÑ HÓ JÑJÕØ×Ñ˜Ô Ø×Ò Ñ!Ör8   c                óÆ   • U(       a  SU R                   R                  -   nOSnU =R                  U R                   R                  5       -  sl        U R	                  U5        g)z*
Insert a new line below the current one.
r  N)r�   rµ  rY   r  r  rº  s      r9   Úinsert_line_belowÚBuffer.insert_line_belowª  sL   € ö Ø˜DŸM™M×LÑLÑL‰FàˆFà×Ò §¡× FÑ FÓ HÑHÕØ×Ñ˜Õ r8   c                ó¬  • U R                   nU R                  nU(       aD  XVU[        U5      -    nSU;   a  USUR                  S5       nUSU U-   XV[        U5      -   S -   nOUSU U-   XVS -   nU(       a  U R                  [        U5      -   n	OU R                  n	[	        X‰5      U l        U(       a¡  U R                  R                  5         U R                  (       a<  U R                  5       (       a'  [        5       R                  U R                  5       5        U R                  (       a(  [        5       R                  U R                  5       5        ggg)z˜
Insert characters at cursor position.

:param fire_event: Fire `on_text_insert` event. This is mainly used to
    trigger autocompletion while typing.
r  N)rX   rY   rN   Úfindr   r�   r“   rì   r‚   r‰   r   rÌ   r›   rƒ   r™   )
rG   r²  Ú	overwriteÚmove_cursorÚ
fire_eventÚotextÚocposÚoverwritten_textrX   Úcposs
             r9   r  ÚBuffer.insert_text¶  s:  € ð —	‘	ˆØ×$Ñ$ˆö ð  %¨U´S¸³YÑ->Ð?ÐØÐ'Ó'Ø#3Ð4QÐ6F×6KÑ6KÈDÓ6QÐ#RÐ à˜˜%�= 4Ñ'¨%¼Ð<LÓ8MÑ0MÐ0OÐ*PÑP‰Dà˜˜%�= 4Ñ'¨%°¨-Ñ7ˆDæØ×'Ñ'¬#¨d«)Ñ3‰Dà×'Ñ'ˆDô ! Ó,ˆŒö Ø×Ñ×$Ñ$Ô&ð �~�~ $×"<Ñ"<×">Ñ">Ü“	×0Ñ0°×1FÑ1FÓ1HÔIð × × Ü“	×0Ñ0°×1FÑ1FÓ1HÕIð !ð r8   c                ó$  • U R                   (       a  U R                   R                  5       u  pXR                  :w  a@  U R                  R	                  U R                  U R
                  45        [        XS9U l        g U R                   (       a  M~  g g )N©rY   )r³   ÚpoprX   r´   rþ   rY   r   r�   ©rG   rX   rW  s      r9   ÚundoÚBuffer.undoê  so   € ð
 ××Ø×(Ñ(×,Ñ,Ó.‰IˆDà—y‘yÓ à× Ñ ×'Ñ'¨¯©°D×4HÑ4HÐ(IÔJô !)¨Ñ C�”Øð ××Ór8   c                óš   • U R                   (       a:  U R                  SS9  U R                   R                  5       u  p[        XS9U l        g g )NF)rÿ   rÌ  )r´   r   rÍ  r   r�   rÎ  s      r9   ÚredoÚBuffer.redoú  sE   € Ø××à×#Ñ#°UÐ#Ñ;ð ×(Ñ(×,Ñ,Ó.‰IˆDÜ$ TÑ?ˆD�Mð r8   c                ó  • U R                   [        R                  :w  a  U R                   [        R                  :H  $ U R                  (       a&   U R                  R                  U R                  5        [        R                  U l         SU l        g! [         ad  nU(       a8  [        [        SUR                  5      [        U R                  5      5      U l
        [        R                  U l         X l         SnAgSnAff = f)z^
Returns `True` if valid.

:param set_cursor: Set the cursor position, if an error was found.
r   NFT)rª   r;   r?   r=   r„   Úvalidater�   r&   r^  rØ   rY   rN   rX   r>   r©   )rG   Ú
set_cursorÚes      r9   rÕ  ÚBuffer.validate  sÃ   € ð × Ñ ¤O×$;Ñ$;Ó;Ø×(Ñ(¬O×,AÑ,AÑAÐAð �>�>ðØ—‘×'Ñ'¨¯©Ô6ô !0× 5Ñ 5ˆÔØ $ˆÔØøô #ó 	æÜ+.Ü˜A˜q×0Ñ0Ó1´3°t·y±y³>ó,�DÔ(ô )8×(?Ñ(?�Ô%Ø()Ô%Üûð	ús   Á%B Â
C>ÂAC9Ã9C>c              ƒ  óâ  #   •  U R                   [        R                  :w  a  gSnU R                  nU R                  (       a@   U R                  R                  U R                  5      I Sh  v•N   U R                  U:w  a  M  U(       a  [        R                  U l         O[        R                  U l         Xl	        [        5       R                  5         MÐ   Nh! [         a  nUn SnANwSnAff = f7f)a§  
Asynchronous version of `validate()`.
This one doesn't set the cursor position.

We have both variants, because a synchronous version is required.
Handling the ENTER key needs to be completely synchronous, otherwise
stuff like type-ahead is going to give very weird results. (People
could type input while the ENTER key is still processed.)

An asynchronous version is required if we have `validate_while_typing`
enabled.
N)rª   r;   r?   r�   r„   Úvalidate_asyncr&   r>   r=   r©   r   Ú
invalidate)rG   Úerrorr�   r×  s       r9   Ú_validate_asyncÚBuffer._validate_async"  sÀ   é € ð ð ×$Ñ$¬×(?Ñ(?Ó?Øð ˆEØ—}‘}ˆHà�~�~ðØŸ.™.×7Ñ7¸¿¹ÓF×FÐFð
 —=‘= HÓ,Ùö Ü(7×(?Ñ(?�Õ%ä(7×(=Ñ(=�Ô%à$)Ô!Ü‹I× Ñ Ô"ñ7 ñ GøÜ&ó Ø•EûðüsC   ‚A C/Á(C Á+CÁ,C Á0A$C/ÃC Ã
C,Ã C'Ã"C/Ã'C,Ã,C/c                óî   • U R                   (       ad  U R                  R                  5       n[        U5      (       a  US   U R                   :w  a&  U R                  R	                  U R                   5        ggg)z*
Append the current input to the history.
ry   N)rX   r�   r‘  rN   Úappend_string)rG   r”  s     r9   r¨   ÚBuffer.append_to_historyL  sY   € ð �9�9Ø"Ÿl™l×6Ñ6Ó8ˆOÜ�×'Ñ'¨?¸2Ñ+>À$Ç)Á)Ó+KØ—‘×*Ñ*¨4¯9©9Õ5ð ,Lð r8   c                ó   ^ ^^	^
^• US:”  d   eUR                   mUR                  m	UR                  5       m
      SU	U
UU U4S jjnT R                  nT R                  n[        U5       H  nU" XV5      nUc    gUu  pVM     XVR                  4$ )z‹
Execute search. Return (working_index, cursor_position) tuple when this
search is applied. Returns `None` when this text cannot be found.
r   c                ól  >• T[         R                  :X  aÆ  UR                  TTTS9nUb%  U [        UR                  UR
                  U-   5      4$ [        U S-   [        TR                  5      S-   5       Hb  nU[        TR                  5      -  n[        TR                  U   S5      nUR                  TSTS9nUc  MJ  U[        UR                  U5      4s  $     gUR                  TTS9nUb%  U [        UR                  UR
                  U-   5      4$ [        U S-
  SS5       H�  nU[        TR                  5      -  n[        TR                  U   [        TR                  U   5      5      nUR                  TTS9nUc  M_  U[        UR                  [        UR                  5      U-   5      4s  $    g)	z@
Do search one time.
Return (working_index, document) or `None`
)Úinclude_current_positionÚignore_caseNr   r   T)rå  éþÿÿÿry   )
r   ÚFORWARDrÂ  r   rX   rY   rŠ  rN   r¶   Úfind_backwards)	rÑ   r�   Ú	new_indexrv  Ú	directionrå  rä  rG   rX   s	       €€€€€r9   Úsearch_onceÚ#Buffer._search.<locals>.search_onceg  sß  ø€ ð œO×3Ñ3Ó3à$ŸM™MØØ-EØ +ð *ð �	ð Ñ(à%Ü  §¡°×0HÑ0HÈ9Ñ0TÓUðð ô # =°1Ñ#4´c¸$×:MÑ:MÓ6NÐQRÑ6RÖS˜ØœS ×!4Ñ!4Ó5Ñ5˜ä#+¨D×,?Ñ,?ÀÑ,BÀAÓ#F˜Ø$,§M¡MØ ¸4È[ð %2ð %˜	ð %Ó0Ø$%¤x°·±¸yÓ'IÐ#JÒJò TðD ð/ %×3Ñ3°DÀkÐ3ÐR�	àÑ(à%Ü  §¡°×0HÑ0HÈ9Ñ0TÓUðð ô # =°1Ñ#4°b¸"Ö=˜ØœS ×!4Ñ!4Ó5Ñ5˜ä#+Ø ×/Ñ/°Ñ2´C¸×8KÑ8KÈAÑ8NÓ4Oó$˜ð %-×$;Ñ$;Ø ¨kð %<ð %˜	ð %Ó0à !Ü (¨¯©¼¸H¿M¹MÓ8JÈYÑ8VÓ Wð$ò ñ >ð r8   N)rÑ   r{   r�   r   ri   ztuple[int, Document] | None)rX   rê  rå  rÑ   r�   rŠ  rY   )rG   Úsearch_staterä  r  rë  rÑ   r�   Ú_rÁ   rê  rå  rX   s   ` `      @@@r9   Ú_searchÚBuffer._searchW  s©   ü€ ð �q‹yÐˆyà× Ñ ˆØ ×*Ñ*ˆ	Ø"×.Ñ.Ó0ˆð:	Øð:	Ø*2ð:	à(÷:	ó :	ðz ×*Ñ*ˆØ—=‘=ˆÜ�u–ˆAÙ  Ó9ˆFØ‰~Ùà*0Ñ'�™xñ ð ×7Ñ7Ð8Ð8r8   c                ó²   • U R                  USS9nUc  U R                  $ Uu  p4X0R                  :X  a  U R                  nOSn[	        U R
                  U   XES9$ )zó
Return a :class:`~prompt_toolkit.document.Document` instance that has
the text/cursor position for this search, if we would apply it. This
will be used in the
:class:`~prompt_toolkit.layout.BufferControl` to display feedback while
searching.
T)rä  N)Ú	selection)rï  r�   rÑ   r«   r   r¶   )rG   rí  Úsearch_resultrÑ   rY   rò  s         r9   Údocument_for_searchÚBuffer.document_for_search¯  si   € ð Ÿ™ \ÈD˜ÐQˆàÑ Ø—=‘=Ð à-:Ñ*ˆMð × 2Ñ 2Ó2Ø ×0Ñ0‘	à �	äØ×#Ñ# MÑ2°Oñð r8   c                óL   • U R                  XUS9nUc  U R                  $ Uu  pVU$ )z«
Get the cursor position for this search.
(This operation won't change the `working_index`. It's won't go through
the history. Vi text objects can't span multiple items.)
©rä  r  )rï  rY   ©rG   rí  rä  r  ró  rÑ   rY   s          r9   Úget_search_positionÚBuffer.get_search_positionÈ  s?   € ð Ÿ™ØÐSXð %ð 
ˆð Ñ Ø×'Ñ'Ð'à-:Ñ*ˆMØ"Ð"r8   c                óL   • U R                  XUS9nUb  Uu  pVXPl        X`l        gg)zQ
Apply search. If something is found, set `working_index` and
`cursor_position`.
r÷  N)rï  rÑ   rY   rø  s          r9   Úapply_searchÚBuffer.apply_searchÝ  s>   € ð Ÿ™ØÐSXð %ð 
ˆð Ñ$Ø-:Ñ*ˆMØ!.ÔØ#2Õ ð %r8   c                ó   • S U l         g rC   )r«   rO   s    r9   Úexit_selectionÚBuffer.exit_selectionð  s
   € Ø#ˆÕr8   c                ó  ^• [        U R                  5      n[        R                  " U5      u  nm[        R
                  " X R                  R                  S5      5        [        R                  " U5        SU4S jjnTU4$ )zI
Simple (file) tempfile implementation.
Return (tempfile, cleanup_func).
úutf-8c                 ó2   >• [         R                  " T 5        g rC   )ÚosÚunlink)Úfilenames   €r9   ÚcleanupÚ/Buffer._editor_simple_tempfile.<locals>.cleanupþ  s   ø€ Ü�IŠI�hÕr8   rË   )	r%   r…   r†   Úmkstempr  ÚwriterX   ÚencodeÚclose)rG   ÚsuffixÚ
descriptorr  r  s       @r9   Ú_editor_simple_tempfileÚBuffer._editor_simple_tempfileó  sc   ø€ ô
 ˜×,Ñ,Ó-ˆÜ'×/Ò/°Ó7Ñˆ
�Hä
�Š�ŸY™Y×-Ñ-¨gÓ6Ô7Ü
�Š�Ô÷	 ð ˜Ð Ð r8   c                ó€  ^• [        U R                  5      nU(       d  U R                  5       $ [        U5      n[        R
                  R                  U5      u  p#[        R
                  R                  U5      (       a  USS  n[        R                  " 5       mU(       a   [        R
                  R                  TU5      m[        R                  " T5        [        R
                  R                  TU5      n[        USSS9 nUR                  U R                  5        S S S 5        SU4S jjnXF4$ ! , (       d  f       N= f)Nr   r—  r  )Úencodingc                 ó2   >• [         R                  " T 5        g rC   )ÚshutilÚrmtree)Údirpaths   €r9   r  Ú0Buffer._editor_complex_tempfile.<locals>.cleanup  s   ø€ Ü�MŠM˜'Õ"r8   rË   )r%   r†   r  rl   r  Úpathr  ÚisabsÚmkdtempr  ÚmakedirsÚopenr
  rX   )rG   ÚheadtailÚheadÚtailr  Úfhr  r  s          @r9   Ú_editor_complex_tempfileÚBuffer._editor_complex_tempfile  sã   ø€ ä˜$Ÿ-™-Ó(ˆÞà×/Ñ/Ó1Ð1Ü�x“=ˆô —W‘W—]‘] 8Ó,‰
ˆÜ�7‰7�=‰=˜×ÑØ˜˜�8ˆDä×"Ò"Ó$ˆÞÜ—g‘g—l‘l 7¨DÓ1ˆGä
�Š�GÔô —7‘7—<‘< ¨Ó.ˆÜ�(˜C¨'Ò2°bØ�H‰H�T—Y‘YÔ÷ 3÷	#ð Ð Ð ÷ 3Õ2ús   Ä D/Ä/
D=c                ó
  ^ ^^^• T R                  5       (       a
  [        5       eT R                  (       a  T R                  5       u  mmOT R	                  5       u  mmSUUU U4S jjn[        5       R                  U" 5       5      $ )zM
Open code in editor.

This returns a future, and runs in a thread executor.
c               “  ó”  >#   •  [        UU4S jSS9I S h  v•N n U (       a~  [        TS5       nUR                  5       R                  S5      nUR	                  S5      (       a  US S n[        U[        U5      S9Tl        S S S 5        T(       a  TR                  5         T" 5         g  N‘! , (       d  f       N/= f! T" 5         f = f7f)	Nc                 ó&   >• TR                  T 5      $ rC   )Ú_open_file_in_editor)r  rG   s   €€r9   Ú<lambda>Ú4Buffer.open_in_editor.<locals>.run.<locals>.<lambda>6  s   ø€ ˜D×5Ñ5°hÔ?r8   T)Úin_executorÚrbr  r  ry   rM  )	r   r  ÚreadÚdecodeÚendswithr   rN   r�   Úvalidate_and_handle)ÚsuccessrÈ   rX   Úcleanup_funcr  rG   r.  s      €€€€r9   ÚrunÚ"Buffer.open_in_editor.<locals>.run/  s§   øé € ðô
 !0Ý?ÈTñ!÷ �ö
 Ü˜h¨Ô-°Ø Ÿv™v›xŸ™¨wÓ7˜ð  Ÿ=™=¨×.Ñ.Ø#'¨¨ 9˜Dä(0°dÌCÐPTËIÑ(V˜œ÷ .ö +Ø×0Ñ0Ô2ñ •ñ-÷ .Õ-ûñ  •üsD   ƒC…B< —B)˜B< ¯AB+ÂB< Â!CÂ)B< Â+
B9Â5B< Â<	CÃCrË   )rŒ   r(   r†   r!  r  r   rÌ   )rG   r.  r1  r0  r  s   `` @@r9   Úopen_in_editorÚBuffer.open_in_editor   sk   û€ ð �>‰>×ÑÜ$Ó&Ð&ð �=�=Ø%)×%BÑ%BÓ%DÑ"ˆH‘là%)×%AÑ%AÓ%CÑ"ˆH�l÷	ò 	ô< ‹y×/Ñ/±³Ó6Ð6r8   c                ó@  • [         R                  R                  S5      n[         R                  R                  S5      nUUSSSSS/nU H@  nU(       d  M   [        R                  " [
        R                  " U5      U/-   5      nUS:H  s  $    g	! [         a     MR  f = f)
zK
Call editor executable.

Return True when we received a zero return code.
ÚVISUALÚEDITORz/usr/bin/editorz/usr/bin/nanoz/usr/bin/picoz/usr/bin/viz/usr/bin/emacsr   F)r  ÚenvironÚgetÚ
subprocessÚcallÚshlexr  ÚOSError)rG   r  ÚvisualÚeditorÚeditorsr×  Ú
returncodes          r9   r&  ÚBuffer._open_file_in_editorO  sž   € ô —‘—‘ Ó)ˆÜ—‘—‘ Ó)ˆð ØàØØØØð	
ˆó ˆAßˆqðô ",§¢´·²¸Q³À8À*Ñ1LÓ!M�JØ%¨™?Ò*ñ ð øô	 ó âðús   Á2BÂ
BÂBc                ó�   • X-   U-   S::  d   e[        5       R                  U R                  UUUU=(       d	    [        SS9S95        g)zz
Start asynchronous autocompletion of this buffer.
(This will do nothing if a previous completion was still in progress.)
r   T)Úcompletion_requested)Úselect_firstÚselect_lastÚinsert_common_partÚcomplete_eventN)r   rÌ   r›   r   )rG   rE  rF  rG  rH  s        r9   Ústart_completionÚBuffer.start_completions  sW   € ð Ñ)Ð,>Ñ>À!ÓCÐCÐCä‹	×(Ñ(Ø×!Ñ!Ø)Ø'Ø#5Ø-÷  <Ü °dÑ;ð "ð õ	
r8   c                óV   ^ ^• SS jm[             S         SUU 4S jjj5       nU$ )z©
Create function for asynchronous autocompletion.

(This consumes the asynchronous completer generator, which possibly
runs the completion algorithm in another thread.)
c                ól   • U R                   nU[        U5      UR                  -   S nX1R                  :H  $ )zj
Return `True` if applying this completion doesn't have any effect.
(When it doesn't insert any new text.
N)rZ   rN   r\   rX   )r�   r€  rZ   Úreplaced_texts       r9   Úcompletion_does_nothingÚCBuffer._create_completer_coroutine.<locals>.completion_does_nothing“  s@   € ð
 "*×!<Ñ!<ÐØ.ÜÐ&Ó'¨*×*CÑ*CÑCÐEðˆMð !§O¡OÑ3Ð3r8   c              “  óB  >^^#   • TR                   nU=(       d	    [        SS9nTR                  (       d  TR                  (       d  g [	        TR                   S9mTTl        S	UU4S jjn[
        R                  " 5       mS
UU4S jjn[
        R                  " U" 5       5      n [        TR                  R                  XC5      5       IS h  v•N nU  S h  v•N n	TR                  R                  U	5        TR                  5         U" 5       (       d    O&[        TR                  5      TR                  :¼  d  Mg    S S S 5      IS h  v•N   UR                  5         TR                   R#                  5         TR                  n
[        U
5      S:X  a  T" XJS   5      (       a  U
S S 2	 U" 5       (       Ga2  TR                  (       a  TR                  R$                  b  g U
(       d"  S Tl        TR                   R#                  5         g U (       a  TR'                  S5        g U(       a  TR'                  [        U
5      S-
  5        g U(       aš  [)        XJ5      nU(       af  TR+                  U5        [        U
5      S:”  a>  U
 Vs/ s H  nUR-                  [        U5      5      PM     snU
S S & TR/                  U
S9  g S Tl        g [        U
5      S:X  a  TR'                  S5        g g g TR                   R0                  UR0                  :X  a  g TR                   R0                  R3                  UR0                  5      (       a  [4        eg  GNx GNp
 GN GN! , IS h  v•N  (       d  f       GN= f! UR                  5         TR                   R#                  5         f = fs  snf 7f)NT)Útext_inserted)rD   c                 ó"   >• TR                   T :H  $ )zYKeep retrieving completions. Input text has not yet changed
while generating completions.)r®   )r®   rG   s   €€r9   ÚproceedÚLBuffer._create_completer_coroutine.<locals>.async_completer.<locals>.proceed°  s   ø€ ð ×*Ñ*¨nÑ<Ð<r8   c               “  óÚ   >#   •  TR                   R                  5         T R                  5         [        R                  " S5      I Sh  v•N   T R                  5       I Sh  v•N   Mb   N N7f)ae  Background loop to refresh the UI at most 3 times a second
while the completion are loading. Calling
`on_completions_changed.fire()` for every completion that we
receive is too expensive when there are many completions. (We
could tune `Application.max_render_postpone_time` and
`Application.min_redraw_interval`, but having this here is a
better approach.)
g333333Ó?N)r•   rì   ÚclearrÂ   ÚsleepÚwait)Úrefresh_neededrG   s   €€r9   Úrefresh_while_loadingÚZBuffer._create_completer_coroutine.<locals>.async_completer.<locals>.refresh_while_loading·  sZ   øé € ð Ø×/Ñ/×4Ñ4Ô6Ø"×(Ñ(Ô*Ü!Ÿ-š-¨Ó,×,Ð,Ø(×-Ñ-Ó/×/Ð/ñ	 ñ -Ù/ùs$   ƒAA+ÁA'Á	A+Á A)Á!A+Á)A+r   r   rm  ©ri   rú   rË   )r�   r   r®   r‚   r*   rÂ   r$   Úensure_futurer   Úget_completions_asyncrE   rþ   rn  rN   rŽ   rµ   r•   rì   rF   r_  r   r  Únew_completion_from_positionri  rZ   rr  Ú_Retry)rE  rF  rG  rH  r�   rS  rZ  Úrefresh_taskÚasync_generatorr€  rE   Úcommon_partr_   r®   rY  rN  rG   s                @@€€r9   Úasync_completerÚ;Buffer._create_completer_coroutine.<locals>.async_completerž  s  úé € ð —}‘}ˆHØ+×P¬}È4Ñ/PˆNð ×"×"¨$¯.¯.Øô -¸t¿}¹}ÑMˆNØ"0ˆDÔ÷=ð =ô
 %Ÿ]š]›_ˆN÷0ð 0ô #×0Ò0Ñ1FÓ1HÓIˆLð3ä#Ø—N‘N×8Ñ8¸ÓR÷ô à$Ù,;÷ "˜jØ&×2Ñ2×9Ñ9¸*ÔEØ&×*Ñ*Ô,ñ  'Ÿy™yÙ!ô   × :Ñ :Ó;Ø#×=Ñ=õ>ð "÷!÷ ð$ ×#Ñ#Ô%ð ×+Ñ+×0Ñ0Ô2à(×4Ñ4ˆKô �;Ó 1Ó$Ñ)@Ø a™.÷*ñ *ð  ¢�Nñ �yŠyð ×+×+Ø×*Ñ*×9Ñ9ÑEàö #Ø*.�DÔ'ð ×/Ñ/×4Ñ4Ô6Øö  Ø×)Ñ)¨!Õ,æ Ø×)Ñ)¬#¨kÓ*:¸QÑ*>Õ?æ'Ü"<¸XÓ"S�KÞ"à×(Ñ(¨Ô5Ü˜{Ó+¨aÓ/ñ *5ó.â)4 Að !"× >Ñ >¼sÀ;Ó?OÖ PÙ)4ñ.˜K©˜Nð
 !×1Ñ1¸kÐ1ÒJà26˜DÕ/ô ˜{Ó+¨qÓ0Ø ×1Ñ1°!Õ4ð 1ð1 (ð> —=‘=×3Ñ3°x×7RÑ7RÓRØà—=‘=×3Ñ3×>Ñ>Ø×/Ñ/÷ñ ô !�Lðò{ò"ªO÷÷ ÷ ò ûð$ ×#Ñ#Ô%ð ×+Ñ+×0Ñ0Õ2üò^.ùsŸ   …BNÂ$(M+ ÃMÃM+ ÃMÃM
ÃMÃM
ÃAMÄ:MÄ;M+ ÅMÅM+ ÅD4NÉ?$NÊ#B!NÍM+ ÍM
Í
MÍM+ ÍM(ÍMÍM(Í#M+ Í+,NÎN)r�   r   r€  r   ri   rú   ©FFFN©
rE  rú   rF  rú   rG  rú   rH  zCompleteEvent | Noneri   rj   ©Ú_only_one_at_a_time)rG   rd  rN  s   ` @r9   rš   Ú"Buffer._create_completer_coroutine‹  sl   ù€ ô		4ô 
à!&Ø %Ø',Ø37ð	J	!ØðJ	!àðJ	!ð !%ðJ	!ð 1ð	J	!ð
 ÷J	!ð J	!ó 
ðJ	!ðX Ðr8   c                ó*   ^ • [         SU 4S jj5       nU$ )zT
Create function for asynchronous auto suggestion.
(This can be in another thread.)
c               “  ó&  >#   • TR                   n TR                  (       d  TR                  (       d  g TR                  R                  TU 5      I S h  v•N nTR                   U :X  a"  UTl        TR                  R                  5         g [        e N<7frC   )r�   r±   rƒ   Úget_suggestion_asyncr–   rì   r`  )r�   r±   rG   s     €r9   Úasync_suggestorÚ>Buffer._create_auto_suggest_coroutine.<locals>.async_suggestor3  sr   øé € à—}‘}ˆHð �� d×&7×&7Øà#×0Ñ0×EÑEÀdÈHÓU×UˆJð �}‰} Ó(à",�”Ø×&Ñ&×+Ñ+Õ-ô �ñ Vùs   ƒABÁBÁ=BrË   rh  )rG   rn  s   ` r9   r˜   Ú%Buffer._create_auto_suggest_coroutine-  s   ø€ ô 
ö	ó 
ð	ð$ Ðr8   c                ó*   ^ • [         SU 4S jj5       nU$ )z^
Create a function for asynchronous validation while typing.
(This can be in another thread.)
c               “  óB   >#   • T R                  5       I S h  v•N   g  N7frC   )rÝ  rO   s   €r9   Úasync_validatorÚ?Buffer._create_auto_validate_coroutine.<locals>.async_validatorP  s   øé € à×&Ñ&Ó(×(Ó(ùs   ƒ—˜rË   rh  )rG   rs  s   ` r9   rœ   Ú&Buffer._create_auto_validate_coroutineH  s   ø€ ô 
ö	)ó 
ð	)ð Ðr8   c                óÌ   • U R                  SS9nU(       aN  U R                  (       a  U R                  U 5      nOSnU R                  5         U(       d  U R                  5         ggg)z/
Validate buffer and handle the accept action.
T)rÖ  FN)rÕ  rˆ   r¨   rŸ   )rG   ÚvalidÚ	keep_texts      r9   r.  ÚBuffer.validate_and_handleV  sY   € ð —‘¨�Ð.ˆö Ø×"×"Ø ×/Ñ/°Ó5‘	à!�	à×"Ñ"Ô$æØ—
‘
•ð ð r8   ),Ú__cursor_positionÚ__working_indexr›   r™   r�   r—   rž   r´   r³   r¶   rˆ   rƒ   r®   r‰   r‚   rY   r�   r°   r‹   r�   r²   rŽ   r�   r¬   r‡   r•   r”   r–   r’   r“   r­   rŒ   r«   r±   r†   r…   rX   r�   rŠ   r©   rª   r„   rÑ   r¯   )NNNNrz   rz   rz   FFFNNFTi'  NNNNN)*r‚   zCompleter | Nonerƒ   zAutoSuggest | Noner�   zHistory | Noner„   zValidator | Noner…   ústr | Callable[[], str]r†   r|  r‡   rl   r‰   r   rŠ   r   r‹   r   r�   úDocument | Nonerˆ   zBufferAcceptHandler | NonerŒ   r   r�   r   rŽ   r{   r’   úBufferEventHandler | Noner“   r~  r”   r~  r•   r~  r–   r~  ri   rj   rk   )NF)r�   r}  r¨   rú   ri   rj   rË   )rÒ   rl   ri   rú   )rÒ   r{   ri   rú   )rÒ   rl   ri   rj   )ri   r{   )rÒ   r{   ri   rj   )ri   r   )rÒ   r   ri   rj   )F)rÒ   r   rõ   rú   ri   rj   r\  )T)rÿ   rú   ri   rj   )r  zIterable[int]r  úCallable[[str], str]ri   rl   )r  r  ri   rj   )r  r{   r  r{   r  r  ri   rj   ©r   )r  r{   ri   rj   )r   F)r  r{   r5  rú   ri   rj   )r  r{   ri   rl   )rF  )rI  rl   ri   rj   )rT   r{   ri   rj   )r  r{   r`  rú   ri   rj   )rE   zlist[Completion]ri   r*   rm   )r€  r   ri   rj   )rv  r{   ri   rú   )ru   rh   r“  rú   ri   rj   rC   )ru   rh   ri   rj   )r   r#   ri   rj   )r¥  rú   ri   r   )ri   r   )r²  r   r­  r!   r  r{   ri   rj   )r¶  rú   ri   rj   )FTT)
r²  rl   rÃ  rú   rÄ  rú   rÅ  rú   ri   rj   )rÖ  rú   ri   rú   )Fr   )rí  r    rä  rú   r  r{   ri   ztuple[int, int] | None)rí  r    ri   r   )Tr   )rí  r    rä  rú   r  r{   ri   r{   )rí  r    rä  rú   r  r{   ri   rj   )ri   ztuple[str, Callable[[], None]])r.  rú   ri   zasyncio.Task[None])r  rl   ri   rú   rf  rg  )ri   z(Callable[..., Coroutine[Any, Any, None]])ri   z'Callable[[], Coroutine[Any, Any, None]])Rr2   r3   r4   r5   r6   rH   rP   rŸ   rÎ   rÕ   rÚ   rn   rX   ÚsetterrY   rÑ   rß   ræ   r�   ró   rû   r   r
  r  r  r  r"  r*  r.  r6  r<  r@  rC  rJ  rS  rX  r[  r9  r1  rf  ri  ry  r_  r�  r„  r‡  r;  r3  rš  r�  r#   Ú
CHARACTERSr¡  r¨  r¤  r!   r°  r±  r·  r¼  r¿  r  rÏ  rÒ  rÕ  rÝ  r¨   rï  rô  rù  rü  rÿ  r  r!  r3  r&  rI  rš   r˜   rœ   r.  r7   r0   r8   r9   r)   r)   ›   st  † ñ9ðz '+Ø+/Ø"&Ø&*Ø35Ø,.ØØ.3Ø.3Ø.3Ø$(Ø59Ø"'Ø"&Ø).Ø59Ø48Ø@DØ<@Ø7;ð+O&à#ðO&ð )ðO&ð  ð	O&ð
 $ðO&ð 1ðO&ð *ðO&ð ðO&ð  ,ðO&ð  ,ðO&ð  ,ðO&ð "ðO&ð 3ðO&ð  ðO&ð  ðO&ð  $'ð!O&ð" 3ð#O&ð$ 2ð%O&ð& %>ð'O&ð( !:ð)O&ð* 5ð+O&ð, 
õ-O&ôbNð KPð?!Ø'ð?!ØCGð?!à	õ?!ôB3Iônô(;ð ó7ó ð7ð 
‡[�[ó,ó ð,ð2 ó&ó ð&ð ×Ñó,ó ð,ð" ó$ó ð$ð ×Ñó!ó ð!ôFô(/ð$ ó
ó ð
ð ‡_�_ó!ó ð!ö!,ðF ó)ó ð)ö"ð  à*ð ð 1ð ð 
ô	 ô@
ð
Øð
Ø!ð
Ø7Kð
à	ô
ö*TöUö0ö0ð NSðSØðSØFJðSà	õSð& NSðSØðSØFJðSà	õSö$ö,öö 
ô0
Gô2ö)ð0 ;@ð)Øð)Ø37ð)à	õ)ô,'ô#ô"!ôH$ô"*ô	,ô
öMö02ö*1(öf4ð /<×.FÑ.FðTØ+ðTà	õTöô&.ð !*§¡Øð	7àð7ð ð7ð ð	7ð
 
õ7ö*#ö"ö
!ð  Ø Øð2Jàð2Jð ð2Jð ð	2Jð
 ð2Jð 
õ2Jôhô @öô>(#ôT	6ð */Øð	V9à!ðV9ð #'ðV9ð ð	V9ð
 
 õV9ôpð8 *.Øð	#à!ð#ð #'ð#ð ð	#ð
 
õ#ð0 *.Øð	3à!ð3ð #'ð3ð ð	3ð
 
õ3ô&$ô!ô !ö:-7ô^"ðL #Ø!Ø#(Ø/3ð
àð
ð ð
ð !ð	
ð
 -ð
ð 
õ
ô0`ôDð6à	0ô÷r8   Ú_T.)Úboundc                óX   ^ ^• Sm[        T 5      SU U4S jj5       n[        [        U5      $ )zñ
Decorator that only starts the coroutine only if the previous call has
finished. (Used to make sure that we have only one autocompleter, auto
suggestor and validator running at a time.)

When the coroutine raises `_Retry`, it is restarted.
Fc               Ÿ  ó‚   >#   • T(       a  g Sm   T" U 0 UD6I S h  v•N    Smg  N! [          a     M%  f = f! Smf = f7f)NTF)r`  )r  ÚkwÚ	coroutineÚrunnings     €€r9   Únew_coroutineÚ*_only_one_at_a_time.<locals>.new_coroutinev  s[   øé € ö
 Øàˆð		Øð Ù# QÐ-¨"Ñ-×-Ð-ð  à‰Gñ .øÜó Úðûð
 ‰Güs4   ƒ?�8 ‘' œ%�' ¢?¥' §
5±8 ´5µ8 ¸<¼?)r  r   r‡  r   ri   r   )r   r   rƒ  )rˆ  rŠ  r‰  s   ` @r9   ri  ri  l  s0   ù€ ð €Gä
ˆ9Ó÷ó ðô( ”�MÓ"Ð"r8   c                  ó   • \ rS rSrSrSrg)r`  iŽ  zRetry in `_only_one_at_a_time`.r0   Nr1   r0   r8   r9   r`  r`  Ž  s   † Ü%r8   r`  c                ó@  ^• U R                   R                  nU R                   R                  n[        X5      nSU-  mU R	                  UU4S j5      n[        U[        U5      R                  US5      5      U l         U =R                  U[        T5      -   -  sl        g)z+
Indent text of a :class:`.Buffer` object.
ú    c                ó   >• TU -   $ rC   r0   )rR  Úindent_contents    €r9   r'  Úindent.<locals>.<lambda>œ  s
   ø€ ¸NÈQÒ<Nr8   r   N©	r�   r2  r&  rŠ  r
  r   Útranslate_row_col_to_indexrY   rN   )	ÚbufferÚfrom_rowÚto_rowr  Úcurrent_rowÚcurrent_colÚ
line_rangera   r�  s	           @r9   r+   r+   ’  s‹   ø€ ð —/‘/×5Ñ5€KØ—/‘/×5Ñ5€KÜ�xÓ(€Jð ˜e‘^€NØ×%Ñ% jÔ2NÓO€HÜØ”(˜8Ó$×?Ñ?ÀÈQÓOó€F„Oð
 ×Ò˜k¬C°Ó,?Ñ?Ñ?Ör8   c                óF  ^	• U R                   R                  nU R                   R                  n[        X5      nSU-  m	SU	4S jjnU R	                  Xg5      n[        U[        U5      R                  US5      5      U l         U =R                  U[        T	5      -
  -  sl        g)z-
Unindent text of a :class:`.Buffer` object.
rŽ  c                óp   >• TnU R                  U5      (       a  U [        U5      S  $ U R                  5       $ rC   )rr  rN   rH  )rX   Úremover�  s     €r9   Ú	transformÚunindent.<locals>.transform¯  s4   ø€ ØˆØ�?‰?˜6×"Ñ"Øœ˜F›˜Ð&Ð&à—;‘;“=Ð r8   r   N)rX   rl   ri   rl   r’  )
r”  r•  r–  r  r—  r˜  r™  r�  ra   r�  s
            @r9   r,   r,   ¥  s�   ø€ ð —/‘/×5Ñ5€KØ—/‘/×5Ñ5€KÜ�xÓ(€Jà˜e‘^€N÷!ð ×%Ñ% jÓ<€HÜØ”(˜8Ó$×?Ñ?ÀÈQÓOó€F„Oð
 ×Ò˜k¬C°Ó,?Ñ?Ñ?Ör8   c           	     ó>  • U R                   R                  S5      nUSU nX2S-   S nX1US-    nU(       Gag  [        R                  " SUS   5      nU(       a  UR	                  5       OSnUS   SU R                  SS5      n	SR                  U5      R                  5       n
U R                  =(       d    S[        U	5      -
  nU	/nSnU
 Hy  nU(       aP  [        U5      U-   S-   U:”  a%  UR                  S5        UR                  U	5        SnOUR                  S	5        US-  nUR                  U5        U[        U5      -  nM{     US
   S:w  a  UR                  S5        [        SR                  XL-   U-   5      [        SR                  XL-   5      5      S9U l        gg)zY
Reformat text, taking the width into account.
`to_row` is included.
(Vi 'gq' operator.)
TNr   z^\s*r   r  rz   éP   rF  ry   rM  )rX   rP  ÚreÚsearchÚendÚreplacer  r  r�   rN   rþ   r   r�   )r”  r•  r–  r	  Úlines_beforeÚlines_afterÚlines_to_reformatÚmatchÚlengthr+   r˜  ÚwidthÚreshaped_textÚcurrent_widthr—  s                  r9   r-   r-   À  s˜  € ð �K‰K×"Ñ" 4Ó(€EØ˜˜(Ð#€LØ ™
˜Ð%€KØ¨°!©Ð4Ðçä—	’	˜'Ð#4°QÑ#7Ó8ˆÞ %�—‘”¨1ˆà" 1Ñ% g vÐ.×6Ñ6°t¸RÓ@ˆð —‘Ð)Ó*×0Ñ0Ó2ˆð ×"Ñ"×( b¬C°«KÑ7ˆØ˜ˆØˆÛˆAÞÜ�q“6˜MÑ)¨AÑ-°Ó5Ø!×(Ñ(¨Ô.Ø!×(Ñ(¨Ô0Ø$%‘Mà!×(Ñ(¨Ô-Ø! QÑ&�Mà× Ñ  Ô#ØœS ›VÑ#ŠMñ ð ˜Ñ Ó$Ø× Ñ  Ô&ô #Ø—‘˜Ñ5¸ÑCÓDÜ §¡¨Ñ(DÓ EÓFñ
ˆ�ð? r8   )rˆ  rƒ  ri   rƒ  r€  )
r”  r)   r•  r{   r–  r{   r  r{   ri   rj   )r”  r)   r•  r{   r–  r{   ri   rj   )Ur6   Ú
__future__r   rÂ   Úloggingr  r¡  r<  r  r:  r†   Úcollectionsr   Úenumr   Ú	functoolsr   Útypingr   r   r	   r
   r   r   Úapplication.currentr   Úapplication.run_in_terminalr   rƒ   r   r   Úcacher   Ú	clipboardr   r€  r   r   r   r   r   r�   r   Ú	eventloopr   Úfiltersr   r   r�   r   r   r¢  r   r    rò  r!   r"   r#   Úutilsr$   r%   Ú
validationr&   r'   Ú__all__Ú	getLoggerr2   rÆ   Ú	Exceptionr(   r;   r*   Úcompiler’  rp   ÚBufferEventHandlerrú   ÚBufferAcceptHandlerr)   rƒ  ri  r`  r+   r,   r-   r0   r8   r9   Ú<module>rÁ     s?  ðñõ
 #ã Û Û 	Û 	Û Û Û Û Ý Ý Ý ß D× Då (Ý 8ß 1Ý  Ý $÷õ õ Ý ß ,ß -ß 0ß ?Ñ ?ß  ß 2ò€ð 
×	Ò	˜8Ó	$€ô5˜ô 5ô�dô ÷?ñ ?ðD —:’:Ð6Ó7Ð ÷^ñ ^ð  ˜x˜j¨$Ð.Ñ/Ð Ø ˜z¨4Ð/Ñ0Ð ÷Kñ Kñ\6 ˆT˜ # y°°c¸4°Ñ'@Ð"@ÑAÑB€ô#ôD&ˆYô &ö@ö&@õ6-
r8   