ó
    Ñ]j.  ã                   óœ  • S 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  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  SS jrS r\R4                  " S5      rSS jrS rSS S jjrSS\S\4S jjr S!S jr!S"S jr"S r#\RH                  S:X  a(  \RJ                  RM                  SS5      S:w  a  SSK'r'S r(gS r(g)#z»
Paging capabilities for IPython.core

Notes
-----

For now this uses IPython hooks, so it can't be in IPython.utils.  If we can get
rid of that dependency, we could move it there.
-----
é    N)ÚUnsupportedOperation)ÚPath)Úget_ipython)Údisplay)ÚTryNext)Úchop)Úsystem)Úget_terminal_size)Ú	py3compatc                 ó¢   • [        U [        5      (       a  U nO-U(       a"  SR                  U R                  5       US 5      n SU 0n[	        USS9  g)z1Just display, no paging. screen_lines is ignored.Ú
Nú
text/plainT)Úraw)Ú
isinstanceÚdictÚjoinÚ
splitlinesr   )ÚstrngÚstartÚscreen_linesÚdatas       ÚN/home/mande/repo/quber/.venv/lib/python3.13/site-packages/IPython/core/page.pyÚdisplay_pager   $   sI   € ä�%œ×ÑØ‰æØ—J‘J˜u×/Ñ/Ó1°%°&Ð9Ó:ˆEØ˜uÐ&ˆÜˆD�dÓó    c                 ó   ^ • U 4S j$ )zJWrap a pager func to strip the `self` arg

