관리-도구
편집 파일: screen.cpython-39.opt-1.pyc
a ������!^�5����������������������@���s����d�Z�ddlZddlZddlZddlZejddd��dZdZdZdZ d Z d ZdZdZ d ZdZdZdZdZdZdZdZdZdZejd�dkZer�eZdd��ZG�dd��d�ZdS�)a���This implements a virtual screen. This is used to support ANSI terminal emulation. The screen representation and state is implemented in this class. Most of the methods are inspired by ANSI screen control codes. The :class:`~pexpect.ANSI.ANSI` class extends this class to add parsing of ANSI escape codes. PEXPECT LICENSE This license is approved by the OSI and FSF as GPL-compatible. http://opensource.org/licenses/isc-license.txt Copyright (c) 2012, Noah Spurrier <noah@noah.org> PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. �����Nz�pexpect.screen and pexpect.ANSI are deprecated. We recommend using pyte to emulate a terminal screen: https://pypi.python.org/pypi/pyte����)� stacklevel������������� ���� ������������ ������������������������������������ ����c�����������������C���s���|�|k�r|S�|�|kr|S�|�S�)z@This returns a number, n constrained to the min and max bounds. ��)�n�min�maxr���r����2/usr/lib/python3.9/site-packages/pexpect/screen.py� constrain<���s ����r���c�������������������@���s���e�Zd�ZdZdbdd�Zdd ��Zd d��Zer0eZneZ dd ��Zdd��Z dd��Zefdd�Z efdd�Zdd��Zdd��Zdd��Zdd��Zdd��Zd d!��Zd"d#��Zd$d%��Zd&d'��Zd(d)��Zd*d+��Zd,d-��Zdcd/d0�Zddd1d2�Zded3d4�Zdfd5d6�Zdgd7d8�Zd9d:��Z d;d<��Z!d=d>��Z"d?d@��Z#dAdB��Z$dCdD��Z%dEdF��Z&dGdH��Z'dIdJ��Z(dKdL��Z)dMdN��Z*dOdP��Z+dQdR��Z,dSdT��Z-dUdV��Z.dWdX��Z/dYdZ��Z0d[d\��Z1d]d^��Z2d_d`��Z3daS�)h�screena5��This object maintains the state of a virtual text screen as a rectangular array. This maintains a virtual cursor position and handles scrolling as characters are added. This supports most of the methods needed by an ANSI text screen. Row and column indexes are 1-based (not zero-based, like arrays). Characters are represented internally using unicode. Methods that accept input characters, when passed 'bytes' (which in Python 2 is equivalent to 'str'), convert them from the encoding specified in the 'encoding' parameter to the constructor. Methods that return screen contents return unicode strings, with the exception of __str__() under Python 2. Passing ``encoding=None`` limits the API to only accept unicode input, so passing bytes in will raise :exc:`TypeError`. r����P����latin-1�replacec��������������������s|���|��_�|��_|��_|��_|dur2t�|�|���_nd��_d��_d��_d��_ d��_ d��_��j���_��fdd�t ��j��D����_dS�)z8This initializes a blank screen of the given dimensions.N����c��������������������s���g�|�]}t�g��j��qS�r���)�SPACE�cols)�.0�_��selfr���r���� <listcomp>f��������z#screen.__init__.<locals>.<listcomp>)�rowsr"����encoding�encoding_errors�codecs�getincrementaldecoder�decoder�cur_r�cur_c�cur_saved_r�cur_saved_c�scroll_row_start�scroll_row_end�range�w)r&����r�cr*���r+���r���r%���r����__init__U���s����zscreen.__init__c�����������������C���s"���|�j�dur|�j��|�S�td��dS�)ztThis converts from the external coding system (as passed to the constructor) to the internal one (unicode). NzLThis screen was constructed with encoding=None, so it does not handle bytes.)r.����decode� TypeError)r&����sr���r���r����_decodeh���s���� zscreen._decodec�����������������C���s���d��dd��|�jD���S�)z�This returns a printable representation of the screen as a unicode string (which, under Python 3.x, is the same as 'str'). The end of each screen line is terminated by a newline.� c�����������������S���s���g�|�]}d���|��qS������join�r#���r8���r���r���r���r'���v���r(���z#screen._unicode.<locals>.<listcomp>�rB���r6���r%���r���r���r����_unicodeq���s����zscreen._unicodec�����������������C���s���|�j�pd}|�����|d�S�)z{This returns a printable representation of the screen. The end of each screen line is terminated by a newline. �asciir���)r*���rE����encode)r&���r*���r���r���r����__str__}���s���� zscreen.__str__c�����������������C���s���d��dd��|�jD���S�)z�This returns a copy of the screen as a unicode string. This is similar to __str__/__unicode__ except that lines are not terminated with line feeds.r@���c�����������������S���s���g�|�]}d���|��qS�r?���rA���rC���r���r���r���r'�������r(���zscreen.dump.<locals>.<listcomp>rD���r%���r���r���r����dump����s����zscreen.dumpc�����������������C���s<���dd|�j���d�}|d�dd��t|���d�D����d�|�S�)z�This returns a copy of the screen as a unicode string with an ASCII text box around the screen border. This is similar to __str__/__unicode__ except that it adds a box.�+�-z+ r>���c�����������������S���s���g�|�]}d�|�d���qS�)�|r���)r#����liner���r���r���r'�������r(���z!screen.pretty.<locals>.<listcomp>)r"���rB����unicode�split)r&���Ztop_botr���r���r����pretty����s����z screen.prettyc�����������������C���s.���t�|t�r|��|�}|��dd|�j|�j|��d�S��Nr ���)� isinstance�bytesr=����fill_regionr)���r"����r&����chr���r���r����fill����s���� zscreen.fillc�����������������C���s����t�|t�r|��|�}t|d|�j�}t|d|�j�}t|d|�j�}t|d|�j�}||kr^||�}}||krp||�}}t||d��D�]&}t||d��D�]}|��|||��q�q~d�S�rQ���)rR���rS���r=���r���r)���r"���r5����put_abs)r&����rs�cs�re�cerV���r7���r8���r���r���r���rT�������s���� zscreen.fill_regionc�����������������C���s���|���|�jd��dS�)zKThis moves the cursor to the beginning (col 1) of the current row. r ���N)�cursor_homer/���r%���r���r���r����cr����s����z screen.crc�����������������C���s,���|�j�}|�����||�j�kr(|�����|�����dS�)z3This moves the cursor down with scrolling. N)r/����cursor_down� scroll_up� erase_line�r&���Zold_rr���r���r����lf����s ���� z screen.lfc�����������������C���s���|������|�����dS�)ztThis advances the cursor with CRLF properties. The cursor will line wrap and the screen may scroll. N)r^���rc���r%���r���r���r����crlf����s����zscreen.crlfc�����������������C���s���|������dS�)z%This is an alias for crlf(). N)rd���r%���r���r���r����newline����s����zscreen.newlinec�����������������C���sX���t�|d|�j�}t�|d|�j�}t|t�r6|��|�d�}n|d�}||�j|d��|d�<�dS�)zScreen array starts at 1 index.r ���r���N)r���r)���r"���rR���rS���r=���r6���)r&���r7���r8���rV���r���r���r���rX�������s���� zscreen.put_absc�����������������C���s*���t�|t�r|��|�}|��|�j|�j|��dS�)z?This puts a characters at the current cursor position. N)rR���rS���r=���rX���r/���r0���rU���r���r���r����put����s���� z screen.putc�������������� ���C���sp���t�|t�r|��|�}t|d|�j�}t|d|�j�}t|�j|d�D�]}|��|||��||d����q>|��|||��dS�)z�This inserts a character at (r,c). Everything under and to the right is shifted right one character. The last character of the line is lost. r ������N) rR���rS���r=���r���r)���r"���r5���rX����get_abs)r&���r7���r8���rV���Zcir���r���r���� insert_abs����s���� zscreen.insert_absc�����������������C���s*���t�|t�r|��|�}|��|�j|�j|��d�S��N)rR���rS���r=���ri���r/���r0���rU���r���r���r����insert����s���� z screen.insertc�����������������C���s2���t�|d|�j�}t�|d|�j�}|�j|d��|d��S�rQ���)r���r)���r"���r6����r&���r7���r8���r���r���r���rh�������s����zscreen.get_absc�����������������C���s���|���|�j|�j��d�S�rj���)rh���r/���r0���r%���r���r���r����get����s����z screen.getc����������� ������C���s����t�|d|�j�}t�|d|�j�}t�|d|�j�}t�|d|�j�}||krJ||�}}||kr\||�}}g�}t||d��D�]:}d}t||d��D�]}|��||�} || �}q�|�|��qn|S�)z>This returns a list of lines representing the region. r ���r@���)r���r)���r"���r5���rh����append) r&���rY���rZ���r[���r\���Zscr7���rM���r8���rV���r���r���r���� get_region����s ���� zscreen.get_regionc�����������������C���s(���t�|�jd|�j�|�_t�|�jd|�j�|�_dS�)z6This keeps the cursor within the screen area. r ���N)r���r/���r)���r0���r"���r%���r���r���r����cursor_constrain��s����zscreen.cursor_constrainr ���c�����������������C���s���||�_�||�_|�����d�S�rj���)r/���r0���rp���rl���r���r���r���r]�����s����zscreen.cursor_homec�����������������C���s���|�j�|�|�_�|�����d�S�rj����r0���rp����r&����countr���r���r����cursor_back��s����zscreen.cursor_backc�����������������C���s���|�j�|�|�_�|�����d�S�rj����r/���rp���rr���r���r���r���r_���#��s����zscreen.cursor_downc�����������������C���s���|�j�|�|�_�|�����d�S�rj���rq���rr���r���r���r����cursor_forward(��s����zscreen.cursor_forwardc�����������������C���s���|�j�|�|�_�|�����d�S�rj���ru���rr���r���r���r���� cursor_up-��s����zscreen.cursor_upc�����������������C���s$���|�j�}|�����||�j�kr |�����d�S�rj���)r/���rw���r`���rb���r���r���r����cursor_up_reverse2��s���� zscreen.cursor_up_reversec�����������������C���s���|���||��dS�)zIdentical to Cursor Home.N)r]���rl���r���r���r����cursor_force_position9��s����zscreen.cursor_force_positionc�����������������C���s���|������dS��zSave current cursor position.N)�cursor_save_attrsr%���r���r���r����cursor_save>��s����zscreen.cursor_savec�����������������C���s���|������dS��z-Restores cursor position after a Save Cursor.N)�cursor_restore_attrsr%���r���r���r���� cursor_unsaveC��s����zscreen.cursor_unsavec�����������������C���s���|�j�|�_|�j|�_dS�rz���)r/���r1���r0���r2���r%���r���r���r���r{���H��s����zscreen.cursor_save_attrsc�����������������C���s���|���|�j|�j��dS�r}���)r]���r1���r2���r%���r���r���r���r~���N��s����zscreen.cursor_restore_attrsc�����������������C���s(���|�j�dkrd|�_�|�j|�jkr$|�j|�_dS�)z6This keeps the scroll region within the screen region.r���r ���N)r3���r4���r)���r%���r���r���r����scroll_constrainS��s���� zscreen.scroll_constrainc�����������������C���s���d|�_�|�j|�_dS�)z$Enable scrolling for entire display.r ���N)r3���r)���r4���r%���r���r���r���� scroll_screen[��s����zscreen.scroll_screenc�����������������C���s���||�_�||�_|�����dS�)z/Enable scrolling from row {start} to row {end}.N)r3���r4���r����)r&���rY���r[���r���r���r����scroll_screen_rowsa��s����zscreen.scroll_screen_rowsc�����������������C���s>���|�j�d�}|�jd�}t�|�j||���|�j|d�|d��<�dS�)zScroll display down one line.r ���N�r3���r4����copy�deepcopyr6����r&���r<����er���r���r����scroll_downh��s���� zscreen.scroll_downc�����������������C���s>���|�j�d�}|�jd�}t�|�j|d�|d����|�j||�<�dS�)zScroll display up one line.r ���Nr����r����r���r���r���r`���p��s���� zscreen.scroll_upc�����������������C���s���|���|�j|�j|�j|�j��dS�)zOErases from the current cursor position to the end of the current line.N)rT���r/���r0���r"���r%���r���r���r����erase_end_of_linex��s����zscreen.erase_end_of_linec�����������������C���s���|���|�jd|�j|�j��dS�)zQErases from the current cursor position to the start of the current line.r ���N)rT���r/���r0���r%���r���r���r����erase_start_of_line~��s����zscreen.erase_start_of_linec�����������������C���s���|���|�jd|�j|�j��dS�)zErases the entire current line.r ���N)rT���r/���r"���r%���r���r���r���ra������s����zscreen.erase_linec�����������������C���s&���|������|��|�jd�d|�j|�j��dS�)zQErases the screen from the current line down to the bottom of the screen.r ���N)r����rT���r/���r)���r"���r%���r���r���r���� erase_down���s����zscreen.erase_downc�����������������C���s$���|������|��|�jd�dd|�j��dS�)zLErases the screen from the current line up to the top of the screen.r ���N)r����rT���r/���r"���r%���r���r���r����erase_up���s����zscreen.erase_upc�����������������C���s���|������dS�)z,Erases the screen with the background color.N)rW���r%���r���r���r����erase_screen���s����zscreen.erase_screenc�����������������C���s���dS�)z#Sets a tab at the current position.Nr���r%���r���r���r����set_tab���s����zscreen.set_tabc�����������������C���s���dS�)z#Clears tab at the current position.Nr���r%���r���r���r���� clear_tab���s����zscreen.clear_tabc�����������������C���s���dS�)zClears all tabs.Nr���r%���r���r���r����clear_all_tabs���s����zscreen.clear_all_tabsN)r���r���r���r���)r ���r ���)r ���)r ���)r ���)r ���)4�__name__� __module__�__qualname__�__doc__r9���r=���rE����PY3rH���Z__unicode__rI���rP���r!���rW���rT���r^���rc���rd���re���rX���rf���ri���rk���rh���rm���ro���rp���r]���rt���r_���rv���rw���rx���ry���r|���r���r{���r~���r����r����r����r����r`���r����r����ra���r����r����r����r����r����r����r���r���r���r���r���F���sb��� r���)r����r,���r�����sys�warnings�warn�NULZENQZBELZBSZHTZLF�VTZFFZCRZSOZSIZXONZXOFFZCANZSUBZESCZDELr!����version_infor�����strrN���r���r���r���r���r���r����<module>���s<����