Your IP : 3.142.130.127


Current Path : /opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/idlelib/__pycache__/UndoDelegator.cpython-35.opt-2.pyc



���]�*�@s�ddlZddlTddlmZGdd�de�ZGdd�d�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�Zdd�Z	e
dkr�ddlZejddddd�ddl
mZee	�dS)�N)�*)�	Delegatorc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dZ
dd�Zd#Zdd�Z
ddd�Zddd�Zdd�Zdd�Zddd�Zdd �Zd!d"�ZdS)$�
UndoDelegatori�cCstj|�|j�dS)N)r�__init__�
reset_undo)�self�r�2/opt/alt/python35/lib64/python3.5/UndoDelegator.pyrs
zUndoDelegator.__init__cCs�|jdk	r6|jd�|jd�|jd�tj||�|dk	r�|jd|j�|jd|j�|jd|j�dS)Nz<<undo>>z<<redo>>z<<dump-undo-state>>)�delegateZunbindr�setdelegate�bind�
undo_event�
redo_event�
dump_event)rr
rrr	rs


zUndoDelegator.setdelegatecCs�ddlm}||jd|j��td|jdd�td|jdd�td|jdd�td|j��||j|jd��d	S)
Nr)�pprintzpointer:�end� zsaved:z
can_merge:zget_saved():�break)r�undolist�pointer�print�saved�	can_merge�	get_saved)r�eventrrrr	r&szUndoDelegator.dump_eventcCs5d|_d|_g|_d|_|jd�dS)N�r���)�	was_savedrr�	undoblock�	set_saved)rrrr	r0s
				zUndoDelegator.reset_undocCs5|r|j|_n	d|_d|_|j�dS)NrFr)rrr�check_saved)r�flagrrr	r7s
		zUndoDelegator.set_savedcCs|j|jkS)N)rr)rrrr	r?szUndoDelegator.get_savedNcCs
||_dS)N)�saved_change_hook)r�hookrrr	�set_saved_change_hookDsz#UndoDelegator.set_saved_change_hookrcCs;|j�}||jkr7||_|jr7|j�dS)N)rrr")rZis_savedrrr	r Is
		zUndoDelegator.check_savedcCs|jt|||��dS)N)�addcmd�
InsertCommand)r�index�chars�tagsrrr	�insertPszUndoDelegator.insertcCs|jt||��dS)N)r%�
DeleteCommand)r�index1�index2rrr	�deleteSszUndoDelegator.deletecCs,|jdkrt�|_|jj�dS)Nr)r�CommandSequence�
bump_depth)rrrr	�undo_block_startaszUndoDelegator.undo_block_startcCsq|jjd�dkrm|j}d|_t|�dkrmt|�dkr]|jd�}|j|d�dS)Nrrr)rr0�len�getcmdr%)r�cmdrrr	�undo_block_stopfs		zUndoDelegator.undo_block_stopTcCs$|r|j|j�|jdkr9|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�mergerr2�max_undor )rr4ZexecuteZlastcmdrrr	r%rs(	
	zUndoDelegator.addcmdcCsh|jdkr|j�dS|j|jd}|j|j�|jd|_d|_|j�dS)NrrrF)r�bellr�undor
rr )rrr4rrr	r
�s
	
zUndoDelegator.undo_eventcCsm|jt|j�kr&|j�dS|j|j}|j|j�|jd|_d|_|j�dS)NrrF)rr2rr:�redor
rr )rrr4rrr	r�s
	
