§
    �Ÿjé-  ã                   ót  — d Z ddlZddlZddlZddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ dd„Zd„ Z ej        d¦  «        Zdd„Zd„ Zdd„Zdd„Zdd„Z d d„Z!d„ Z"ej#        dk    r(ej$         %                    dd¦  «        dk    r	ddl&Z&d„ Z'dS d„ Z'dS )!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)Ú	py3compaté   c                 óÂ   — t          | t          ¦  «        r| }n5|r/d                     |                      ¦   «         |d…         ¦  «        } d| i}t	          |d¬¦  «         dS )z1Just display, no paging. screen_lines is ignored.ú
Nú
text/plainT)Úraw)Ú
isinstanceÚdictÚjoinÚ
splitlinesr   )ÚstrngÚstartÚscreen_linesÚdatas       ú^/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/IPython/core/page.pyÚdisplay_pager   $   sl   € å�%�ÑÔð 'Øˆˆàð 	;Ø—J’J˜u×/Ò/Ñ1Ô1°%°&°&Ô9Ñ:Ô:ˆEØ˜uÐ&ˆÝˆD�dÐÑÔÐÐÐó    c                 ó   ‡ — ˆ fd„S )zRWrap a pager func to strip the `self` arg

    so it can be called as a hook.
    c                 ó   •—  ‰|i |¤ŽS ©N© )ÚselfÚargsÚkwargsÚ	page_funcs      €r   ú<lambda>zas_hook.<locals>.<lambda>4   s   ø€ ¨¨°DÐ)C¸FÐ)CÐ)C€ r   r   )r#   s   `r   Úas_hookr%   /   s   ø€ ð
 DÐCÐCÐCÐCr   z(\x1b[^m]+m)c                 ó¾  — t          | t          ¦  «        r|                      dd¦  «        } |                      ¦   «         |d…         }t	          ||dz
  ¦  «        }t          |¦  «        dk    r4t          t          j         	                    |d         ¦  «        ¦  «         dS d}|dd…         D ]y}t          j         	                    |¦  «        }t          ||z   ¦  «         t          ¦   «         s dS t                               |¦  «        }t          |¦  «        dk    r|d         }Œzt          |t          j         	                    |d         ¦  «        z   ¦  «         dS )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   s9  € õ �%�ÑÔð ,Ø—	’	˜,¨Ñ+Ô+ˆØ×ÒÑ Ô    Ô(€FÝ�6˜, q™.Ñ)Ô)€GÝ
ˆ7�|„|�qÒÐÝ�bŒj�oŠo˜g aœjÑ)Ô)Ñ*Ô*Ð*Ð*Ð*àˆØ˜1˜R˜4”=ð 	+ð 	+ˆCÝ”:—?’? 3Ñ'Ô'ˆDÝ�+ Ñ$Ñ%Ô%Ð%Ý‘;”;ð Ø��Ý—~’~ dÑ+Ô+ˆHÝ�8‰}Œ}˜qÒ Ð Ø& rœl�øÝˆk�BœJŸOšO¨G°B¬KÑ8Ô8Ñ8Ñ9Ô9Ð9Ð9Ð9r   c                 óX  — t           j                             dd¦  «        }|dk    s|dk    rt          j        dk    s| S 	 ddl}ddl}n# t          $ r | cY S w xY w	 |                     t          j	        ¦  «        }n5# |j
        $ r(}t          d                     |¦  «        ¦  «        |‚d}~ww xY w	 |                     ¦   «         }n# t          $ r | cY S w xY w|                     ¦   «         \  }}|                     ¦   «          |                     t          j	        |j        |¦  «         |S )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   sd  € õ Œ:�>Š>˜& Ñ&Ô&€DØ�'ŠMˆM˜T =Ò0Ð0µc´lÀhÒ6NÐ6Nð  Ðð ØˆˆˆØˆˆˆˆøÝð  ð  ð  ØÐÐÐð øøøðCØ×&Ò&¥s¤zÑ2Ô2ˆ
