a
    ze                     @   s@   d dl mZ G dd dZedkr<d dlmZ edddd	 d
S )    )idleConfc                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )Historyc                 C   sL   || _ g | _d | _d | _tddddd| _|d| j |d| j	 d S )Nmainr   cyclic   boolz<<history-previous>>z<<history-next>>)
texthistoryprefixpointerr   Z	GetOptionr   bindhistory_prevhistory_next)selfr    r   %/usr/lib/python3.9/idlelib/history.py__init__   s    	zHistory.__init__c                 C   s   | j dd dS )NFreversebreakfetchr   eventr   r   r   r      s    zHistory.history_nextc                 C   s   | j dd dS )NTr   r   r   r   r   r   r   r   $   s    zHistory.history_prevc                 C   s  t | j}| j}| j}|d urd|d urd| jdddsN| jdd| j| krdd  }}| jdd |d u st|d u r| jdd}|r|}n| jrd}n| j	  d S t |}||rdnd7 }|dk s||kr(| j	  | js|dk rd S | jdd|kr| j
dd | jd| d  }}qp| j| }|d | |krt ||kr| j
dd | jd| qpq| jd | jdd	d
 || _|| _d S )Ninsertz!=zend-1cZiomarkr   r   Zselz1.0end)lenr	   r   r
   r   ZcomparegetZmark_setr   Zbelldeleter   ZseeZ
tag_remove)r   r   Znhistr   r
   Znprefixitemr   r   r   r   )   sJ    



zHistory.fetchc                 C   sT   |  }t|dkrDz| j| W n ty6   Y n0 | j| d | _d | _d S )N   )stripr   r	   remove
ValueErrorappendr   r
   )r   sourcer   r   r   storeZ   s    zHistory.storeN)__name__
__module____qualname__r   r   r   r   r'   r   r   r   r   r      s
   1r   __main__)r   zidlelib.idle_test.test_historyr!   F)	verbosityexitN)Zidlelib.configr   r   r(   Zunittestr   r   r   r   r   <module>   s   b