so it can be called as a hook.
c                 ó   >• T" U0 UD6$ ©N© )ÚselfÚargsÚkwargsÚ	page_funcs      €r   Ú<lambda>Úas_hook.<locals>.<lambda>4   s   ø€ ©°DÐ)C¸FÒ)Cr   r   )r"   s   `r   Úas_hookr%   /   s   ø€ ô
 DÐCr   z(\x1b[^m]+m)c                 óR  • [        U [        5      (       a  U R                  SS5      n U R                  5       US n[	        X2S-
  5      n[        U5      S:X  a,  [        [        R                  R                  US   5      5        gSnUSS  Hk  n[        R                  R                  U5      n[        XW-   5        [        5       (       d    g[        R                  U5      n[        U5      S:”  d  Mf  US   nMm     [        U[        R                  R                  US   5      -   5        g)zˆVery dumb 'pager' in Python, for when nothing else works.

Only moves forward, same interface as page(), except for pager_cmd and
mode.
r   Ú Né   r   éÿÿÿÿ)r   r   Úgetr   r   ÚlenÚprintÚosÚlinesepr   Ú	page_moreÚesc_reÚfindall)	r   r   r   Úout_lnÚscreensÚlast_escapeÚscrÚhunkÚesc_lists	            r   Ú	page_dumbr8   9   sè   € ô �%œ×ÑØ—	‘	˜,¨Ó+ˆØ×ÑÓ   Ð(€FÜ�6 q™.Ó)€GÜ
ˆ7ƒ|�qÓÜŒb�j‰j�o‰o˜g a™jÓ)Õ*àˆØ˜1˜R“=ˆCÜ—:‘:—?‘? 3Ó'ˆDÜ�+Ñ$Ô%Ü—;‘;ÙÜ—~‘~ dÓ+ˆHÜ�8‹}˜qÕ Ø& r™l’ñ !ô 	ˆkœBŸJ™JŸO™O¨G°B©KÓ8Ñ8Õ9r   c                 óF  • [         R                  R                  SS5      nUS:X  d  US:X  a  [        R                  S:w  d  U $  SSKnSSKn UR                  [        R                  5      n UR                  5       nUR                  5       u  pxUR!                  5         UR#                  [        R                  UR$                  U5        U$ ! [         a    U s $ f = f! UR                   a   n[        SR                  U5      5      UeSnAff = f! [         a    U s $ f = f)zÌAttempt to work out the number of lines on the screen.

This is called by page(). It can raise an error (e.g. when run in the
test suite), so it's separated out so it can easily be called in a try block.
ÚTERMNÚxtermzxterm-colorÚsunos5r   ztermios error: {0})r-   Úenvironr*   ÚsysÚplatformÚtermiosÚcursesÚImportErrorÚ	tcgetattrÚstdoutÚerrorÚ	TypeErrorÚformatÚinitscrÚAttributeErrorÚgetmaxyxÚendwinÚ	tcsetattrÚTCSANOW)	Úscreen_lines_defr:   r@   rA   Ú
term_flagsÚerrr5   Úscreen_lines_realÚscreen_colss	            r   Ú_detect_screen_sizerS   Q   s  € ô �:‰:�>‰>˜& Ó&€DØ�'‹M˜T =Ó0´c·l±lÀhÓ6Nð  Ðð ÛÛðCØ×&Ñ&¤s§z¡zÓ2ˆ
ð
 Ø�n‰nÓˆð
 %(§L¡L£NÑ!ÐØ
‡M�M„Oð ×Ñ”c—j‘j §¡°Ô<àÐøô9 ó  ØÒð ûð �=‰=ó CäÐ,×3Ñ3°CÓ8Ó9¸sÐBûðCûô ó  àÒð ús<   ÁC ÁC Á-D ÃCÃCÃDÃ.D	Ä	DÄD ÄD c                 ó˜  • [        U [        5      (       a  U S   n [        R                  R	                  SS5      nUS;   a   [        R
                  S:w  a  [        U 5        gU R                  5       US n[        R                  R                  U5      n[        U5      n[        U5      n[        U[        US-  5      S-   5      n	[        5       S   n
US	::  a   U[        U
5      -  nX’::  a  [        U5        g[#        U5      nUS
[%        X15      -   -  n[        R
                  S:X  a¾  UR'                  S5      (       a  SnGO][(        R*                  " S5      u  pÍ[-        U5      n [        R.                  " U5        UR1                  SSS9 nUR3                  U 5        U< SU< 3nSSS5        [        R4                  " W5      (       a  SnOSn[,        R6                  " U5        O¹ Sn[8        R:                  " US[8        R<                  [8        R>                  S9n[        R@                  " [B        RD                  " URF                  SS9U5      n URH                  =(       d    [J        RL                  RH                  nUR3                  U 5        UR/                  5       nUb
  [U        XS9  gg! [        [         4 a    [        U5         gf = f! , (       d  f       GN.= f! [,        R6                  " U5        f = f! UR/                  5       nf = f! [N         a#  nURP                  S:X  a  Sn SnAN’Sn SnAN™SnAf[R         a    Sn Nªf = f)aÈ  Display a string, piping through a pager after a certain length.

strng can be a mime-bundle dict, supplying multiple representations,
keyed by mime-type.

The screen_lines parameter specifies the number of *usable* lines of your
terminal screen (total lines minus lines you need to reserve to show other
information).

If you set screen_lines to a number <=0, page() will try to auto-determine
your screen size and will only use up to (screen_size+screen_lines) for
printing, paging after that. That is, if you want auto-detection but need
to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
auto-detection without any lines reserved simply use screen_lines = 0.

If a string won't fit in the allowed lines, it is sent through the
specified pager command. If none given, look for PAGER in the environment,
and ultimately default to less.

If no system pager works, the string is sent through a 'dumb pager'
written in python, very simplistic.
r   r:   Údumb)rU   ÚemacsÚntNéP   r(   r   Ú Útypez.txtÚwtúutf-8©Úencodingz < T)ÚshellÚstdinÚstderr)é    zBroken pipe)r   )+r   r   r-   r=   r*   Únamer,   r   r.   r   r+   ÚmaxÚintr
   rS   rF   r   Úget_pager_cmdÚget_pager_startÚ
startswithÚtempfileÚmkstempr   ÚcloseÚopenÚwriter	   ÚunlinkÚ
subprocessÚPopenÚPIPEÚDEVNULLÚ_wrap_closeÚioÚTextIOWrapperr`   r^   r>   rD   ÚIOErrorr    ÚOSErrorr8   )r   r   r   Ú	pager_cmdr:   Ú	str_linesÚstr_toprintÚnum_newlinesÚlen_strÚnumlinesrN   ÚretvalÚfdÚtmpnameÚtmppathÚtmpfileÚcmdÚprocÚpagerÚpager_encodingÚmsgs                        r   Ú
pager_pagerˆ   €   sº  € ô2 �%œ×ÑØ�lÑ#ˆô �:‰:�>‰>˜& Ó(€DØÐÓ¤B§G¡G¨t£OÜˆeŒØà× Ñ Ó" 5 6Ð*€IÜ—*‘*—/‘/ )Ó,€KÜ�y“>€LÜ�+Ó€Gô
 �<¤ G¨B¡J£°Ñ 1Ó2€Hä(Ó*¨1Ñ-Ðð �qÓð	ØÔ/Ð0@ÓAÑAˆLð ÓäˆkÕô " )Ó,ˆ	Ø�Sœ?¨9Ó;Ñ;Ñ;ˆ	Ü�7‰7�d‹?Ø×#Ñ# F×+Ñ+à’ä&×.Ò.¨vÓ6‘�Ü˜w›-�ð)Ü—H’H˜R”LØ Ÿ™ d°W˜Ñ=ÀØŸ™ eÔ,Û+4²gÐ>˜÷ >ô —y’y —~‘~Ø!"™à!%˜ä—K’K Õ(ðØ�ä!×'Ò'ØØÜ$Ÿ/™/Ü%×-Ñ-ñ	�ô ŸšÜ×$Ò$ T§Z¡Z¸'ÑBÀDó�ð+Ø%*§^¡^×%J´s·z±z×7JÑ7J�NØ—K‘K Ô&à"Ÿ[™[›]�Fð ÑÜ�eÓ6ð øôy Ô/Ð0ó 	Ü�+ÔÙð	ú÷0 >Ö=ûô —K’K Õ(ûð$ #Ÿ[™[›]‘FûÜó Ø—8‘8Ð2Ó2Ø!•Fà•FûÜó à’ðúss   ÃJ, Å%&K ÆKÆ&(K Ç&A)L É>K: ÊL Ê,K
Ë	K
Ë
KËK ËK7Ë:LÌL Ì
M	ÌL7Ì0L7Ì7M	ÍM	r   r   c                 ó¬   • [        SU5      n[        5       nU(       a   UR                  R                  XUS9  g[        XX#5      $ ! [         a     Nf = f)a  Display content in a pager, piping through a pager after a certain length.

data can be a mime-bundle dict, supplying multiple representations,
keyed by mime-type, or text.

Pager is dispatched via the `show_in_pager` IPython hook.
If no hook is registered, `pager_page` will be used.
r   )r   r   N)rd   r   ÚhooksÚshow_in_pagerr   rˆ   )r   r   r   rx   Úips        r   Úpager�   ò   s]   € ô ��5‹M€Eô 
‹€BÞ	ð	Ø�H‰H×"Ñ" 4À<Ð"ÑPØô
 �d <Ó;Ð;øô	 ó 	Ùð	ús   ŸA Á
AÁAc                 ó>  • [        U5      nUS[        X!5      -   -  n [        R                  S   S;   a  [        e[        US-   U -   5        g	!    US:”  a  US-  n[        [        U SS9R                  5       U5         g	!   [        S[        U 5      5          g	= f= f)
zDPage a file, using an optional pager command and starting line.
    rY   r:   )rV   rU   r   r(   r\   r]   zUnable to show fileN)rf   rg   r-   r=   ÚEnvironmentErrorr	   r�   rl   Úreadr,   Úrepr)Úfnamer   rx   s      r   Ú	page_filer“     s›   € ô ˜iÓ(€IØ�” yÓ7Ñ7Ñ7€Ið
5Ü�:‰:�fÑÐ!1Ó1Ü"Ð"Üˆy˜3‰ Ñ&Õ'øð5ð	5Ø�q‹yØ˜‘
�Ü”�e gÑ.×3Ñ3Ó5°uÖ=øð	5ÜÐ'¬¨U«×4ýs#   ž.A ÁBÁ-A?Á?BÂBÂBc                 ó  • [         R                  S:X  a  SnO[         R                  S;   a  SnU c   [         R                  S   n U S:X  a7  S[         R                  R                  SS	5      R	                  5       ;  a  U S
-  n U $ !   Wn  NE= f)zKReturn a pager command.

Makes some attempts at finding an OS-correct one.
Úposixzless -R)rW   ÚdosrZ   ÚPAGERÚlessz-rÚLESSr'   z -R)r-   rc   r=   r*   Úlower)rx   Údefault_pager_cmds     r   rf   rf      s†   € ô
 
‡w�w�'ÓØ%ÑÜ	�‰�LÓ	 Ø"ÐàÑð	*ÜŸ
™
 7Ñ+ˆIð �FÓ˜t¬2¯:©:¯>©>¸&À"Ó+E×+KÑ+KÓ+MÓMØ�UÑˆ	àÐøð	*Ø)ŠIús   ²B ÂB
c                 óN   • U S;   a  U(       a  S[        U5      -   nU$ Sn U$ SnU$ )zwReturn the string for paging files with an offset.

This is the '+N' argument which less and more (under Unix) accept.
)r˜   ÚmoreÚ+r'   )Ústr)r…   r   Ústart_strings      r   rg   rg   6  sA   € ð �ÓÞØ¤ U£Ñ+ˆLð
 Ðð ‰Lð Ðð ˆØÐr   rW   r:   rU   rV   c                  óÂ   • [         R                  R                  S5        [        R                  " 5       n U S;   a  SnOSn[         R                  R                  S5        U$ )zVSmart pausing between pages

@return:    True if need print more lines, False if quit
ú$---Return to continue, q to quit--- )ÚqÚQFTzo                                     )r>   rD   rm   ÚmsvcrtÚgetwch)ÚansÚresults     r   r/   r/   I  sL   € ô
 	�
‰
×ÑÐ?Ô@Ü�mŠm‹oˆØ�*ÓØ‰FàˆFÜ�
‰
×ÑÐ3Ô4Øˆr   c                  óz   • [         R                  " S5      n U R                  5       R                  S5      (       a  gg)Nr¢   r£   FT)r   Úinputrš   rh   )r§   s    r   r/   r/   W  s.   € Ü�oŠoÐDÓEˆØ�9‰9‹;×!Ñ! #×&Ñ&Øàr   )r   é   )r   r   N)ÚreturnN)r   Nr   ))Ú__doc__r-   rt   Úrer>   ri   ro   r   Úpathlibr   ÚIPythonr   ÚIPython.displayr   ÚIPython.core.errorr   ÚIPython.utils.datar   ÚIPython.utils.processr	   ÚIPython.utils.terminalr
   ÚIPython.utilsr   r   r%   Úcompiler0   r8   rS   rˆ   re   r�   r“   rf   rg   rc   r=   r*   r¥   r/   r   r   r   Ú<module>r¸      s¸   ðñ	ó 
Û 	Û 	Û 
Û Û å #Ý å Ý #Ý &Ý #Ý (Ý 4Ý #ôòDð 
�Š�OÓ	$€ô:ò0+ö^o7ñd<�cð <¨Sõ <ô45ô(ò,ð" ‡7�7ˆdƒ?�r—z‘z—~‘~ f¨VÓ4¸Ó?Ûóór   