ˆ
øØŒ=ð Cð Cð CåÐ,×3Ò3°CÑ8Ô8Ñ9Ô9¸sÐBøøøøðCøøøð Ø�nŠnÑÔˆˆøÝð  ð  ð  àÐÐÐð øøøð %(§L¢L¡N¤NÑ!Ð�kØ
‡M‚M�O„O€Oð ×Ò•c”j ¤°Ñ<Ô<Ð<àÐs<   Á A	 Á	AÁAÁA< Á<
B.Â#B)Â)B.Â2C ÃCÃCc                 óØ  — t          | t          ¦  «        r| d         } t          j                             dd¦  «        }|dv r!t          j        dk    rt          | ¦  «         dS |                      ¦   «         |d…         }t          j         	                    |¦  «        }t          |¦  «        }t          |¦  «        }t          |t          |dz  ¦  «        dz   ¦  «        }	t          ¦   «         d         }
|d	k    r;	 |t          |
¦  «        z  }n'# t          t           f$ r t          |¦  «         Y dS w xY w|	|k    rt          |¦  «         dS t#          |¦  «        }|d
t%          ||¦  «        z   z  }t          j        dk    rç|                     d¦  «        rd}�n¼t)          j        d¦  «        \  }}t-          |¦  «        }	 t          j        |¦  «         |                     dd¬¦  «        5 }|                     | ¦  «         |›d|›�}ddd¦  «         n# 1 swxY w Y   t          j        |¦  «        rd}nd}t-          j        |¦  «         �n# t-          j        |¦  «         w xY w	 d}t9          j        |dt8          j        t8          j        ¬¦  «        }t          j         tC          j"        |j#        d¬¦  «        |¦  «        }	 |j$        ptJ          j&        j$        }|                     | ¦  «         |                     ¦   «         }n# |                     ¦   «         }w xY wn4# tN          $ r}|j(        dk    rd}nd}Y d}~nd}~wtR          $ r d}Y nw xY w|�tU          | |¬¦  «         dS dS )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¨t¢O OÝˆe‰ŒˆØˆà× Ò Ñ"Ô" 5 6 6Ô*€IÝ”*—/’/ )Ñ,Ô,€KÝ�y‘>”>€LÝ�+ÑÔ€Gõ
 �<¥ G¨B¡J¡¤°Ñ 1Ñ2Ô2€Hå(Ñ*Ô*¨1Ô-Ðð �qÒÐð	ØÕ/Ð0@ÑAÔAÑAˆLˆLøÝÕ/Ð0ð 	ð 	ð 	Ý�+ÑÔÐØˆFˆFð	øøøð
 �<ÒÐåˆkÑÔÐÐÐõ " )Ñ,Ô,ˆ	Ø�S�?¨9°UÑ;Ô;Ñ;Ñ;ˆ	ÝŒ7�dŠ?ˆ?Ø×#Ò# FÑ+Ô+ð )à�‘å&Ô.¨vÑ6Ô6‘��GÝ˜w™-œ-�ð)Ý”H˜R‘L”L�LØ Ÿš d°W˜Ñ=Ô=ð ?ÀØŸš eÑ,Ô,Ð,Ø+4¨9¨9°g°gÐ>˜ð?ð ?ð ?ñ ?ô ?ð ?ð ?ð ?ð ?ð ?ð ?øøøð ?ð ?ð ?ð ?õ ”y ‘~”~ð &Ø!"˜˜à!%˜å”K Ñ(Ô(Ð(Ñ(ø•D”K Ñ(Ô(Ð(Ð(øøøðØ�å!Ô'ØØÝ$œ/Ý%Ô-ð	ñ ô �õ œÝÔ$ T¤Z¸'ÐBÑBÔBÀDñô �ð+Ø%*¤^Ð%Jµs´zÔ7J�NØ—K’K Ñ&Ô&Ð&à"Ÿ[š[™]œ]�F�Fø˜UŸ[š[™]œ]�FÐ*Ð*Ð*Ð*�FøÝð ð ð Ø”8Ð2Ò2Ð2Ø!�F�Fà�FøøøøøøøøøÝð ð ð à���ðøøøð ÐÝ�e¨Ð6Ñ6Ô6Ð6Ð6Ð6ð Ðsy   Ã:D Ä D1Ä0D1Ç +I Ç+HÈI ÈHÈI ÈHÈI ÉI$É(AL! Ë-L Ë2L! ÌLÌL! Ì!
MÌ+M Í MÍMc                 óÆ   — t          d|¦  «        }t          ¦   «         }|r0	 |j                             | ||¬¦  «         dS # t          $ r Y nw xY wt          | |||¦  «        S )a1  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ŒM€Eõ 
‰Œ€BØ	ð ð	ØŒH×"Ò" 4¨uÀ<Ð"ÑPÔPÐPØˆFøÝð 	ð 	ð 	ØˆDð	øøøõ �d˜E <°Ñ;Ô;Ð;s   ¢A Á
AÁAc                 óˆ  — t          |¦  «        }|dt          ||¦  «        z   z  }	 t          j        d         dv rt          ‚t          |dz   | z   ¦  «         d	S #  	 |dk    r|dz  }t          t          | d¬¦  «                             ¦   «         |¦  «         Y d	S #  t          dt          | ¦  «        ¦  «         Y Y d	S xY wxY w)
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Ñ7€Ið
5ÝŒ:�fÔÐ!1Ð1Ð1Ý"Ð"Ýˆy˜3‰ Ñ&Ñ'Ô'Ð'Ð'Ð'øð5ð	5Ø�qŠyˆyØ˜‘
�Ý•�e gÐ.Ñ.Ô.×3Ò3Ñ5Ô5°uÑ=Ô=Ð=Ð=Ð=Ð=øð	5ÝÐ'­¨U©¬Ñ4Ô4Ð4Ð4Ð4Ð4Ð4øøøøøøs#   §0A ÁCÁ<BÂB>Â:CÂ>Cc                 ó  — t           j        dk    rd}nt           j        dv rd}| €	 t           j        d         } n	#  |} Y nxY w| dk    r9dt           j                             d	d
¦  «                             ¦   «         vr| dz  } | S )zSReturn a pager command.

    Makes some attempts at finding an OS-correct one.
    Úposixzless -R)rW   ÚdosrZ   NÚPAGERÚlessz-rÚLESSr'   z -R)r-   rc   r=   r*   Úlower)rx   Údefault_pager_cmds     r   rf   rf      s™   € õ
 
„w�'ÒÐØ%ÐÐÝ	Œ�LÐ	 Ð	 Ø"ÐàÐð	*Ýœ
 7Ô+ˆIˆIøð	*Ø)ˆIˆIˆIøøøà�FÒÐ˜t­2¬:¯>ª>¸&À"Ñ+EÔ+E×+KÒ+KÑ+MÔ+MÐMÐMØ�UÑˆ	àÐs	   §: ºA c                 óB   — | dv r|rdt          |¦  «        z   }nd}nd}|S )zReturn 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  s;   € ð �ÐÐØð 	Ø¥ U¡¤Ñ+ˆLˆLàˆLˆLàˆØÐr   rW   r:   rU   rV   c                  óº   — t           j                             d¦  «         t          j        ¦   «         } | dv rd}nd}t           j                             d¦  «         |S )zg Smart 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  sY   € õ
 	Œ
×ÒÐ?Ñ@Ô@Ð@ÝŒm‰oŒoˆØ�*ÐÐØˆFˆFàˆFÝŒ
×ÒÐ3Ñ4Ô4Ð4Øˆr   c                  ó€   — t          j        d¦  «        } |                      ¦   «                              d¦  «        rdS dS )Nr¢   r£   FT)r   Úinputrš   rh   )r§   s    r   r/   r/   W  s:   € ÝŒoÐDÑEÔEˆØ�9Š9‰;Œ;×!Ò! #Ñ&Ô&ð 	Ø�5à�4r   )r   r   )r   r   N)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ˆ   r�   r“   rf   rg   rc   r=   r*   r¥   r/   r   r   r   ú<module>r¶      s  ðð	ð 	ð 
€	€	€	Ø 	€	€	€	Ø 	€	€	€	Ø 
€
€
€
Ø €€€Ø Ð Ð Ð à #Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð Ø #Ð #Ð #Ð #Ð #Ð #Ø &Ð &Ð &Ð &Ð &Ð &Ø #Ð #Ð #Ð #Ð #Ð #Ø (Ð (Ð (Ð (Ð (Ð (Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø #Ð #Ð #Ð #Ð #Ð #ðð ð ð ðDð Dð Dð 
ˆŒ�OÑ	$Ô	$€ð:ð :ð :ð :ð0+ð +ð +ð^o7ð o7ð o7ð o7ðd<ð <ð <ð <ð45ð 5ð 5ð 5ð(ð ð ð ð,ð ð ð" „7ˆd‚?€?�r”z—~’~ f¨VÑ4Ô4¸Ò?Ð?Ø€M€M€Mðð ð ð ð ðð ð ð ð r   