AlkantarClanX12

Your IP : 18.216.99.18


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



��Yf�*�@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�:/opt/alt/python35/lib64/python3.5/idlelib/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�setdelegateZbind�
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)rZflagrrr	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	rIs
		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)rr.�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�mergerr0�max_undor)rr2ZexecuteZlastcmdrrr	r#rs(	
	zUndoDelegator.addcmdcCsh|jdkr|j�dS|j|jd}|j|j�|jd|_d|_|j�dS)NrrrF)r�bellr�undor
rr)rrr2rrr	r�s
	
zUndoDelegator.undo_eventcCsm|jt|j�kr&|j�dS|j|j}|j|j�|jd|_d|_|j�dS)NrrF)rr0rr8�redor
rr)rrr2rrr	r
�s
	
zUndoDelegator.redo_eventr)�__name__�
__module__�__qualname__r7rrrrrrr r"rrr(r,r/r3r#rr
rrrr	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	r4�sz
Command.docCsdS)Nr)rrFrrr	r:�szCommand.redocCsdS)Nr)rrFrrr	r9�szCommand.undocCsdS)Nrr)rr2rrr	r6�sz
Command.mergecCsLi}x?|j�D]1}|dkr|dkr|j|�||<qW|S)Nr(Zcurrent)Z
mark_namesr%)rrF�marks�namerrr	�
save_marks�s
zCommand.save_markscCs1x*|j�D]\}}|j||�q
WdS)N)�items�mark_set)rrFrGrHr%rrr	�	set_marks�szCommand.set_marks)r;r<r=r'rrEr4r:r9r6rIrLrrrr	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)rIr?r%r*�comparer(r&r'r0r+r@)rrFrrr	r4�s(zInsertCommand.docCsS|jd|j�|j|j|j|j�|j||j�|jd�dS)Nr()rKr*r(r&r'rLr@�see)rrFrrr	r:�szInsertCommand.redocCsM|jd|j�|j|j|j�|j||j�|jd�dS)Nr()rKr*r,r+rLr?rO)rrFrrr	r9�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)rAr+r*r'r0r&�classify)rr2rrr	r6�s	(zInsertCommand.merge�_cCs'||jkrdS|dkr#dSdS)N�alphanumeric�
�newlineZpunctuation)rR)r�crrr	rPs
zInsertCommand.classify)
r;r<r=rr4r:r9r6�stringZ
ascii_lettersZdigitsrRrPrrrr	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 +1crMzend-1c)
rIr?r%r*r+rN�getr&r,r@)rrFrrr	r4s	zDeleteCommand.docCsM|jd|j�|j|j|j�|j||j�|jd�dS)Nr()rKr*r,r+rLr@rO)rrFrrr	r:szDeleteCommand.redocCsM|jd|j�|j|j|j�|j||j�|jd�dS)Nr()rKr*r(r&rLr?rO)rrFrrr	r9%szDeleteCommand.undo)r;r<r=rr4r:r9rrrr	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
))rAr;rXr5�join)rrCZstrsr2rrr	rE5s
zCommandSequence.__repr__cCs
t|j�S)N)r0rX)rrrr	�__len__<szCommandSequence.__len__cCs|jj|�dS)N)rXr5)rr2rrr	r5?szCommandSequence.appendcCs|j|S)N)rX)r�irrr	r1BszCommandSequence.getcmdcCs%x|jD]}|j|�q
WdS)N)rXr:)rrFr2rrr	r:EszCommandSequence.redocCs?|jdd�}|j�x|D]}|j|�q$WdS)N)rX�reverser9)rrFrXr2rrr	r9Is

zCommandSequence.undorcCs|j||_|jS)N)rY)rZincrrrr	r.OszCommandSequence.bump_depthN)r;r<r=rrEr[r5r1r:r9r.rrrr	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�
rFZUndoZcommandcs
�jd�S)N)rr)�drr	�<lambda>dsz!_undo_delegator.<locals>.<lambda>Zside�leftZRedocs
�jd�S)N)r
r)rbrr	rcfsZDumpcs
�jd�S)N)rr)rbrr	rchs)�re�tkinterZidlelib.Percolatorr^ZToplevel�title�list�map�int�splitZgeometryZTextZpackZ	focus_setrZinsertfilterZButton)�parentreZtkr^Zundowin�widthr`�x�yrF�pr9r:�dumpr)rbr	�_undo_delegatorTs&
3

	
$$$rr�__main__z$idlelib.idle_test.test_undodelegator�	verbosity��exitF)�run)rVrfZidlelib.Delegatorrrr>r$r)r-rrr;Zunittest�mainZidlelib.idle_test.htestrwrrrr	�<module>s
�.:$(