a
    }Œ@hÕ  ã                   @   s^   d Z ddlmZ ddlmZ dd„ ZG dd„ dƒZe ¡  edkrZdd	l	Z	e	j
d
ddd� d	S )zœExample extension, also used for testing.

See extend.txt for more details on creating an extension.
See config-extension.def for configuring an extension.
é    )ÚidleConf©Úwrapsc                    s   t ˆ ƒd‡ fdd„	ƒ}|S )z9Apply a formatting function to all of the selected lines.Nc                    sT   | j  ¡ \}}}}tt|ƒd ƒD ]}|| }ˆ | |ƒ||< q"| j  ||||¡ dS )Né   Úbreak)Ú	formatterZ
get_regionÚrangeÚlenZ
set_region)ÚselfZeventÚheadÚtailÚcharsÚlinesÚposÚline©Úformat_line© ú lib/python3.9/idlelib/zzdummy.pyÚapply   s    zformat_selection.<locals>.apply)Nr   )r   r   r   r   r   Úformat_selection   s    r   c                   @   sJ   e Zd ZdZdddgfgZdd„ Zedd„ ƒZed	d
„ ƒZ	edd„ ƒZ
dS )ÚZzDummyz3Prepend or remove initial text from selected lines.Úformat)zZ inz<<z-in>>)zZ outz	<<z-out>>c                 C   s   || _ |j| _|j| _dS )z+Initialize the settings for this extension.N)ÚeditwinÚtextZfregionr   )r
   r   r   r   r   Ú__init__%   s    zZzDummy.__init__c                 C   s   t  ddd¡| _dS )z!Load class variables from config.Ú
extensionsr   zz-textN)r   Z	GetOptionÚztext)Úclsr   r   r   Úreload+   s    zZzDummy.reloadc                 C   s   | j › |› �S )z™Insert text at the beginning of each selected line.

        This is bound to the <<z-in>> virtual event when the extensions
        are loaded.
        )r   )r
   r   r   r   r   Ú
z_in_event0   s    zZzDummy.z_in_eventc                 C   s&   |  | j¡sdnt| jƒ}||d… S )z¥Remove specific text from the beginning of each selected line.

        This is bound to the <<z-out>> virtual event when the extensions
        are loaded.
        r   N)Ú
startswithr   r	   )r
   r   Zzlengthr   r   r   Úz_out_event9   s    zZzDummy.z_out_eventN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Zmenudefsr   Úclassmethodr   r   r    r"   r   r   r   r   r      s   þÿ

r   Ú__main__Nzidlelib.idle_test.test_zzdummyé   F)Ú	verbosityÚexit)r&   Zidlelib.configr   Ú	functoolsr   r   r   r   r#   ZunittestÚmainr   r   r   r   Ú<module>   s   *