Hacked By AnonymousFox
3
� f� � @ sD d Z ddlmZ G dd� d�Zedkr@ddlmZ eddd d
� dS )z9Implement Idle Shell history mechanism with History class� )�idleConfc @ s8 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� 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 C sL || _ g | _d| _d| _tjddddd�| _|jd| j� |jd| 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).
N�mainr �cyclic� �boolz<<history-previous>>z<<history-next>>)
�text�history�prefix�pointerr Z GetOptionr Zbind�history_prev�history_next)�selfr � r �4/opt/alt/python36/lib64/python3.6/idlelib/history.py�__init__ s zHistory.__init__c C s | j dd� dS )z4Fetch later statement; start with ealiest if cyclic.F)�reverse�break)�fetch)r �eventr r r r
s zHistory.history_nextc C s | j dd� dS )z0Fetch earlier statement; start with most recent.T)r r )r )r r r r r r $ s zHistory.history_prevc C s� t | j�}| j}| j}|dk rd|dk rd| jjddd�sN| jjdd�| j| krdd }}| jjdd� |dkst|dkr�| jjdd�}|r�|}n| jr�d}n| jj � dS t |�}x�||r�dnd7 }|dk s�||k�r*| jj � | j r�|dk r�dS | jjdd�|k�r | jj
dd� | jjd|� d }}P | j| }|d|� |kr�t |�|kr�| jj
dd� | jjd|� P q�W | jjd� | jj
dd d
� || _|| _dS )
a+ Fetch statememt 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!=zend-1cZiomarkr r Zselz1.0�end���r )�lenr r r
r Zcompare�getZmark_setr Zbell�deleter ZseeZ
tag_remove)r r Znhistr r
Znprefix�itemr r r r ) sJ
z
History.fetchc C sV |j � }t|�dkrFy| jj|� W n tk
r8 Y nX | jj|� d| _d| _dS )z.Store Shell input statement into history list.� N)�stripr r �remove�
ValueError�appendr r
)r �sourcer r r �storeZ s z
History.storeN) �__name__�
__module__�__qualname__�__doc__r r
r r r# r r r r r s 1r �__main__)r zidlelib.idle_test.test_historyr F)� verbosity�exitN)r'