ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/curses/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/curses/__pycache__/textpad.cpython-35.opt-1.pyc



M�Ma��@s{dZddlZddlZdd�ZGdd�d�Zedkrwdd	�Zeje�Ze	d
e
e��dS)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/python35/lib64/python3.5/curses/textpad.py�	rectangles%%%%r
c@speZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
dS)�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
    FcCs?||_||_|j�d|_d|_|jd�dS)Nr)r�insert_mode�_update_max_yx�stripspaces�lastcmdZkeypad)�selfrrrrr	�__init__+s		
		zTextbox.__init__cCs3|jj�\}}|d|_|d|_dS)Nr)rZgetmaxyx�maxy�maxx)rrrrrr	r
3s
zTextbox._update_max_yxcCs||j�|j}xbtjj|jj||��tjjkr]t|j|d�}Pn
|dkrjP|d}qW|S)zuGo to the location of the first blank on the given line,
        returning the index of the last non-blank character.rr)r
rr�asciir�inchZSP�min)r�yZlastrrr	�_end_of_line8s
	-zTextbox._end_of_linecCs�|j�|jj�\}}d}x�||jksF||jkr�|jr^|jj�}y|jj|�Wntj	k
r�YnX|js�tj
j|�r�P|}|jj�\}}|dkr(||f}q(W|dk	r�|jj|�dS)N)
r
r�getyxrrrrrr�errorr�isprint�move)r�chr�xZbackyxZoldchrrr	�_insert_printable_charFs$
!	zTextbox._insert_printable_charcCsW|j�|jj�\}}||_tjj|�rh||jksX||jkrS|j	|�n�|tjj
kr�|jj|d�n�|tjjtj
tjjtjfkrd|dkr�|jj||d�nY|dkr�nJ|jr|jj|d|j|d��n|jj|d|j�|tjjtjfkrS|jj�n�|tjjkr�|jj�n�|tjjkr�|jr�|jj||j|��qS|jj||j�nz|tjjtjfkrI||jkr|jj||d�qS||jkr/qS|jj|dd�n
|tjjkr_dS|tjjkr�|jdkr�dS||jkrS|jj|dd�n�|tjjkr|dkr�|j|�dkr�|jj�qS|jj||�|jj�n@|tjjkr5|jj�n|tjjtjfkr�||jkrS|jj|d|�||j|d�krS|jj|d|j|d��n�|tjj kr�|jj!�n{|tjj"tj#fkrS|dkrS|jj|d|�||j|d�krS|jj|d|j|d��dS)z!Process a single editing command.rr)$r
rrrrrrrrrZSOHrZSTXZKEY_LEFTZBSZ
KEY_BACKSPACErrZdelchZEOTZENQZACKZ	KEY_RIGHTZBEL�NLZVTZdeletelnZclrtoeolZFF�refresh�SOZKEY_DOWNZSIZinsertlnZDLEZKEY_UP)rrrrrrr	�
do_command_sr
	*	'	!'$zTextbox.do_commandcCs�d}|j�x�t|jd�D]�}|jj|d�|j|�}|dkrd|jrdq$x\t|jd�D]G}|jr�||kr�P|tt	j
j
|jj||���}qxW|jdkr$|d}q$W|S)z.Collect and return the contents of the window.�rr�
)r
�rangerrrrrr�chrrrr)r�resultr�stoprrrr	�gather�s
/zTextbox.gatherNcCsXxK|jj�}|r$||�}|s-q|j|�s=P|jj�qW|j�S)z2Edit in the widget window and collect the results.)rZgetchr#r!r*)rZvalidaterrrr	�edit�szTextbox.edit)�__name__�
__module__�__qualname__�__doc__rr
rrr#r*r+rrrr	rsA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