Edit File: textpad.cpython-38.pyc
U ����@��d�����������������������@���sV���d�Z�ddlZddlZdd��ZG�dd��d�ZedkrRdd ��Ze�e�Ze d e e���dS�)z:Simple textbox editing widget with Emacs-like keybindings.�����Nc�����������������C���s����|���|d�|tj||�d���|��||d�tj||�d���|��||d�tj||�d���|���|d�|tj||�d���|��||tj��|��||tj��|��||tj��|��||tj ��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��r����3/opt/alt/python38/lib64/python3.8/curses/textpad.py� rectangle���s����r ���c�������������������@���sL���e�Zd�ZdZddd�Zdd��Zdd��Zd d ��Zdd��Zd d��Z ddd�Z dS�)�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�����������������C���s.���||�_�||�_|�����d|�_d�|�_|�d��d�S��Nr���)r����insert_mode�_update_max_yx�stripspaces�lastcmdZkeypad)�selfr���r ���r���r���r ����__init__+���s����zTextbox.__init__c�����������������C���s&���|�j����\}}|d�|�_|d�|�_d�S�r���)r���Zgetmaxyx�maxy�maxx)r���r���r���r���r���r ���r���3���s���� zTextbox._update_max_yxc�����������������C���sX���|������|�j}tj�|�j�||��tjjkr@t|�j|d��}qTn |dkrJqT|d�}q|S�)zuGo to the location of the first blank on the given line, returning the index of the last non-blank character.r���r���)r���r���r����asciir����inchZSP�min)r����yZlastr���r���r ����_end_of_line8���s���� zTextbox._end_of_linec�����������������C���s����|������|�j���\}}d�}||�jk�s.||�jk�r�|�jr>|�j���}z|�j�|��W�n�tj k rd���Y�nX�|�jr�tj �|�szq�|}|�j���\}}|d�kr||f}q|d�k r�|�jj|���d�S�)N) r���r����getyxr���r���r ���r���r���r����errorr����isprint�move)r����chr����xZbackyxZoldchr���r���r ����_insert_printable_charF���s$���� zTextbox._insert_printable_charc�����������������C���sV��|������|�j���\}}||�_tj�|�rJ||�jk�s<||�jk�rF|�� |���n|tjj krh|�j�|d���n�|tjjtj tjjtjfk�r|dkr�|�j�||d���nB|dkr�n8|�jr�|�j�|d�|��|d����n|�j�|d�|�j��|tjjtjfk�rR|�j�����nL|tjjk�r"|�j�����n0|tjjk�rb|�j�rN|�j�||��|���n|�j�||�j���n�|tjjtjfk�r�||�jk��r�|�j�||d���n ||�jk�r�n|�j�|d�d���n�|tjjk�r�dS�|tjjk�r|�jdk�r�dS�||�jk��rR|�j�|d�d���nF|tjjk�rZ|dk�r@|��|�dk�r@|�j����n|�j�||��|�j����n�|tjjk�rt|�j����n�|tjjtjfk�r�||�jk��rR|�j�|d�|��||��|d��k�rR|�j�|d�|��|d����nz|tjj k�r�|�j�!���n`|tjj"tj#fk�rR|dk�rR|�j�|d�|��||��|d��k�rR|�j�|d�|��|d����dS�)z!Process a single editing command.r���r���)$r���r���r���r���r���r���r���r���r���r ���ZSOHr���ZSTXZKEY_LEFTZBSZ KEY_BACKSPACEr���r���ZdelchZEOTZENQZACKZ KEY_RIGHTZBEL�NLZVTZdeletelnZclrtoeolZFF�refreshZSOZKEY_DOWNZSIZinsertlnZDLEZKEY_UP)r���r���r���r���r���r���r ���� do_command_���sr���� zTextbox.do_commandc�������������� ���C���s����d}|������t|�jd��D�]�}|�j�|d��|��|�}|dkrF|�jrFqt|�jd��D�]4}|�jrj||krj�q�|tt j � |�j�||����}qT|�jdkr|d�}q|S�)z.Collect and return the contents of the window.��r���r���� )r����ranger���r���r���r���r���r����chrr���r���r���)r����resultr����stopr���r���r���r ����gather����s���� zTextbox.gatherNc�����������������C���s<���|�j����}|r||�}|sq�|��|�s(q4|�j�����q�|����S�)z2Edit in the widget window and collect the results.)r���Zgetchr#���r"���r*���)r���Zvalidater���r���r���r ����edit����s���� zTextbox.edit)F)N)�__name__� __module__�__qualname__�__doc__r���r���r���r ���r#���r*���r+���r���r���r���r ���r������s��� Ar����__main__c�����������������C���sf���d\}}d\}}|���|d�|d��t�||||�}t|�|d�|d�||�||���|�����t|����S�)N)� �������)������������zUse Ctrl-G to end editing.r���)Zaddstrr���Znewwinr ���r"���r���r+���)ZstdscrZncolsZnlinesr���r���r���r���r���r ����test_editbox����s���� r6���zContents of text box:)r/���r���Zcurses.asciir ���r���r,���r6����wrapper�str�print�reprr���r���r���r ����<module>���s��� �,