a
    If                     @   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 )zExample 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 )zInsert 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 )zRemove 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   *