Your IP : 52.14.234.146


Current Path : /opt/alt/python312/lib64/python3.12/curses/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/curses/__pycache__/textpad.cpython-312.pyc

�

�Q�fJ���dZddlZddlZd�ZGd�d�Zedk(r%d�Zeje�Ze	de
e��yy)	z:Simple textbox editing widget with Emacs-like keybindings.�Nc�d�|j|dz|tj||z
dz
�|j||dztj||z
dz
�|j||dztj||z
dz
�|j|dz|tj||z
dz
�|j||tj�|j||tj�|j||tj�|j||tj�y)z^Draw a rectangle with corners at the provided upper-left
    and lower-right coordinates.
    �N)
�vline�curses�	ACS_VLINE�hline�	ACS_HLINE�addch�ACS_ULCORNER�ACS_URCORNER�ACS_LRCORNER�ACS_LLCORNER)�win�uly�ulx�lry�lrxs     �5/opt/alt/python312/lib64/python3.12/curses/textpad.py�	rectanglers����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�>�eZdZdZd
d�Zd�Zd�Zd�Zd�Zd�Z	dd	�Z
y)�TextboxadEditing 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
    c�~�||_||_|j�d|_d|_|jd�y�Nr)r�insert_mode�_update_max_yx�stripspaces�lastcmd�keypad)�selfrrs   r�__init__zTextbox.__init__+s7�����&��������������
