Your IP : 3.146.65.134


Current Path : /opt/alt/python34/lib64/python3.4/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/idlelib/__pycache__/UndoDelegator.cpython-34.pyc

�
e f?*�@s�ddlZddlTddlmZGdd�de�ZGdd�d�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�Zdd�Z	e
dkr�ddlmZee	�ndS)�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/python34/lib64/python3.4/idlelib/UndoDelegator.pyrs
zUndoDelegator.__init__cCs�|jdk	r9|jd�|jd�|jd�ntj||�|dk	r�|jd|j�|jd|j�|jd|j�ndS)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_hookrcCsA|j�}||jkr=||_|jr=|j�q=ndS)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�|_n|jj�dS)Nr)r�CommandSequence�
bump_depth)rrrr	�undo_block_startaszUndoDelegator.undo_block_startcCsz|jjd�dkrv|j}d|_t|�dkrvt|�dkr`|jd�}n|j|d�qvndS)Nrrr)rr.�len�getcmdr#)r�cmdrrr	�undo_block_stopfs		zUndoDelegator.undo_block_stopTcCs3|r|j|j�n|jdkr<|jj|�dS|jr~|jdkr~|j|jd}|j|�r~dSn|g|j|jd�<|j|jkr�d|_n|jd|_t	|j�|j
kr|jd=|jd|_|jdkr|jd|_qnd|_|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)�CommandNcCsCi|_i|_||_||_||_|r?||_ndS)N)�marks_before�marks_afterr*r+r&r')rr*r+r&r'rrr	r�s					zCommand.__init__cCsZ|jj}|j|j|j|jf}|jdkrL|dd�}n|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.mergecCsOi}xB|j�D]4}|dkr|dkr|j|�||<qqW|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�rT|jd�|_n|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�|_n|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-cspddlm}t�}|jd�ttttjd|j	����\}}}}|j	d||df�t
|�}|jdd�|j�|j
�||�}t��|j��t|d	d
d�fdd
��}	|	jdd�t|d	dd�fdd
��}
|
jdd�t|d	dd�fdd
��}|jdd�|j�dS)Nr)�
PercolatorzTest UndoDelegatorz[x+]z+%d+%d��height�
rFZUndoZcommandcs
�jd�S)N)rr)�drr	�<lambda>bsz!_undo_delegator.<locals>.<lambda>Zside�leftZRedocs
�jd�S)N)r
r)rbrr	rcdsZDumpcs
�jd�S)N)rr)rbrr	rcfs)Zidlelib.Percolatorr^ZTk�title�list�map�int�re�splitZgeometryZText�configZpackZ	focus_setrZinsertfilterZButtonZmainloop)�parentr^�root�widthr`�x�yrF�pr9r:�dumpr)rbr	�_undo_delegatorSs&	
3

	
$$$rs�__main__)�run)
rVZtkinterZidlelib.Delegatorrrr>r$r)r-rsr;Zidlelib.idle_test.htestrurrrr	�<module>s
�.:$'

?>