shell bypass 403
�
Tf� � �h � d Z ddlmZ G d� d� � Zedk rddlmZ eddd �
� � dS dS )z9Implement Idle Shell history mechanism with History class� )�idleConfc �0 � e Zd ZdZd� Zd� Zd� Zd� Zd� ZdS )�Historya@ Implement Idle Shell history mechanism.
store - Store source statement (called from pyshell.resetoutput).
fetch - Fetch stored statement matching prefix already entered.
history_next - Bound to <<history-next>> event (default Alt-N).
history_prev - Bound to <<history-prev>> event (default Alt-P).
c �� � || _ g | _ d| _ d| _ t j ddddd� � | _ |� d| j � � |� d| j � � dS ) ad Initialize data attributes and bind event methods.
.text - Idle wrapper of tk Text widget, with .bell().
.history - source statements, possibly with multiple lines.
.prefix - source already entered at prompt; filters history list.
.pointer - index into history.
.cyclic - wrap around history list (or not).
N�mainr �cyclic� �boolz<<history-previous>>z<<history-next>>)
�text�history�prefix�pointerr � GetOptionr �bind�history_prev�history_next)�selfr s �8/usr/local/python-3.11/lib/python3.11/idlelib/history.py�__init__zHistory.__init__ sp � � �� �����������(���H�a��P�P���� � �(�$�*;�<�<�<�� � �$�d�&7�8�8�8�8�8� c �2 � | � d�� � dS )z5Fetch later statement; start with earliest if cyclic.F��reverse�break��fetch�r �events r r zHistory.history_next s � ��
�
�5�
�!�!�!��wr c �2 � | � d�� � dS )z0Fetch earlier statement; start with most recent.Tr r r r s r r zHistory.history_prev$ s � ��
�
�4�
� � � ��wr c �T � t | j � � }| j }| j }|�g|�e| j � ddd� � s*| j � dd� � | j | k rdx}}| j � dd� � |�|�E| j � dd� � }|r|}n%| j rd}n| j � � � dS t |� � } ||rdndz
}|d k s||k r�| j � � � | j s|d k rdS | j � dd� � |k r7| j �
dd� � | j � d|d
� � dx}}ng| j | }|d|� |k rKt |� � |k r8| j �
dd� � | j � d|d
� � n��| j � d� � | j �
ddd
� � || _ || _ dS )a+ Fetch statement and replace current line in text widget.
Set prefix and pointer as needed for successive fetches.
Reset them to None, None when returning to the start line.
Sound bell when return to start line or cannot leave a line
because cyclic is False.
N�insertz!=zend-1c�iomark���Tr r �stdin�selz1.0�end)�lenr r r
r �compare�get�mark_setr �bell�deleter! �see�
tag_remove)r r �nhistr r
�nprefix�items r r z
History.fetch) sE � � �D�L�!�!���,�������6�#5��y� � ��4��:�:�
7��I�M�M�(�H�5�5���g�9N�N�N�#'�'��&�� �"�"�8�X�6�6�6��?�f�n��Y�]�]�8�X�6�6�F��
�����;� � �G�G��I�N�N�$�$�$��F��f�+�+�� ��W�+�r�r�!�+�G���{�{�g��.�.�� ��� � � ��{� ,�w��{�{��F��y�}�}�X�x�8�8�F�B�B�� �(�(��8�<�<�<�� �(�(��6�7�C�C�C�'+�+�G�f���<��(�D��H�W�H�~��'�'�C��I�I��,?�,?�� � � ��8�4�4�4�� � � ��4��9�9�9��! �"