ó
    OÎh÷  ã                  óö   • S r SSKJr  SSKrSSKrSSKJr  SSKJr  SSK	J
r
JrJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  \(       a  SSKJr  SSKJr  SS/r\rSS jrSS jr      SS jrSSS jjr g)z2
Key binding handlers for displaying completions.
é    )ÚannotationsN)ÚTYPE_CHECKING)Úin_terminal)ÚCompleteEventÚ
CompletionÚget_common_complete_suffix)ÚStyleAndTextTuples)ÚKeyBindings)ÚKeyPressEvent)ÚKeys)Ú
get_cwidth)ÚApplication©ÚPromptSessionÚgenerate_completionsÚ!display_completions_like_readlinec                ó~   • U R                   nUR                  (       a  UR                  5         gUR                  SS9  g)zo
Tab-completion: where the first tab completes the common suffix and the
second tab lists all the completions.
T)Úinsert_common_partN)Úcurrent_bufferÚcomplete_stateÚcomplete_nextÚstart_completion)ÚeventÚbs     Úk/home/mande/repo/quber/.venv/lib/python3.13/site-packages/prompt_toolkit/key_binding/bindings/completion.pyr   r   #   s5   € ð
 	×Ñ€Að 	××Ø	�‰Õà	×Ñ¨dÐÒ3ó    c                óÜ  • U R                   nUR                  c  g[        SS9n[        UR                  R	                  UR
                  U5      5      n[        UR
                  U5      n[        U5      S:X  a>  UR                  US   R                  * 5        UR                  US   R                  5        gU(       a  UR                  U5        gU(       a  [        U R                  U5        gg)av  
Key binding handler for readline-style tab completion.
This is meant to be as similar as possible to the way how readline displays
completions.

Generate the completions immediately (blocking) and display them above the
prompt in columns.

Usage::

    # Call this handler when 'Tab' has been pressed.
    key_bindings.add(Keys.ControlI)(display_completions_like_readline)
NT)Úcompletion_requestedé   r   )r   Ú	completerr   ÚlistÚget_completionsÚdocumentr   ÚlenÚdelete_before_cursorÚstart_positionÚinsert_textÚtextÚ"_display_completions_like_readlineÚapp)r   r   Úcomplete_eventÚcompletionsÚcommon_suffixs        r   r   r   1   s¼   € ð 	×Ñ€AØ‡{�{ÑØÜ"¸Ñ=€NÜ�q—{‘{×2Ñ2°1·:±:¸~ÓNÓO€Kô /¨q¯z©z¸;ÓG€Mô ˆ;Ó˜1ÓØ	×Ñ ¨A¡× =Ñ =Ð=Ô>Ø	�‰�k !‘n×)Ñ)Õ*æ	Ø	�‰�mÕ$æ	Ü*¨5¯9©9°kÕBð 
r   c                óÄ  ^ ^^^^^	^
^^• SSK Jm  SSKJm  T R                  R                  5       nUR                  nUR                  n[        U[        S T 5       5      S-   5      m
[        SUT
-  5      mTUS-
  -  m[        [        R                  " [        T5      [        T5      -  5      5      mSU UUUU
U4S jjm	S	U UUUU	U4S jjnT R                  U" 5       5      $ )
zÇ
Display the list of completions in columns above the prompt.
This will ask for a confirmation if there are too many completions to fit
on a single page and provide a paginator to walk through them.
r   )Úto_formatted_text)Úcreate_confirm_sessionc              3  óL   #   • U  H  n[        UR                  5      v •  M     g 7f)N)r   Údisplay_text)Ú.0Úcs     r   Ú	<genexpr>Ú5_display_completions_like_readline.<locals>.<genexpr>i   s   é € ÐHºK°qœ
 1§>¡>×2Ð2ºKùs   ‚"$r   c           	     ó�  >• TU T-  U S-   T-   n[        [        R                  " [        U5      [	        T5      -  5      5      n[        T5       Vs/ s H  nXU-  US-   U-   PM     nn/ n[        U5       Hž  n[        T5       H{  n XG   U   nSUR                  =(       d    S-   n	UR                  T" UR                  U	S95        T[        UR                  5      -
  n
UR                  UR                  SU
-  45        M}     UR                  S5        M      TR                  T" US5      5        g s  snf ! [         a     M¿  f = f)Nr   z+class:readline-like-completions.completion Ú )ÚstyleÚ )r8   Ú
zclass:readline-like-completions)ÚintÚmathÚceilr$   ÚfloatÚranger9   ÚextendÚdisplayr   r2   ÚappendÚ
IndexErrorÚ
print_text)ÚpageÚpage_completionsÚpage_row_countÚiÚpage_columnsÚresultÚrr4   Ú
completionr9   Úpaddingr*   Úcolumn_countr,   Úcompletions_per_pageÚmax_compl_widthr/   s              €€€€€€r   rB   Ú3_display_completions_like_readline.<locals>.displayp   s\  ø€ à&ØÐ'Ñ'¨4°!©8Ð7KÑ*Kð
Ðô œTŸYšY¤sÐ+;Ó'<¼uÀ\Ó?RÑ'RÓSÓTˆô ˜<Ô(ó
â(�ð  Ñ/°1°q±5¸NÑ2JÓKÙ(ð 	ð 
ð
 &(ˆä�~Ö&ˆAÜ˜<Ö(�ðØ!-¡°Ñ!3�JØIØ"×(Ñ(×.¨Bñ�Eð —M‘MÑ"3°J×4FÑ4FÈeÑ"TÔUð .´
¸:×;RÑ;RÓ0SÑS�GØ—M‘M :×#3Ñ#3°S¸7±]Ð"CÖDñ )ð �M‰M˜*Ö%ñ 'ð" 	�‰Ñ(¨Ð1RÓSÕTùò1
øô( "ó Úðús   ÁD2Â	A7D7Ä7
EÅEc               “  ó"  >#   • [        SS9 ISh  v•N   [        T5      T:”  a­  T" S[        T5       S35      R                  5       I Sh  v•N n U (       a`  [        T5       HP  nT" U5        UTS-
  :w  d  M  [	        S5      R                  5       I Sh  v•N nU(       a  M@    SSS5      ISh  v•N   g   O#TR
                  R                  5         OT" S5        SSS5      ISh  v•N   g NÙ N¡ NZ NB N! , ISh  v•N  (       d  f       g= f7f)	z
Coroutine.T)Úrender_cli_doneNzDisplay all z possibilities?r   ú--MORE--r   )r   r$   Úprompt_asyncr@   Ú_create_more_sessionÚoutputÚflush)	ÚconfirmrF   Ú	show_morer*   r,   rP   r0   rB   Ú
page_counts	      €€€€€€r   Ú	run_complÚ5_display_completions_like_readline.<locals>.run_compl’   sÚ   øé € ä¨t×4Ó4Ü�;ÓÐ"6Ó6á 6Ø"¤3 {Ó#3Ð"4°OÐDó!ç‘,“.÷!�ö ä % jÖ 1˜Ù œà :°¡>Õ1ä.BØ *ó/ç*™l›n÷)-˜I÷ $- 9Ø &÷' 5×4Ð4ò !2ð —J‘J×$Ñ$Õ&ñ ˜”
÷1 5×4Ò4ñ!ñ)-÷ 5×4×4Ò4üs’   ƒD‘C+’D•6C5ÁC-Á(C5Á8C5ÂC/Â	C5Â"C5Â#DÂ.C1Â/DÂ4&C5ÃDÃ%C3Ã&DÃ-C5Ã/C5Ã1DÃ3DÃ5DÃ;C>Ã<DÄD)rF   r<   ÚreturnÚNone)r_   r`   )Úprompt_toolkit.formatted_textr/   Úprompt_toolkit.shortcuts.promptr0   rX   Úget_sizeÚcolumnsÚrowsÚminÚmaxr<   r=   r>   r$   r?   Úcreate_background_task)r*   r,   Ú	term_sizeÚ
term_widthÚterm_heightr]   rO   rP   r0   rB   rQ   r\   r/   s   ``    @@@@@@@r   r)   r)   U   sÇ   ÿø€ õ @ÝFð —
‘
×#Ñ#Ó%€IØ×"Ñ"€JØ—.‘.€Kô
 Ø”CÑH¹KÓHÓHÈ1ÑLó€Oô �q˜*¨Ñ7Ó8€LØ'¨;¸©?Ñ;ÐÜ”T—Y’Yœs ;Ó/´%Ð8LÓ2MÑMÓNÓO€J÷Uô U÷Dô ð8 ×%Ñ%¡i£kÓ2Ð2r   c                óº  • SSK Jn  [        5       nUR                  S5      UR                  S5      UR                  S5      UR                  [        R
                  5      UR                  [        R                  5      UR                  [        R                  5      SS j5       5       5       5       5       5       nUR                  S5      UR                  S5      UR                  S	5      UR                  S
5      UR                  [        R                  5      SS j5       5       5       5       5       nUR                  [        R                  5      SS j5       nU" XSS9$ )z@
Create a `PromptSession` object for displaying the "--MORE--".
r   r   r:   ÚyÚYc                ó6   • U R                   R                  SS9  g )NT©rK   ©r*   Úexit©r   s    r   Ú_yesÚ"_create_more_session.<locals>._yes¹   s   € ð 	�	‰	�‰˜dˆÒ#r   ÚnÚNÚqÚQc                ó6   • U R                   R                  SS9  g )NFrp   rq   rs   s    r   Ú_noÚ!_create_more_session.<locals>._noÂ   s   € ð 	�	‰	�‰˜eˆÒ$r   c                ó   • g)zDisable inserting of text.N© rs   s    r   Ú_ignoreÚ%_create_more_session.<locals>._ignoreÊ   s   � r   T)Úkey_bindingsÚerase_when_done©r   ÚEr_   r`   )
Úprompt_toolkit.shortcutsr   r
   Úaddr   ÚControlJÚControlMÚControlIÚControlCÚAny)Úmessager   Úbindingsrt   r{   r   s         r   rW   rW   ±   s  € õ 7ä‹}€Hà‡\�\�#ÓØ‡\�\�#ÓØ‡\�\�#ÓØ‡\�\”$—-‘-Ó Ø‡\�\”$—-‘-Ó Ø‡\�\”$—-‘-Ó ó$ó !ó !ó !ó ó ó ð$ð ‡\�\�#ÓØ‡\�\�#ÓØ‡\�\�#ÓØ‡\�\�#ÓØ‡\�\”$—-‘-Ó ó%ó !ó ó ó ó ð
%ð ‡\�\”$—(‘(Óó%ó ð%ñ ˜ÈÑNÐNr   rƒ   )r*   zApplication[object]r,   zlist[Completion]r_   zasyncio.Task[None])rU   )rŒ   Ústrr_   zPromptSession[bool])!Ú__doc__Ú
__future__r   Úasyncior=   Útypingr   Ú*prompt_toolkit.application.run_in_terminalr   Úprompt_toolkit.completionr   r   r   ra   r	   Ú'prompt_toolkit.key_binding.key_bindingsr
   Ú(prompt_toolkit.key_binding.key_processorr   Úprompt_toolkit.keysr   Úprompt_toolkit.utilsr   Úprompt_toolkit.applicationr   r…   r   Ú__all__r„   r   r   r)   rW   r~   r   r   Ú<module>r›      s‰   ðñõ #ã Û Ý  å B÷ñ õ
 =Ý ?Ý BÝ $Ý +æÝ6Ý6ð Ø'ð€ð
 €ô4ô!CðHY3Ø	ðY3Ø+;ðY3àôY3÷xOr   