�
�Wc� c s� � d Z ddlZddlZd� Z G d� d� Zedk r)d� Z ej e� Z e d e
e� � dS dS ) z:Simple textbox editing widget with Emacs-like keybindings.� Nc s� � | j |dz |t j ||z
dz
� | j ||dz t j ||z
dz
� | j ||dz t j ||z
dz
� | j |dz |t j ||z
dz
� | j ||t j � | j ||t j � | j ||t j � | j ||t j � dS )z^Draw a rectangle with corners at the provided upper-left
and lower-right coordinates.
� N)
Zvline�cursesZ ACS_VLINEZhlineZ ACS_HLINE�addchZACS_ULCORNERZACS_URCORNERZACS_LRCORNERZACS_LLCORNER)�win�uly�ulxZlryZlrx� �'/usr/lib64/python3.12/curses/textpad.py� rectangler s
� � �I�I�c�!�e�S�&�*�*�C�#�I��M�:�:��I�I�c�3�q�5�&�*�*�C�#�I��M�:�:��I�I�c�3�q�5�&�*�*�C�#�I��M�:�:��I�I�c�!�e�S�&�*�*�C�#�I��M�:�:��I�I�c�3��+�+�,�,��I�I�c�3��+�+�,�,��I�I�c�3��+�+�,�,��I�I�c�3��+�+�,�,�,�,� c s@ � e Zd ZdZdd�Zd� Zd� Zd� Zd� Zd� Z dd
�Z
d S )
�Textboxad Editing widget using the interior of a window object.
Supports the following Emacs-like key bindings:
Ctrl-A Go to left edge of window.
Ctrl-B Cursor left, wrapping to previous line if appropriate.
Ctrl-D Delete character under cursor.
Ctrl-E Go to right edge (stripspaces off) or end of line (stripspaces on).
Ctrl-F Cursor right, wrapping to next line when appropriate.
Ctrl-G Terminate, returning the window contents.
Ctrl-H Delete character backward.
Ctrl-J Terminate if the window is 1 line, otherwise insert newline.
Ctrl-K If line is blank, delete it, otherwise clear to end of line.
Ctrl-L Refresh screen.
Ctrl-N Cursor down; move down one line.
Ctrl-O Insert a blank line at cursor location.
Ctrl-P Cursor up; move up one line.
Move operations do nothing if the cursor is at an edge where the movement
is not possible. The following synonyms are supported where possible:
KEY_LEFT = Ctrl-B, KEY_RIGHT = Ctrl-F, KEY_UP = Ctrl-P, KEY_DOWN = Ctrl-N
KEY_BACKSPACE = Ctrl-h
Fc s� � || _ || _ | j � d| _ d | _ |j d� d S �Nr )r �insert_mode�_update_max_yx�stripspaces�lastcmdZkeypad)�selfr r
� r �__init__zTextbox.__init__+ s@ � ����&���������������
�
�1�
�
�
�
r
c sj � | j j � \ }}|dz
| _ |dz
| _ d S r )r Zgetmaxyx�maxy�maxx)r r r r r r zTextbox._update_max_yx3 s2 � ��X�X�&�&�(�
��d��1�H�� ��1�H�� � � r
c sJ � | j � | j } t j j | j j ||� � t j j k rt | j |dz � } |S |dk r |S |dz
}��)zuGo to the location of the first blank on the given line,
returning the index of the last non-blank character.Tr r )r r r �asciir �inchZSPZmin)r �yZlastr r �_end_of_linezTextbox._end_of_line8 s� � �
������y�y����|�|�!�!�$�(�(�-�-��4�"8�9�V�\�\�_�_�L�L��4�9�9�d�1�f�-��� �� ������� �!�8�D�
r
c s� � | j � | j j � \ }}d }|| j k s|| j k r�| j
r| j j
� } | j j |� | j
r!t j j � snH|}| j j � \ }}|�||f}|| j k r��|| j k r��|� | j j |� d S d S # t j $ r Y ��w xY w�N)
r r �getyxr r r
r r r Zerrorr �isprint�move)r �chr �xZbackyxZoldch� r �_insert_printable_charzTextbox._insert_printable_charF s0 � �����������!���A����$�)�)�m�m�q�4�9�9�}�}��������
�
���
������r�"�"� �#�#�#�6�<�<�+?�+?��+F�+F���B��X�X�^�^�%�F�Q���~��A���! �$�)�)�m�m��q�4�9�9�}�}��$ ���D�H�H�M�M�6�"�"�"�"� ��� �<�<�
�
�
���
���s �:D+ �+E�Ec sj � | j � | j j � \ }}|| _ t j
j
|� r4|| j k s|| j k r| j |� dS |t j
j k r| j j |d� dS |t j
j t j t j
j t j fv r�|dk r!| j j ||dz
� nq|dk rnj| j r4| j j |dz
| j# |dz
� � n*| j j |dz
| j � |t j
j t j fv r| j j% � dS |t j
j&