�`^c@sbdZddlmZddd��YZedkr^ddlmZeddd d
e�ndS(
s9Implement Idle Shell history mechanism with History classi�(tidleConftHistorycBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(s@ 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).
cCsl||_g|_d|_d|_tjddddd�|_|jd|j �|jd|j
�dS( sdInitialize 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).
tmainRtcyclicitbools<<history-previous>>s<<history-next>>N(ttextthistorytNonetprefixtpointerRt GetOptionRtbindthistory_prevthistory_next(tselfR((s)/sys/lib/python2.7/idlelib/IdleHistory.pyt__init__
s cCs|jdt�dS(s4Fetch later statement; start with ealiest if cyclic.treversetbreak(tfetchtFalse(Rtevent((s)/sys/lib/python2.7/idlelib/IdleHistory.pyR
scCs|jdt�dS(s0Fetch earlier statement; start with most recent.RR(RtTrue(RR((s)/sys/lib/python2.7/idlelib/IdleHistory.pyR#scCsFt|j�}|j}|j}|dk r�|dk r�|jjddd�ss|jjdd�|j|kr�d}}|jjdd�q�n|dks�|dkr�jjdd�}|r�|}q�j r�}q�jj
�dSnt|�}x||rdnd7}|dks5||kr�|jj
�|j r\|dkr\dS|jjdd�|kr�|jjdd�|jjd|�nd}}Pn|j|}|| |krt|�|kr|jjdd�|jjd|�Pqq|jj
d�|jjd d
d�||_||_dS(s+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.
tinserts!=send-1ctiomarki�Niitsels1.0tend(tlenRR RRRtcomparetgettmark_setRtbelltdeleteRtseet
tag_remove(RRtnhistR Rtnprefixtitem((s)/sys/lib/python2.7/idlelib/IdleHistory.pyR(sJ "
" cCso|j�}t|�dkrYy|jj|�Wntk
rEnX|jj|�nd|_d|_dS(s.Store Shell input statement into history list.iN( tstripRRtremovet
ValueErrortappendRR R(Rtsource((s)/sys/lib/python2.7/idlelib/IdleHistory.pytstoreYs
(t__name__t
__module__t__doc__RR
RRR*(((s)/sys/lib/python2.7/idlelib/IdleHistory.pyRs 1t__main__(Rs"idlelib.idle_test.test_idlehistoryt verbosityitexitN((R-tidlelib.configHandlerRRR+tunittestRR(((s)/sys/lib/python2.7/idlelib/IdleHistory.pyt<module>s
a
|