Your IP : 18.191.54.190


Current Path : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/undo.cpython-36.pyc

3

� f'+�@s�ddlZddlmZGdd�de�ZGdd�d�ZGdd�de�ZGd	d
�d
e�ZGdd�de�Zd
d�Ze	dkr�ddl
mZedddd�ddlm
Z
e
e�dS)�N)�	Delegatorc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dZ
dd�Zd#Zdd�Z
d$dd�Zd%dd�Zdd�Zdd�Zd&dd�Zdd �Zd!d"�ZdS)'�
UndoDelegatori�cCstj|�|j�dS)N)r�__init__�
reset_undo)�self�r�1/opt/alt/python36/lib64/python3.6/idlelib/undo.pyrs
zUndoDelegator.__init__cCsj|jdk	r(|jd�|jd�|jd�tj||�|dk	rf|jd|j�|jd|j�|jd|j�dS)Nz<<undo>>z<<redo>>z<<dump-undo-state>>)�delegateZunbindr�setdelegateZbind�
undo_event�
redo_event�
dump_event)rr	rrrr
s



zUndoDelegator.setdelegatecCsvddlm}||jd|j��td|jdd�td|jdd�td|jdd�td|j��||j|jd��d	S)
Nr)�pprintzpointer:� )�endzsaved:z
can_merge:zget_saved():�break)r�undolist�pointer�print�saved�	can_merge�	get_saved)r�eventrrrrr
(szUndoDelegator.dump_eventcCs&d|_d|_g|_d|_|jd�dS)N�r���)�	was_savedrr�	undoblock�	set_saved)rrrrr2s
zUndoDelegator.reset_undocCs&|r|j|_nd|_d|_|j�dS)NrFr)rrr�check_saved)r�flagrrrr9s

zUndoDelegator.set_savedcCs|j|jkS)N)rr)rrrrrAszUndoDelegator.get_savedNcCs
||_dS)N)�saved_change_hook)r�hookrrr�set_saved_change_hookFsz#UndoDelegator.set_saved_change_hookrcCs*|j�}||jkr&||_|jr&|j�dS)N)rrr )rZis_savedrrrrKs

zUndoDelegator.check_savedcCs|jt|||��dS)N)�addcmd�
InsertCommand)r�index�chars�tagsrrr�insertRszUndoDelegator.insertcCs|jt||��dS)N)r#�
DeleteCommand)r�index1�index2rrr�deleteUszUndoDelegator.deletecCs |jdkrt�|_|jj�dS)Nr)r�CommandSequence�
bump_depth)rrrr�undo_block_startcs
zUndoDelegator.undo_block_startcCsN|jjd�dkrJ|j}d|_t|�dkrJt|�dkr>|jd�}|j|d�dS)Nrrr)rr.�len�getcmdr#)r�cmdrrr�undo_block_stophs
zUndoDelegator.undo_block_stopTcCs�|r|j|j�|jdkr*|jj|�dS|jrX|jdkrX|j|jd}|j|�rXdS|g|j|jd�<|j|jkr|d|_|jd|_t	|j�|j
kr�|jd=|jd|_|jdkr�|jd|_d|_|j�dS)NrrTr)�dor	r�appendrrr�mergerr0�max_undor)rr2ZexecuteZlastcmdrrrr#ts(


zUndoDelegator.addcmdcCsP|jdkr|j�dS|j|jd}|j|j�|jd|_d|_|j�dS)NrrrF)r�bellr�undor	rr)rrr2rrrr�s
zUndoDelegator.undo_eventcCsR|jt|j�kr|j�dS|j|j}|j|j�|jd|_d|_|j�dS)NrrF)rr0rr8�redor	rr)rrr2rrrr�szUndoDelegator.redo_eventr)N)N)T)�__name__�
__module__�__qualname__r7rr
r
rrrr r"rrr(r,r/r3r#rrrrrrrs$



rc@sReZdZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�CommandNcCs,i|_i|_||_||_||_|r(||_dS)N)�marks_before�marks_afterr*r+r&r')rr*r+r&r'rrrr�szCommand.__init__cCs>|jj}|j|j|j|jf}|jdkr2|dd�}|t|�S)Nrr)�	__class__r;r*r+r&r'�repr)r�s�trrr�__repr__�s

zCommand.__repr__cCsdS)Nr)r�textrrrr4�sz
Command.docCsdS)Nr)rrFrrrr:�szCommand.redocCsdS)Nr)rrFrrrr9�szCommand.undocCsdS)Nrr)rr2rrrr6�sz
Command.mergecCs8i}x.|j�D]"}|dkr|dkr|j|�||<qW|S)Nr(Zcurrent)Z
mark_namesr%)rrF�marks�namerrr�
save_marks�s
zCommand.save_markscCs&x |j�D]\}}|j||�q
WdS)N)�items�mark_set)rrFrGrHr%rrr�	set_marks�szCommand.set_marks)N)r;r<r=r'rrEr4r:r9r6rIrLrrrrr>�s
	r>c@sNeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zej	ej
