python (3.11.7)
    e                     h    d Z ddlmZ  G d d          Zedk    rddlmZ  eddd	
           dS dS )z9Implement Idle Shell history mechanism with History class    )idleConfc                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )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        ddddd          | _        |                    d| j                   |                    d| j	                   dS )	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).
        Nmainr   cyclic   boolz<<history-previous>>z<<history-next>>)
texthistoryprefixpointerr   	GetOptionr   bindhistory_prevhistory_next)selfr   s     C/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/idlelib/history.py__init__zHistory.__init__   sp     	(HaPP		($*;<<<		$d&788888    c                 2    |                      d           dS )z5Fetch later statement; start with earliest if cyclic.Freversebreakfetchr   events     r   r   zHistory.history_next   s    
5
!!!wr   c                 2    |                      d           dS )z0Fetch earlier statement; start with most recent.Tr   r   r   r   s     r   r   zHistory.history_prev$   s    
4
   wr   c                 T   t          | j                  }| j        }| j        }|g|e| j                            ddd          s*| j                            dd          | j        |         k    rdx}}| j                            dd           ||E| j                            dd          }|r|}n%| j        rd}n| j        	                                 dS t          |          }	 ||rdndz
  }|d	k     s||k    r| j        	                                 | j        s|d	k     rdS | j                            dd          |k    r7| j        
                    dd           | j                            d|d
           dx}}ng| j        |         }|d|         |k    rKt          |          |k    r8| j        
                    dd           | j                            d|d
           n| j                            d           | j        
                    ddd
           || _        || _        dS )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.
        Ninsertz!=zend-1ciomarkTr	   r   stdinselz1.0end)lenr   r   r
   r   comparegetmark_setr   belldeleter!   see
tag_remove)r   r   nhistr   r
   nprefixitems          r   r   z
History.fetch)   sE    DL!!,6#5y  4:: 
7IMM(H55g9NNN#''&	""8X666?fnY]]8X66F 
;  GGINN$$$Ff++	W+rr!+G{{g..	   { ,w{{Fy}}Xx88FBB	((8<<<	((67CCC'++Gf<(DHWH~''CII,?,?	  8444	  4999!	"