�
�1�
rc�f�|jj�\}}|dz
|_|dz
|_yr)r�getmaxyx�maxy�maxx)r r$r%s   rrzTextbox._update_max_yx3s.���X�X�&�&�(�
��d��1�H��	��1�H��	rc�8�|j�|j}	tjj|jj||��tjjk7rt|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.rr)rr%r�asciir�inch�SP�min)r �y�lasts   r�_end_of_linezTextbox._end_of_line8s���	
�����y�y����|�|�!�!�$�(�(�-�-��4�"8�9�V�\�\�_�_�L��4�9�9�d�1�f�-������������!�8�D�
rc�n�|j�|jj�\}}d}||jks||jkr�|j
r|jj
�}	|jj|�|j
rtjj�snE|}|jj�\}}|�||f}||jkr��||jkr��|�|jj|�yy#tj$rY��wxYw�N)
rr�getyxr$r%rr(r
r�errorr'�isprint�move)r �chr+�x�backyx�oldchs      r�_insert_printable_charzTextbox._insert_printable_charFs������������!���A����$�)�)�m�q�4�9�9�}�������
�
���
������r�"��#�#�6�<�<�+?�+?��+F���B��X�X�^�^�%�F�Q���~��A���!�$�)�)�m�q�4�9�9�}�$���D�H�H�M�M�6�"����<�<�
��
�s�5D�D4�3D4c��|j�|jj�\}}||_tj
j
|�r0||jks||jkr|j|�y|tj
jk(r|jj|d�y|tj
jtjtj
jtjtj
j fvr�|dkDr |jj||dz
�nm|dk(rng|j"r2|jj|dz
|j%|dz
��n)|jj|dz
|j�|tj
jtjtj
j fvr|jj'�y|tj
j(k(r|jj'�y|tj
j*k(r_|j"r,|jj||j%|��y|jj||j�y|tj
j,tj.fvr`||jkr |jj||dz�y||jk(r	y|jj|dzd�y|tj
j0k(ry|tj
j2k(r?|jdk(ry||jkr|jj|dzd�y|tj
j4k(rk|dk(r/|j%|�dk(r|jj7�y|jj||�|jj9�y|tj
j:k(r|jj=�y|tj
j>tj@fvrw||jkrg|jj|dz|�||j%|dz�kDr1|jj|dz|j%|dz��y|tj
jBk(r|jjE�y|tj
jFtjHfvrl|dkDrg|jj|dz
|�||j%|dz
�kDr1|jj|dz
|j%|dz
��y)z!Process a single editing command.rr)%rrr0rrr'r2r$r%r8�SOHr3�STX�KEY_LEFT�BS�
KEY_BACKSPACE�DELrr-�delch�EOT�ENQ�ACK�	KEY_RIGHT�BEL�NL�VT�deleteln�clrtoeol�FF�refresh�SO�KEY_DOWN�SI�insertln�DLE�KEY_UP)r r4r+r5s    r�
do_commandzTextbox.do_command_s������������!���A�����<�<����#��4�9�9�}��D�I�I�
��+�+�B�/�v�u�6�<�<�#�#�
#��H�H�M�M�!�Q��r�q�F�L�L�$�$�V�_�_��L�L�O�O��(�(��L�L�$�$�&�&��1�u����
�
�a��1��%��a����!�!����
�
�a��c�4�#4�#4�Q�q�S�#9�:����
�
�a��c�4�9�9�-��f�l�l�o�o�v�';�';�V�\�\�=M�=M�N�N������ �V�U�6�<�<�#�#�
#��H�H�N�N��R�Q�6�<�<�#�#�
#�������
�
�a��!2�!2�1�!5�6�L�I���
�
�a����+�H�G�F�L�L�$�$�f�&6�&6�7�
7��4�9�9�}����
�
�a��1��%�B�A�d�i�i���>�;���
�
�a��c�1�%�:�9�6�<�<�#�#�
#��
�6�<�<�?�?�
"��y�y�A�~���T�Y�Y�����
�
�a��c�1�%�,�+�6�<�<�?�?�
"��A�v�$�+�+�A�.�!�3����!�!�#�&�!���
�
�a��#����!�!�#���6�<�<�?�?�
"��H�H������F�L�L�O�O�V�_�_�5�
5��4�9�9�}����
�
�a��c�1�%��t�(�(��1��-�-��H�H�M�M�!�A�#�t�'8�'8��1��'=�>���6�<�<�?�?�
"��H�H������F�L�L�$�$�f�m�m�4�
4��1�u����
�
�a��c�1�%��t�(�(��1��-�-��H�H�M�M�!�A�#�t�'8�'8��1��'=�>�rc��d}|j�t|jdz�D]�}|jj	|d�|j|�}|dk(r
|jr�Bt|jdz�D]Z}|jr||kDrnG|ttjj|jj||���z}�\|jdkDs��|dz}��|S)z.Collect and return the contents of the window.�rr�
)r�ranger$rr3r-rr%�chrrr'r()r �resultr+�stopr5s     r�gatherzTextbox.gather�s����������t�y�y��{�#�A��H�H�M�M�!�Q���$�$�Q�'�D��q�y�T�-�-���4�9�9�Q�;�'���#�#��D����#�f�l�l�&8�&8������q�!�9L�&M�"N�N��(��y�y�1�}��$���$��
rNc���	|jj�}|r||�}|s�(|j|�s	|j	�S|jj��d)z2Edit in the widget window and collect the results.)r�getchrRrKrZ)r �validater4s   r�editzTextbox.edit�sY��������!�B���b�\�����?�?�2�&���{�{�}��
�H�H����r)Fr/)�__name__�
__module__�__qualname__�__doc__r!rr-r8rRrZr^�rrrrs,���.��
�#�2B�H�"rr�__main__c��d\}}d\}}|j|dz
|d�tj||||�}t||dz
|dz
||z||z�|j	�t|�j
�S)N)�	�)���zUse Ctrl-G to end editing.r)�addstrr�newwinrrKrr^)�stdscr�ncols�nlinesrrrs      r�test_editboxrp�sz���
��v����S��
�
�c�!�e�S�">�?��m�m�F�E�3��4���&�#�a�%��Q���f��c�E�k�B������s�|� � �"�"rzContents of text box:)rbr�curses.asciirrr_rp�wrapper�str�print�reprrcrr�<module>rvsU��@�
��-�l�l�\�z��#��&�.�.��
&�C�	�
!�4��9�-�r

?>