Your IP : 3.12.147.12
�
f f� � @ sb d Z d d l m Z Gd d � d � Z e d k r^ d d l m Z e d d d d
d �n d S)
z9Implement Idle Shell history mechanism with History class� )�idleConfc @ sR e Z d Z d Z d d � Z d d � Z d d � Z d d � Z d
d � Z d S)
�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 | _ t j d d d d d � | _ | j d | j � | j d | j � d S) 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 �8/opt/alt/python34/lib64/python3.4/idlelib/IdleHistory.py�__init__
s zHistory.__init__c C s | j d d � d S)z4Fetch later statement; start with ealiest if cyclic.�reverseF�break)�fetch)r �eventr r r r
s zHistory.history_nextc C s | j d d � d S)z0Fetch earlier statement; start with most recent.r Tr )r )r r r r r r # s zHistory.history_prevc C sM t | j � } | j } | j } | d k r� | d k r� | j j d d d � ss | j j d d � | j | k r� d } } | j j d d � q� n | d k s� | d k r� | j j d d � } | r� | } q� | j r� d } q� | j j � d Sn t | � } x
| | rd n d 7} | d k s5| | k r�| j j � | j r\| d k r\d S| j j d d � | k r�| j j
d d � | j j d | � n d } } Pn | j | } | d | � | k rt | � | k r| j j
d d � | j j d | � PqqW| j j d � | j j
d d d
� | | _ | | _ d S)
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 ZbellZdeleter ZseeZ
tag_remove)r r Znhistr r
Znprefix�itemr r r r ( sJ "
( z
History.fetchc C sp | j � } t | � d k rZ y | j j | � Wn t k
rF Yn X| j j | � n d | _ d | _ d S)z.Store Shell input statement into history list.� N)�stripr r �remove�
ValueError�appendr r
)r �sourcer r r �storeY s
z
History.storeN) �__name__�
__module__�__qualname__�__doc__r r
r r r"