ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python34/lib64/python3.4/curses/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python34/lib64/python3.4/curses/__pycache__/textpad.cpython-34.pyc

�
i f��@s~dZddlZddlZdd�ZGdd�d�Zedkrzdd	�Zeje�Ze	d
e
e��ndS)z:Simple textbox editing widget with Emacs-like keybindings.�NcCs�|j|d|tj||d�|j||dtj||d�|j||dtj||d�|j|d|tj||d�|j||tj�|j||tj�|j||tj�|j||tj	�dS)z^Draw a rectangle with corners at the provided upper-left
    and lower-right coordinates.
    �N)
Zvline�cursesZ	ACS_VLINEZhlineZ	ACS_HLINE�addchZACS_ULCORNERZACS_URCORNERZACS_LRCORNERZACS_LLCORNER)�win�uly�ulxZlryZlrx�r�3/opt/alt/python34/lib64/python3.4/curses/textpad.py�	rectangles%%%%r
c@sdeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
dd�Z	d
S)�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
    FcCsm||_||_|j�\|_|_|jd|_|jd|_d|_d|_|jd�dS)Nr)r�insert_modeZgetmaxyx�maxy�maxx�stripspaces�lastcmdZkeypad)�selfrrrrr	�__init__+s				zTextbox.__init__cCsu|j}xetjj|jj||��tjjkrSt|j|d�}Pn|dkrcPn|d}qW|S)zuGo to the location of the first blank on the given line,
        returning the index of the last non-blank character.rr)rr�asciir�inchZSP�min)r�y�lastrrr	�_end_of_line5s	-zTextbox._end_of_linecCs�|jj�\}}||jks3||jkr�|jrN|jj�}ny|jj|�Wntjk
ryYnX|jr�|jj�\}}tj	j
|�r�|j|�|jj||�q�q�ndS)N)
r�getyxr
rrrrr�errorr�isprint�_insert_printable_char�move)r�chr�xZoldchZbackyZbackxrrr	rBs		
zTextbox._insert_printable_charcCse|jj�\}}||_tjj|�ra||jksN||jkra|j|�qan|tjj	kr�|jj
|d�n�|tjjtjtjj
tjfkr`|dkr�|jj
||d�nY|dkr�nJ|jr|jj
|d|j|d��n|jj
|d|j�|tjj
tjfkra|jj�qan|tjjkr�|jj�n�|tjjkr�|jr�|jj
||j|��qa|jj
||j�n�|tjjtjfkrE||jkr|jj
||d�qa||jkr+qa|jj
|dd�n|tjjkr[dS|tjjkr�|jdkr�dS||jkra|jj
|dd�qan�|tjjkr|dkr�|j|�dkr�|jj�qa|jj
||�|jj�nO|tjjkr4|jj�n-|tjjtjfkr�||jkra|jj
|d|�||j|d�kr�|jj
|d|j|d��q�qan�|tjjkr�|jj �n�|tjj!tj"fkra|dkra|jj
|d|�||j|d�kr^|jj
|d|j|d��q^qandS)z!Process a single editing command.rr)#rrrrrrr
rrZSOHrZSTXZKEY_LEFTZBSZ
KEY_BACKSPACErrZdelchZEOTZENQZACKZ	KEY_RIGHTZBEL�NLZVTZdeletelnZclrtoeolZFF�refresh�SOZKEY_DOWNZSIZinsertlnZDLEZKEY_UP)rrrrrrr	�
do_commandTsp	*	'	!--zTextbox.do_commandcCs�d}x�t|jd�D]�}|jj|d�|j|�}|dkr]|jr]qnx_t|jd�D]J}|jr�||kr�Pn|ttj	j	|jj
||���}qqW|jdkr|d}qqW|S)z.Collect and return the contents of the window.�rr�
)�ranger
rrrrr�chrrrr)r�resultr�stoprrrr	�gather�s/zTextbox.gatherNcCsaxT|jj�}|r'||�}n|s3qn|j|�sFPn|jj�qW|j�S)z2Edit in the widget window and collect the results.)rZgetchr#r!r*)rZvalidaterrrr	�edit�szTextbox.edit)
�__name__�
__module__�__qualname__�__doc__rrrr#r*r+rrrr	rs

@r�__main__cCs�d\}}d	\}}|j|d|d�tj||||�}t||d|d||||�|j�t|�j�S)
N�	����zUse Ctrl-G to end editing.r)r1r2)r3r4)ZaddstrrZnewwinr
r!rr+)ZstdscrZncolsZnlinesrrrrrr	�test_editbox�s&
r6zContents of text box:)r/rZcurses.asciir
rr,r6�wrapper�str�print�reprrrrr	�<module>s
�	

Zerion Mini Shell 1.0