Ë
    #´˜já  ã                   óV   — d Z ddlmZ  G d„ d«      Zedk(  rddlmZ  eddd	¬
«       yy)z9Implement Idle Shell history mechanism with History classé    )ÚidleConfc                   ó.   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚHistorya@   Implement Idle Shell history mechanism.

    store - Store source statement (called from pyshell.resetoutput).
    fetch - Fetch stored statement matching prefix already entered.
    history_next - Bound to <<history-next>> event (default Alt-N).
    history_prev - Bound to <<history-prev>> event (default Alt-P).
    c                 óè   — || _         g | _        d| _        d| _        t	        j
                  ddddd«      | _        |j                  d| j                  «       |j                  d| j                  «       y)	ad  Initialize data attributes and bind event methods.

        .text - Idle wrapper of tk Text widget, with .bell().
        .history - source statements, possibly with multiple lines.
        .prefix - source already entered at prompt; filters history list.
        .pointer - index into history.
        .cyclic - wrap around history list (or not).
        NÚmainr   Úcyclicé   Úboolz<<history-previous>>z<<history-next>>)
ÚtextÚhistoryÚprefixÚpointerr   Ú	GetOptionr   ÚbindÚhistory_prevÚhistory_next)Úselfr   s     ú!lib/python3.12/idlelib/history.pyÚ__init__zHistory.__init__   sd   € ð ˆŒ	ØˆŒØˆŒØˆŒÜ×(Ñ(¨°¸HÀaÈÓPˆŒØ�	‰	Ð(¨$×*;Ñ*;Ô<Ø�	‰	Ð$ d×&7Ñ&7Õ8ó    c                 ó(   — | j                  d¬«       y)z5Fetch later statement; start with earliest if cyclic.F©ÚreverseÚbreak©Úfetch©r   Úevents     r   r   zHistory.history_next   s   € à�
‰
˜5ˆ
Ô!Ør   c                 ó(   — | j                  d¬«       y)z0Fetch earlier statement; start with most recent.Tr   r   r   r   s     r   r   zHistory.history_prev$   s   € à�
‰
˜4ˆ
Ô Ør   c                 ór  — t        | j                  «      }| j                  }| j                  }|�k|�i| j                  j                  ddd«      s,| j                  j                  dd«      | j                  |   k7  r dx}}| j                  j                  dd«       |�|€K| j                  j                  dd«      }|r|}n*| j                  rd}n| j                  j                  «        yt        |«      }	 ||rdndz  }|dk  s||k\  r‰| j                  j                  «        | j                  s|dk  ry| j                  j                  dd«      |k7  r9| j                  j                  dd«       | j                  j                  d|d	«       dx}}n`| j                  |   }|d| |k(  rHt        |«      |kD  r:| j                  j                  dd«       | j                  j                  d|d	«       nŒü| j                  j                  d«       | j                  j                  d
dd«       || _        || _        y)a+  Fetch statement and replace current line in text widget.

        Set prefix and pointer as needed for successive fetches.
        Reset them to None, None when returning to the start line.
        Sound bell when return to start line or cannot leave a line
        because cyclic is False.
        NÚinsertz!=zend-1cÚiomarkéÿÿÿÿr	   r   ÚstdinÚselz1.0Úend)Úlenr   r   r   r   ÚcompareÚgetÚmark_setr   ÚbellÚdeleter!   ÚseeÚ
tag_remove)r   r   Únhistr   r   ÚnprefixÚitems          r   r   zHistory.fetch)   sè  € ô �D—L‘LÓ!ˆØ—,‘,ˆØ—‘ˆØÐ 6Ð#5Ø�y‰y× Ñ  ¨4°Ô:Ø—I‘I—M‘M (¨HÓ5¸¿¹ÀgÑ9NÒNØ#'Ð'�˜&Ø—	‘	×"Ñ" 8¨XÔ6Øˆ?˜f˜nØ—Y‘Y—]‘] 8¨XÓ6ˆFÙØ‘à—;’;Ø ‘Gà—I‘I—N‘NÔ$ØÜ�f“+ˆØØ™W‘r¨!Ñ+ˆGØ˜Š{˜g¨Ò.Ø—	‘	—‘Ô Ø—{’{ w°¢{Øà—y‘y—}‘} X¨xÓ8¸FÒBØŸ	™	×(Ñ(¨°8Ô<ØŸ	™	×(Ñ(¨°6¸7ÔCØ'+Ð+�G˜fØØ—<‘< Ñ(ˆDØ�H�Wˆ~ Ò'¬C°«I¸Ò,?Ø—	‘	× Ñ  ¨8Ô4Ø—	‘	× Ñ  ¨4°Ô9Øð! ð" 	�	‰	�‰�hÔØ�	‰	×Ñ˜U E¨5Ô1ØˆŒØˆ�r   c                 óè   — |j                  «       }t        |«      dkD  r7	 | j                  j                  |«       | j                  j                  |«       d| _        d| _        y# t        $ r Y Œ5w xY w)z.Store Shell input statement into history list.é   N)Ústripr'   r   ÚremoveÚ
ValueErrorÚappendr   r   )r   Úsources     r   ÚstorezHistory.storeZ   se   € à—‘“ˆÜˆv‹;˜Š?ðØ—‘×#Ñ# FÔ+ð �L‰L×Ñ Ô'ØˆŒØˆ�øô	 ò Ùðús    A% Á%	A1Á0A1N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r9   © r   r   r   r      s!   „ ñò9ò"ò
ò
/óbr   r   Ú__main__)r   zidlelib.idle_test.test_historyr3   F)Ú	verbosityÚexitN)r=   Úidlelib.configr   r   r:   Úunittestr   r>   r   r   Ú<module>rD      s7   ðÙ ;å #÷_ñ _ðD ˆzÒÝÙÐ	)°Q¸UÖCð r   