File: //opt/alt/python35/lib64/python3.5/curses/__pycache__/textpad.cpython-35.pyc
��Yf�  �               @   s{   d  Z  d d l Z d d l Z d d �  Z Gd d �  d � Z e d k rw d d	 �  Z e j e � Z e	 d
 e
 e � � d S)z:Simple textbox editing widget with Emacs-like keybindings.�    Nc             C   s�   |  j  | d | t j | | d � |  j | | d t j | | d � |  j | | d t j | | d � |  j  | d | t j | | d � |  j | | t j � |  j | | t j � |  j | | t j � |  j | | t j	 � d S)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/python35/lib64/python3.5/curses/textpad.py�	rectangle   s    %%%%r
   c               @   sp   e  Z d  Z d Z d d d � Z d d �  Z d d �  Z d	 d
 �  Z d d �  Z d
 d �  Z	 d d d � 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             C   s?   | |  _  | |  _ |  j �  d |  _ d  |  _ | j d � d  S)Nr   )r   �insert_mode�_update_max_yx�stripspaces�lastcmdZkeypad)�selfr   r   r   r   r	   �__init__+   s    		
		zTextbox.__init__c             C   s3   |  j  j �  \ } } | d |  _ | d |  _ d  S)Nr   )r   Zgetmaxyx�maxy�maxx)r   r   r   r   r   r	   r
   3   s    
zTextbox._update_max_yxc             C   s|   |  j  �  |  j } xb t j j |  j j | | � � t j j k r] t |  j | d � } Pn
 | d k rj P| 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.r   r   )r
   r   r   �asciir   �inchZSP�min)r   �yZlastr   r   r	   �_end_of_line8   s    
	-zTextbox._end_of_linec             C   s�   |  j  �  |  j j �  \ } } d  } x� | |  j k  sF | |  j k  r� |  j r^ |  j j �  } y |  j j | � Wn t j	 k
 r� Yn X|  j s� t j
 j | � r� P| } |  j j �  \ } } | d  k r( | | f } q( W| d  k	 r� |  j j | �  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   sW  |  j  �  |  j j �  \ } } | |  _ t j j | � rh | |  j k  sX | |  j k  rS|  j	 | � n�| t j j
 k r� |  j j | d � n�| t j j t j
 t j j t j f k rd| d k r� |  j j | | d � nY | d k r� nJ |  j r|  j j | d |  j | d � � n |  j j | d |  j � | t j j t j f k rS|  j j �  n�| t j j k r�|  j j �  n�| t j j k r�|  j r�|  j j | |  j | � � qS|  j j | |  j � nz| t j j t j f k rI| |  j k  r|  j j | | d � qS| |  j k r/qS|  j j | d d � n
| t j j k r_d S| t j j k r�|  j d k r�d S| |  j k  rS|  j j | d d � n�| t j j k r| d k r�|  j | � d k r�|  j j �  qS|  j j | | � |  j j �  n@| t j j k r5|  j j �  n| t j j t j f k r�| |  j k  rS|  j j | d | � | |  j | d � k rS|  j j | d |  j | d � � n� | t j j  k r�|  j j! �  n{ | t j j"