ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python37/lib64/python3.7/idlelib/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python37/lib64/python3.7/idlelib/__pycache__/undo.cpython-37.pyc

B

� 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�ZdZdd�Z
d#dd�Zd$dd�Zdd�Zdd�Zd%dd�Zdd �Zd!d"�ZdS)&�
UndoDelegatori�cCst�|�|��dS)N)r�__init__�
reset_undo)�self�r�1/opt/alt/python37/lib64/python3.7/idlelib/undo.pyrs
zUndoDelegator.__init__cCsj|jdk	r(|�d�|�d�|�d�t�||�|dk	rf|�d|j�|�d|j�|�d|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|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|_|�d�dS)N���r�)�	was_savedrr�	undoblock�	set_saved)rrrrr2s
zUndoDelegator.reset_undocCs&|r|j|_nd|_d|_|��dS)NrF)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*|��}||jkr&||_|jr&|��dS)N)rrr )rZis_savedrrrrKs

zUndoDelegator.check_savedcCs|�t|||��dS)N)�addcmd�
InsertCommand)r�index�chars�tagsrrr�insertRszUndoDelegator.insertcCs|�t||��dS)N)r#�
DeleteCommand)r�index1�index2rrr�deleteUszUndoDelegator.deletecCs |jdkrt�|_|j��dS)Nr)r�CommandSequence�
bump_depth)rrrr�undo_block_startcs
zUndoDelegator.undo_block_startcCsN|j�d�dkrJ|j}d|_t|�dkrJt|�dkr>|�d�}|�|d�dS)Nrrr)rr.�len�getcmdr#)r�cmdrrr�undo_block_stophs
zUndoDelegator.undo_block_stopTcCs�|r|�|j�|jdkr*|j�|�dS|jrX|jdkrX|j|jd}|�|�rXdS|g|j|jd�<|j|jkr|d|_|jd|_t	|j�|j
kr�|jd=|jd|_|jdkr�|jd|_d|_|��dS)NrrrT)�dor	r�appendrrr�mergerr0�max_undor)rr2ZexecuteZlastcmdrrrr#ts(


zUndoDelegator.addcmdcCsP|jdkr|��dS|j|jd}|�|j�|jd|_d|_|��dS)NrrrF)r�bellr�undor	rr)rrr2rrrr�s
zUndoDelegator.undo_eventcCsR|jt|j�kr|��dS|j|j}|�|j�|jd|_d|_|��dS)NrrF)rr0rr8�redor	rr)rrr2rrrr�szUndoDelegator.redo_event)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)Nr)�	__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.|��D]"}|dkr|dkr|�|�||<qW|S)Nr(Zcurrent)Z
mark_namesr%)rrF�marks�namerrr�
save_marks�s
zCommand.save_markscCs&x |��D]\}}|�||�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$NcCst�||d||�dS)N)r>r)rr*r&r'rrrr�szInsertCommand.__init__cCsv|�|�|_|�|j�|_|�|jdd�r6|�d�|_|�|j|j|j�|�d|jt|j�f�|_	|�|�|_
dS)N�>zend-1cz%s+%dc)rIr?r%r*�comparer(r&r'r0r+r@)rrFrrrr4�szInsertCommand.docCs>|�d|j�|�|j|j|j�|�||j�|�d�dS)Nr()rKr*r(r&r'rLr@�see)rrFrrrr:�szInsertCommand.redocCs:|�d|j�|�|j|j�|�||j�|�d�dS)Nr()rKr*r,r+rLr?rO)rrFrrrr9�szInsertCommand.undocCs�|j|jk	rdS|j|jkr dS|j|jkr0dSt|j�dkrBdS|jrh|�|jd�|�|j�krhdS|j|_|j|j|_dS)NFrrT)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)NcCst�|||dd�dS)N)r>r)rr*r+rrrrszDeleteCommand.__init__cCs�|�|�|_|�|j�|_|jr0|�|j�|_n|�|jd�|_|�|jdd�r^|�d�|_|�|j|j�|_|�|j|j�|�|�|_	dS)Nz +1crMzend-1c)
rIr?r%r*r+rN�getr&r,r@)rrFrrrr4szDeleteCommand.docCs:|�d|j�|�|j|j�|�||j�|�d�dS)Nr()rKr*r,r+rLr@rO)rrFrrrr:szDeleteCommand.redocCs:|�d|j�|�|j|j�|�||j�|�d�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]}|�d|f�qW|dd�|�dS)Nz    %rz(
z,
z
))rAr;rXr5�join)rrCZstrsr2rrrrE4s
zCommandSequence.__repr__cCs
t|j�S)N)r0rX)rrrr�__len__;szCommandSequence.__len__cCs|j�|�dS)N)rXr5)rr2rrrr5>szCommandSequence.appendcCs
|j|S)N)rX)r�irrrr1AszCommandSequence.getcmdcCsx|jD]}|�|�qWdS)N)rXr:)rrFr2rrrr:DszCommandSequence.redocCs2|jdd�}|��x|D]}|�|�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}||�}|�d�tt|�	��
d�dd��\}}|�	d||df�||d	d
�}|��|��||�}	t
��|	���||d�fdd
�d�}
|
jdd�||d�fdd
�d�}|jdd�||d�fdd
�d�}|jdd�dS)Nr)�Toplevel�Text�Button)�
PercolatorzTest UndoDelegator�+rz+%d+%d��
)ZheightZUndocs
��d�S)N)rr)�drr�<lambda>b�z!_undo_delegator.<locals>.<lambda>)rFZcommand�left)ZsideZRedocs
��d�S)N)rr)rerrrfdrgZDumpcs
��d�S)N)r
r)rerrrffrg)Ztkinterr^r_r`Zidlelib.percolatorra�title�map�intZgeometry�splitZpackZ	focus_setrZinsertfilter)
�parentr^r_r`raZundowin�x�yrF�pr9r:�dumpr)rer�_undo_delegatorSs$
 
rr�__main__)�mainzidlelib.idle_test.test_undo�F)�	verbosity�exit)�run)rVZidlelib.delegatorrrr>r$r)r-rrr;ZunittestrtZidlelib.idle_test.htestrxrrrr�<module>s-9$'

Zerion Mini Shell 1.0