zUndoDelegator.redo_eventr)�__name__�
__module__�__qualname__r9rrrrrrr"r$rr r*r.r1r5r%r
rrrrr	rs$
rc@syeZdZdZddd�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)rrr	r�s					zCommand.__init__cCsW|jj}|j|j|j|jf}|jdkrI|dd�}|t|�S)Nrr)�	__class__r=r,r-r(r)�repr)r�s�trrr	�__repr__�s
zCommand.__repr__cCsdS)Nr)r�textrrr	r6�sz
Command.docCsdS)Nr)rrHrrr	r<�szCommand.redocCsdS)Nr)rrHrrr	r;�szCommand.undocCsdS)Nrr)rr4rrr	r8�sz
Command.mergecCsLi}x?|j�D]1}|dkr|dkr|j|�||<qW|S)Nr*�current)Z
mark_namesr')rrH�marks�namerrr	�
save_marks�s
zCommand.save_markscCs1x*|j�D]\}}|j||�q
WdS)N)�items�mark_set)rrHrJrKr'rrr	�	set_marks�szCommand.set_marks)r=r>r?r)rrGr6r<r;r8rLrOrrrr	r@�s	r@c@soeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zej	ej
dZd
d�ZdS)r&NcCstj||d||�dS)N)r@r)rr,r(r)rrr	r�szInsertCommand.__init__cCs�|j|�|_|j|j�|_|j|jdd�rQ|jd�|_|j|j|j|j�|jd|jt|j�f�|_	|j|�|_
dS)N�>zend-1cz%s+%dc)rLrAr'r,�comparer*r(r)r2r-rB)rrHrrr	r6�s(zInsertCommand.docCsS|jd|j�|j|j|j|j�|j||j�|jd�dS)Nr*)rNr,r*r(r)rOrB�see)rrHrrr	r<�szInsertCommand.redocCsM|jd|j�|j|j|j�|j||j�|jd�dS)Nr*)rNr,r.r-rOrArR)rrHrrr	r;�szInsertCommand.undocCs�|j|jk	rdS|j|jkr,dS|j|jkrBdSt|j�dkr[dS|jr�|j|jd�|j|j�kr�dS|j|_|j|j|_dS)NFrTr)rCr-r,r)r2r(�classify)rr4rrr	r8�s	(zInsertCommand.merge�_cCs'||jkrdS|dkr#dSdS)N�alphanumeric�
�newline�punctuation)rU)r�crrr	rSs
zInsertCommand.classify)
r=r>r?rr6r<r;r8�string�
ascii_letters�digitsrUrSrrrr	r&�sr&c@sCeZdZddd�Zdd�Zdd�Zdd	�ZdS)
r+NcCstj|||dd�dS)N)r@r)rr,r-rrr	rszDeleteCommand.__init__cCs�|j|�|_|j|j�|_|jrH|j|j�|_n|j|jd�|_|j|jdd�r�|jd�|_|j|j|j�|_|j|j|j�|j|�|_	dS)Nz +1crPzend-1c)
rLrAr'r,r-rQ�getr(r.rB)rrHrrr	r6s	zDeleteCommand.docCsM|jd|j�|j|j|j�|j||j�|jd�dS)Nr*)rNr,r.r-rOrBrR)rrHrrr	r<szDeleteCommand.redocCsM|jd|j�|j|j|j�|j||j�|jd�dS)Nr*)rNr,r*r(rOrArR)rrHrrr	r;%szDeleteCommand.undo)r=r>r?rr6r<r;rrrr	r+sr+c@sseZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
dS)r/cCsg|_d|_dS)Nr)�cmds�depth)rrrr	r1s	zCommandSequence.__init__cCsS|jj}g}x%|jD]}|jd|f�qW|ddj|�dS)Nz    %rz(
z,
z
))rCr=r^r7�join)rrEZstrsr4rrr	rG5s
zCommandSequence.__repr__cCs
t|j�S)N)r2r^)rrrr	�__len__<szCommandSequence.__len__cCs|jj|�dS)N)r^r7)rr4rrr	r7?szCommandSequence.appendcCs|j|S)N)r^)r�irrr	r3BszCommandSequence.getcmdcCs%x|jD]}|j|�q
WdS)N)r^r<)rrHr4rrr	r<EszCommandSequence.redocCs?|jdd�}|j�x|D]}|j|�q$WdS)N)r^�reverser;)rrHr^r4rrr	r;Is

zCommandSequence.undorcCs|j||_|jS)N)r_)rZincrrrr	r0OszCommandSequence.bump_depthN)r=r>r?rrGrar7r3r<r;r0rrrr	r/,sr/cswddl}ddl}ddlm}|j�}|jd�ttt|j	d|j
����\}}}}|j
d||df�t|dd�}	|	j�|	j
�||	�}
t��|
j��t|d	d
d�fdd
��}|jdd�t|d	dd�fdd
��}|jdd�t|d	dd�fdd
��}
|
jdd�dS)Nr)�
PercolatorzTest UndoDelegatorz[x+]z+%d+%d��height�
rHZUndoZcommandcs
�jd�S)N)r
r)�drr	�<lambda>dsz!_undo_delegator.<locals>.<lambda>Zside�leftZRedocs
�jd�S)N)rr)rhrr	rifsZDumpcs
�jd�S)N)rr)rhrr	rihs)�re�tkinterZidlelib.PercolatorrdZToplevel�title�list�map�int�splitZgeometryZText�packZ	focus_setrZinsertfilterZButton)�parentrkZtkrdZundowin�widthrf�x�yrH�pr;r<�dumpr)rhr	�_undo_delegatorTs&
3

	
$$$ry�__main__z$idlelib.idle_test.test_undodelegator�	verbosity��exitF)�run)rZrlZidlelib.Delegatorrrr@r&r+r/ryr=Zunittest�mainZidlelib.idle_test.htestr~rrrr	�<module>s
�.:$(

?>