dZd
d�ZdS)r$NcCstj||d||�dS)N)r>r)rr*r&r'rrrr�szInsertCommand.__init__cCsv|j|�|_|j|j�|_|j|jdd�r6|jd�|_|j|j|j|j�|jd|jt|j�f�|_	|j|�|_
dS)N�>zend-1cz%s+%dc)rIr?r%r*�comparer(r&r'r0r+r@)rrFrrrr4�szInsertCommand.docCs>|jd|j�|j|j|j|j�|j||j�|jd�dS)Nr()rKr*r(r&r'rLr@�see)rrFrrrr:�szInsertCommand.redocCs:|jd|j�|j|j|j�|j||j�|jd�dS)Nr()rKr*r,r+rLr?rO)rrFrrrr9�szInsertCommand.undocCs�|j|jk	rdS|j|jkr dS|j|jkr0dSt|j�dkrBdS|jrh|j|jd�|j|j�krhdS|j|_|j|j|_dS)NFrTr)rAr+r*r'r0r&�classify)rr2rrrr6�szInsertCommand.merge�_cCs||jkrdS|dkrdSdS)N�alphanumeric�
�newlineZpunctuation)rR)r�crrrrPs

zInsertCommand.classify)N)
r;r<r=rr4r:r9r6�stringZ
ascii_lettersZdigitsrRrPrrrrr$�s
r$c@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)r)NcCstj|||dd�dS)N)r>r)rr*r+rrrrszDeleteCommand.__init__cCs�|j|�|_|j|j�|_|jr0|j|j�|_n|j|jd�|_|j|jdd�r^|jd�|_|j|j|j�|_|j|j|j�|j|�|_	dS)Nz +1crMzend-1c)
rIr?r%r*r+rN�getr&r,r@)rrFrrrr4szDeleteCommand.docCs:|jd|j�|j|j|j�|j||j�|jd�dS)Nr()rKr*r,r+rLr@rO)rrFrrrr:szDeleteCommand.redocCs:|jd|j�|j|j|j�|j||j�|jd�dS)Nr()rKr*r(r&rLr?rO)rrFrrrr9$szDeleteCommand.undo)N)r;r<r=rr4r:r9rrrrr)s
r)c@sNeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
dS)r-cCsg|_d|_dS)Nr)�cmds�depth)rrrrr0szCommandSequence.__init__cCsB|jj}g}x|jD]}|jd|f�qW|ddj|�dS)Nz    %rz(
z,
z
))rAr;rXr5�join)rrCZstrsr2rrrrE4s
zCommandSequence.__repr__cCs
t|j�S)N)r0rX)rrrr�__len__;szCommandSequence.__len__cCs|jj|�dS)N)rXr5)rr2rrrr5>szCommandSequence.appendcCs
|j|S)N)rX)r�irrrr1AszCommandSequence.getcmdcCsx|jD]}|j|�qWdS)N)rXr:)rrFr2rrrr:DszCommandSequence.redocCs2|jdd�}|j�x|D]}|j|�qWdS)N)rX�reverser9)rrFrXr2rrrr9Hs
zCommandSequence.undorcCs|j||_|jS)N)rY)rZincrrrrr.NszCommandSequence.bump_depthN)r)r;r<r=rrEr[r5r1r:r9r.rrrrr-,sr-c
sddlm}m}m}ddlm}||�}|jd�tt|j	�j
d�dd��\}}|j	d||df�||d	d
�}|j�|j�||�}	t
��|	j��||d�fdd
�d�}
|
jdd�||d�fdd
�d�}|jdd�||d�fdd
�d�}|jdd�dS)Nr)�Toplevel�Text�Button)�
PercolatorzTest UndoDelegator�+rz+%d+%d��
)ZheightZUndocs
�jd�S)N)rr)�drr�<lambda>bsz!_undo_delegator.<locals>.<lambda>)rFZcommand�left)ZsideZRedocs
�jd�S)N)rr)rerrrfdsZDumpcs
�jd�S)N)r
r)rerrrffs)Ztkinterr^r_r`Zidlelib.percolatorra�title�map�intZgeometry�splitZpackZ	focus_setrZinsertfilter)
�parentr^r_r`raZundowin�x�yrF�pr9r:�dumpr)rer�_undo_delegatorSs$
 
rq�__main__)�mainzidlelib.idle_test.test_undo�F)�	verbosity�exit)�run)rVZidlelib.delegatorrrr>r$r)r-rqr;ZunittestrsZidlelib.idle_test.htestrwrrrr�<module>s-9$'

?>