HOME


Mini Shell 1.0
DIR: /usr/lib/python3/dist-packages/twisted/conch/insults/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/twisted/conch/insults/__pycache__/insults.cpython-312.pyc
�

Ϫ�f/���>�dZddlmZmZddlmZmZmZddl	m
Z
mZGd�de�Zee�Gd�d��Z
Gd	�d
ej�ZdZdd
iZGd�d�ZGd�d�ZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!Gd�d �Z"d!�Z#d"Z$Gd#�d$�Z%e$D�cgc]}e%|�jM���c}Z'ee�Gd%�d&ejP��Z)e*e$e'�D]\Z+Z,e-e)e+e,��Gd'�d(ejP�Z.gd)�Z/y*cc}w)+z?
VT102 and VT220 terminal manipulation.

@author: Jp Calderone
�)�	Interface�implementer)�defer�
interfaces�protocol)�	iterbytes�
networkStringc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�ITerminalProtocolc��y)zX
        Called with an L{ITerminalTransport} when a connection is established.
        N�)�	transports �?/usr/lib/python3/dist-packages/twisted/conch/insults/insults.py�makeConnectionz ITerminalProtocol.makeConnection���c��y)a`
        A keystroke was received.

        Each keystroke corresponds to one invocation of this method.
        keyID is a string identifier for that key.  Printable characters
        are represented by themselves.  Control keys, such as arrows and
        function keys, are represented with symbolic constants on
        L{ServerProtocol}.
        Nr
)�keyID�modifiers  r�keystrokeReceivedz#ITerminalProtocol.keystrokeReceivedrrc��y)z�
        Called to indicate the size of the terminal.

        A terminal of 80x24 should be assumed if this method is not
        called.  This method might not be called for real terminals.
        Nr
)�width�heights  r�terminalSizezITerminalProtocol.terminalSize"rrc��y�z�
        Called when an unsupported control sequence is received.

        @type seq: L{str}
        @param seq: The whole control sequence which could not be interpreted.
        Nr
��seqs r�unhandledControlSequencez*ITerminalProtocol.unhandledControlSequence*rrc��y)zh
        Called when the connection has been lost.

        reason is a Failure describing why.
        Nr
)�reasons r�connectionLostz ITerminalProtocol.connectionLost2rrN)�__name__�
__module__�__qualname__rrrrr"r
rrrrs���
	���rrc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�TerminalProtocolc�2�||_|j�y�N)�terminal�connectionMade)�selfr*s  rrzTerminalProtocol.makeConnection<s�� ��
����rc��y)zA
        Called after a connection has been established.
        Nr
�r,s rr+zTerminalProtocol.connectionMadeArrc��yr)r
)r,rrs   rrz"TerminalProtocol.keystrokeReceivedF���rc��yr)r
)r,rrs   rrzTerminalProtocol.terminalSizeIr0rc��yr)r
)r,rs  rrz)TerminalProtocol.unhandledControlSequenceLr0rc��yr)r
�r,r!s  rr"zTerminalProtocol.connectionLostOr0rN)	r#r$r%rr+rrrr"r
rrr'r':s ���
�

�
�
�
rr'c��eZdZd+d�Zd+d�Zd+d�Zd+d�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd,d�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d+d$�Z&d+d%�Z'd+d&�Z(d'�Z)d(�Z*d)�Z+y*)-�ITerminalTransportc��y)z-
        Move the cursor up n lines.
        Nr
��ns r�cursorUpzITerminalTransport.cursorUpTrrc��y)z/
        Move the cursor down n lines.
        Nr
r8s r�
cursorDownzITerminalTransport.cursorDownYrrc��y)z2
        Move the cursor right n columns.
        Nr
r8s r�
cursorForwardz ITerminalTransport.cursorForward^rrc��y)z1
        Move the cursor left n columns.
        Nr
r8s r�cursorBackwardz!ITerminalTransport.cursorBackwardcrrc��y)z?
        Move the cursor to the given line and column.
        Nr
)�column�lines  r�cursorPositionz!ITerminalTransport.cursorPositionhrrc��y)z'
        Move the cursor home.
        Nr
r
rr�
cursorHomezITerminalTransport.cursorHomemrrc��y)zS
        Move the cursor down one line, performing scrolling if necessary.
        Nr
r
rr�indexzITerminalTransport.indexrrrc��y)zQ
        Move the cursor up one line, performing scrolling if necessary.
        Nr
r
rr�reverseIndexzITerminalTransport.reverseIndexwrrc��y)zl
        Move the cursor to the first position on the next line, performing scrolling if necessary.
        Nr
r
rr�nextLinezITerminalTransport.nextLine|rrc��y)zj
        Save the cursor position, character attribute, character set, and origin mode selection.
        Nr
r
rr�
saveCursorzITerminalTransport.saveCursor�rrc��y)z�
        Restore the previously saved cursor position, character attribute, character set, and origin mode selection.

        If no cursor state was previously saved, move the cursor to the home position.
        Nr
r
rr�
restoreCursorz ITerminalTransport.restoreCursor�rrc��y)z6
        Set the given modes on the terminal.
        Nr
��modess r�setModeszITerminalTransport.setModes�rrc��y)z8
        Reset the given modes on the terminal.
        Nr
)�modes r�
resetModeszITerminalTransport.resetModes�rrc��y)zB
        Set the given DEC private modes on the terminal.
        Nr
rRs r�setPrivateModesz"ITerminalTransport.setPrivateModes�rrc��y)zD
        Reset the given DEC private modes on the terminal.
        Nr
rRs r�resetPrivateModesz$ITerminalTransport.resetPrivateModes�rrc��y)z�
        Cause keypad to generate control functions.

        Cursor key mode selects the type of characters generated by cursor keys.
        Nr
r
rr�applicationKeypadModez(ITerminalTransport.applicationKeypadMode�rrc��y)z=
        Cause keypad to generate normal characters.
        Nr
r
rr�numericKeypadModez$ITerminalTransport.numericKeypadMode�rrc��y)z�
        Select a character set.

        charSet should be one of CS_US, CS_UK, CS_DRAWING, CS_ALTERNATE, or
        CS_ALTERNATE_SPECIAL.

        which should be one of G0 or G1.
        Nr
)�charSet�whichs  r�selectCharacterSetz%ITerminalTransport.selectCharacterSet�rrc��y)z0
        Activate the G0 character set.
        Nr
r
rr�shiftInzITerminalTransport.shiftIn�rrc��y)z0
        Activate the G1 character set.
        Nr
r
rr�shiftOutzITerminalTransport.shiftOut�rrc��y)zG
        Shift to the G2 character set for a single character.
        Nr
r
rr�singleShift2zITerminalTransport.singleShift2�rrc��y)zG
        Shift to the G3 character set for a single character.
        Nr
r
rr�singleShift3zITerminalTransport.singleShift3�rrc��y)z�
        Enabled one or more character attributes.

        Arguments should be one or more of UNDERLINE, REVERSE_VIDEO, BLINK, or BOLD.
        NORMAL may also be specified to disable all character attributes.
        Nr
)�
attributess r�selectGraphicRenditionz)ITerminalTransport.selectGraphicRendition�rrc��y)z@
        Set a tab stop at the current cursor position.
        Nr
r
rr�horizontalTabulationSetz*ITerminalTransport.horizontalTabulationSet�rrc��y)zD
        Clear the tab stop at the current cursor position.
        Nr
r
rr�tabulationClearz"ITerminalTransport.tabulationClear�rrc��y)z&
        Clear all tab stops.
        Nr
r
rr�tabulationClearAllz%ITerminalTransport.tabulationClearAll�rrc��y)z�
        Make the current line the top or bottom half of a double-height, double-width line.

        If top is True, the current line is the top half.  Otherwise, it is the bottom half.
        Nr
)�tops r�doubleHeightLinez#ITerminalTransport.doubleHeightLine�rrc��y)zK
        Make the current line a single-width, single-height line.
        Nr
r
rr�singleWidthLinez"ITerminalTransport.singleWidthLine�rrc��y)z<
        Make the current line a double-width line.
        Nr
r
rr�doubleWidthLinez"ITerminalTransport.doubleWidthLine�rrc��y)zV
        Erase from the cursor to the end of line, including cursor position.
        Nr
r
rr�eraseToLineEndz!ITerminalTransport.eraseToLineEnd�rrc��y)zd
        Erase from the cursor to the beginning of the line, including the cursor position.
        Nr
r
rr�eraseToLineBeginningz'ITerminalTransport.eraseToLineBeginning�rrc��y)z/
        Erase the entire cursor line.
        Nr
r
rr�	eraseLinezITerminalTransport.eraseLine�rrc��y)za
        Erase from the cursor to the end of the display, including the cursor position.
        Nr
r
rr�eraseToDisplayEndz$ITerminalTransport.eraseToDisplayEndrrc��y)zg
        Erase from the cursor to the beginning of the display, including the cursor position.
        Nr
r
rr�eraseToDisplayBeginningz*ITerminalTransport.eraseToDisplayBeginningrrc��y)z+
        Erase the entire display.
        Nr
r
rr�eraseDisplayzITerminalTransport.eraseDisplayrrc��y)z�
        Delete n characters starting at the cursor position.

        Characters to the right of deleted characters are shifted to the left.
        Nr
r8s r�deleteCharacterz"ITerminalTransport.deleteCharacterrrc��y)z�
        Insert n lines at the cursor position.

        Lines below the cursor are shifted down.  Lines moved past the bottom margin are lost.
        This command is ignored when the cursor is outside the scroll region.
        Nr
r8s r�
insertLinezITerminalTransport.insertLinerrc��y)z�
        Delete n lines starting at the cursor position.

        Lines below the cursor are shifted up.  This command is ignored when the cursor is outside
        the scroll region.
        Nr
r8s r�
deleteLinezITerminalTransport.deleteLine rrc��y)zi
        Return a Deferred that fires with a two-tuple of (x, y) indicating the cursor position.
        Nr
r
rr�reportCursorPositionz'ITerminalTransport.reportCursorPosition(rrc��y)z:
        Reset the terminal to its initial state.
        Nr
r
rr�resetzITerminalTransport.reset-rrc��yrr
rs rrz+ITerminalTransport.unhandledControlSequence2rrN���T),r#r$r%r:r<r>r@rDrFrHrJrLrNrPrTrWrYr[r]r_rcrergrirkrnrprrrtrwryr{r}rr�r�r�r�r�r�r�r�r�rr
rrr6r6Ss����
�
�
�
�
�
�
�
�
�
��
�
�
�
��
��
�
�
�
��
�
�
��
�
�
�
�
�
�
�
����
�
rr6��~stildec�(�eZdZdZdxZZdxZZdxZZ	y)rSz$
    ECMA 48 standardized modes
    ���N)
r#r$r%�__doc__�KEYBOARD_ACTION�KAM�INSERTION_REPLACEMENT�IRM�LINEFEED_NEWLINE�LNMr
rrrSrS?s-���
��O�c�#$�#��C� ���srrSc�@�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
Zy)�privateModesz'
    ANSI-Compatible Private Modes
    rr�r��r��������N)r#r$r%r��ERROR�
CURSOR_KEY�	ANSI_VT52�COLUMN�SCROLL�SCREEN�ORIGIN�	AUTO_WRAP�AUTO_REPEAT�PRINTER_FORM_FEED�PRINTER_EXTENT�CURSOR_MODEr
rrr�r�[sH���
�E��J��I�
�F�
�F�
�F�
�F��I��K����N��Krr�sCS_USsCS_UKs
CS_DRAWINGsCS_ALTERNATEsCS_ALTERNATE_SPECIALsG0sG1sG2sG3r�r�r�r�c��eZdZd�Zy)�Vectorc� �||_||_yr))�x�y)r,r�r�s   r�__init__zVector.__init__�s�������rN)r#r$r%r�r
rrr�r��s��rr�c��tdd�5}|jt|�dz�ddd�y#1swYyxYw)N�log�a�
)�open�write�str)�s�fs  rr�r��s7��	
�e�S�	��Q�	����A���
�����s�4�=)�UP_ARROW�
DOWN_ARROW�RIGHT_ARROW�
LEFT_ARROW�HOME�INSERT�DELETE�END�PGUP�PGDN�
NUMPAD_MIDDLE�F1�F2�F3�F4�F5�F6�F7�F8�F9�F10�F11�F12�ALT�SHIFT�CONTROLc�8�eZdZdZdeddfd�Zdefd�Zdefd�Zy)�_constz3
    @ivar name: A string naming this constant
    �name�returnNc��||_yr)�r�)r,r�s  rr�z_const.__init__�s	����	rc�&�d|jzdzS)N�[�]r�r.s r�__repr__z_const.__repr__�s���T�Y�Y���$�$rc�D�d|jzdzjd�S)Nr�r��ascii)r��encoder.s r�	__bytes__z_const.__bytes__�s ���d�i�i��#�%�-�-�g�6�6r)	r#r$r%r�r�r�r��bytesr�r
rrr�r��s2����S��T��%�#�%�7�5�7rr�c���eZdZdZdZdZdZdZdZe	dd�Z
e	dd�ZdZdZ
dBd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�ZGd�d�Ze�ZdCd�ZdCd�ZdCd�ZdCd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d �Z%d!�Z&d"�Z'd#�Z(d$�Z)d%�Z*d&�Z+d'�Z,d(�Z-d)�Z.d*�Z/d+�Z0d,�Z1d-�Z2dDd.�Z3d/�Z4d0�Z5d1�Z6d2�Z7d3�Z8d4�Z9d5�Z:d6�Z;dCd7�Z<dCd8�Z=dCd9�Z>dEd:�Z?d;�Z@d<�ZAd=�ZBd>�ZCd?�ZDd@�ZEdA�ZFy)F�ServerProtocolN�	�r�data�P�rc�@�|�||_||_||_g|_y)a
        @param protocolFactory: A callable which will be invoked with
        *a, **kw and should return an ITerminalProtocol implementor.
        This will be invoked when a connection to this ServerProtocol
        is established.

        @param a: Any positional arguments to pass to protocolFactory.
        @param kw: Any keyword arguments to pass to protocolFactory.
        N)�protocolFactory�protocolArgs�protocolKwArgs�_cursorReports)r,r�r��kws    rr�zServerProtocol.__init__�s*���&�#2�D� ���� ��� ��rc��td��)Nz%Unimplemented: ServerProtocol.getHost��NotImplementedErrorr.s r�getHostzServerProtocol.getHost����!�"I�J�Jrc��td��)Nz%Unimplemented: ServerProtocol.getPeerr�r.s r�getPeerzServerProtocol.getPeer�rrc��|j�e|j|ji|j��|_	|j}||j_|jj
|�yy#t
$rY�(wxYwr))r�r�r��terminalProtocol�factory�AttributeErrorr)r,rs  rr+zServerProtocol.connectionMade�s������+�$8�D�$8�$8��"�"�%�&*�&9�&9�%�D�!�
8��,�,��18��%�%�-��!�!�0�0��6�,��"�
��
�s�A3�3	A?�>A?c��t|�D�]<}|jdk(r*|dk(rd|_� |jj|d��=|jdk(r:|dk(rd|_g|_�`|dk(rd|_�md|_|j|���|jdk(rv|dk(rd|_��|j
�s|dk(r7|jd	j|j�|z�|`d|_��|jj|���|jdk(r|j|�d|_��4td
��y)Nr�r��escaped�[sbracket-escaped�Oslow-function-escapedr�r�
Illegal state)r�staterr�escBuf�_handleShortControlSequence�isalpha�_handleControlSequence�join�append�!_handleLowFunctionControlSequence�
ValueError)r,�data�chs   r�dataReceivedzServerProtocol.dataReceiveds���D�/�	2�B��z�z�W�$���=�!+�D�J��)�)�;�;�B��E����z�)���:�!3�D�J�"$�D�K��4�Z�!8�D�J�!(�D�J��4�4�R�8����1�1���:�!8�D�J��Z�Z�\�R�4�Z��/�/�������0E��0J�K���!(�D�J��K�K�&�&�r�*����6�6��6�6�r�:�$��
� ��1�1�9	2rc�P�|jj||j�yr))rrr�)r,rs  rrz*ServerProtocol._handleShortControlSequence!s�����/�/��D�H�H�=rc	���d|z}t|jtj|dd|dd�j	d�d�}|�|j|�y|||j|dd�y)N�[���r�)�getattr�controlSequenceParser�CST�get�decoderr)r,�bufr�s   rrz%ServerProtocol._handleControlSequence$ss����n����&�&��G�G�C���H�c�"�#�h�'�.�.�w�7��
��

�9��)�)�#�.�
�d�D�)�)�3�s��8�4rc�:�|jj|�yr))rr)r,r#s  rrz'ServerProtocol.unhandledControlSequence0s�����6�6�s�;rc��|j|j|j|jd�}|j	|�}|�|j
j
|d�y|j
jd|z�y)N)�P�Q�R�Ss)r�r�r�r�r!rrr)r,r�functionKeysrs    rrz0ServerProtocol._handleLowFunctionControlSequence3sd��"�g�g�T�W�W�D�G�G�4�7�7�S��� � ��$�����!�!�3�3�E�4�@��!�!�:�:�9�r�>�Jrc�H�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�$ServerProtocol.ControlSequenceParserc�p�|dk(r|j|jd�y|j|dz�y)Nr�A)rr�r�r,�proto�handlerr#s    r�Az&ServerProtocol.ControlSequenceParser.A<s/���h���)�)�%�.�.�$�?��0�0��t��<rc�p�|dk(r|j|jd�y|j|dz�y)Nr�B)rr�rr/s    r�Bz&ServerProtocol.ControlSequenceParser.BB�1���h���)�)�%�*:�*:�D�A��0�0��t��<rc�p�|dk(r|j|jd�y|j|dz�y)Nr�C)rr�rr/s    r�Cz&ServerProtocol.ControlSequenceParser.CHs1���h���)�)�%�*;�*;�T�B��0�0��t��<rc�p�|dk(r|j|jd�y|j|dz�y)Nr�D)rr�rr/s    r�Dz&ServerProtocol.ControlSequenceParser.DNr6rc�p�|dk(r|j|jd�y|j|dz�y)Nr�E)rr�rr/s    r�Ez&ServerProtocol.ControlSequenceParser.ETs1���h���)�)�%�*=�*=�t�D��0�0��t��<rc�p�|dk(r|j|jd�y|j|dz�y)Nr�F)rr�rr/s    r�Fz&ServerProtocol.ControlSequenceParser.FZs/���h���)�)�%�)�)�T�:��0�0��t��<rc�p�|dk(r|j|jd�y|j|dz�y)Nr�H)rr�rr/s    r�Hz&ServerProtocol.ControlSequenceParser.H`s/���h���)�)�%�*�*�d�;��0�0��t��<rc���|js|j|dz�y|jd�r�|dd}|jd�}t	|�dk7r|j|dz�y|\}}	t|�t|�}}|jj
d�}|j|dz
|dz
f�y|j|dz�y#t$r|j|dz�YywxYw)Nr(rr��;rr�)	r�r�
startswith�split�len�int�pop�callbackr)	r,r0r1r#�report�parts�Pl�Pc�ds	         r�Rz&ServerProtocol.ControlSequenceParser.Rfs����'�'��0�0��t��<�����)��Q�R������T�*���u�:��?��4�4�S�4�Z�@�"�F�B��5�!$�R��#�b�'�B��"�0�0�4�4�Q�7���
�
�B��F�B��F�#3�4��0�0��t��<��
&�E��8�8��t��D�E�s�2C�C2�1C2c��|dk(r'|j|j|j�y|j|dz�y)Nr�Z)r�TABr�rr/s    r�Zz&ServerProtocol.ControlSequenceParser.Zzs3���h���)�)�%�)�)�U�[�[�A��0�0��t��<rc�l�|j|j|j|j|j|j
|j|j|j|j|j|j|j|jd�}|jd�rO|dd}	t|�}|j!|�}|�|j#||d�y|j%|dz�y|j%|dz�y#t&$r|j%|dz�YywxYw)N)r�r�r�r�r�r���r�r�r���r�rr�r�)r�r�r�r�r�r�r�r�r�r�r�r�r�r�rHrKr!rrr)r,r0r1r#�mapr�v�symbolics        r�tildez*ServerProtocol.ControlSequenceParser.tilde�s���:�:��<�<��<�<��9�9��:�:��:�:��H�H��H�H��H�H��H�H��H�H��I�I��I�I��I�I��C�"�~�~�h�'����W��	E��B��A� #�w�w�q�z�H��+��1�1�#�a�&�$�?��8�8��t��D��0�0��t��<��"�A��4�4�S�4�Z�@�A�s�5D�D3�2D3N)
r#r$r%r2r5r9r<r?rBrErSrWr`r
rr�ControlSequenceParserr,;s4��	=�	=�	=�	=�	=�	=�	=�	=�(	=�	=rrac��|dk\sJ�t|jj|z
d�|j_|jd|fz�y)Nr�rs[%dA��max�	cursorPosr�r��r,r9s  rr:zServerProtocol.cursorUp��B���A�v�
�v��t�~�~�/�/�!�3�Q�7������
�
�;�!��%�&rc���|dk\sJ�t|jj|z|jjdz
�|j_|j	d|fz�y)Nr�s[%dB��minrer��termSizer�rfs  rr<zServerProtocol.cursorDown��O���A�v�
�v��t�~�~�/�/�!�3�T�]�]�_�_�q�5H�I������
�
�;�!��%�&rc���|dk\sJ�t|jj|z|jjdz
�|j_|j	d|fz�y)Nr�s[%dC)rjrer�rkr�rfs  rr>zServerProtocol.cursorForward�rlrc��|dk\sJ�t|jj|z
d�|j_|jd|fz�y)Nr�rs[%dD)rdrer�r�rfs  rr@zServerProtocol.cursorBackward�rgrc�<�|jd|dz|dzfz�y)Ns[%d;%dHr��r�)r,rBrCs   rrDzServerProtocol.cursorPosition�s ���
�
�>�T�A�X�v��z�$:�:�;rc�j�dx|j_|j_|jd�y)Nrs)rer�r�r�r.s rrFzServerProtocol.cursorHome�s&��./�/�����4�>�>�+��
�
�9�rc��t|jjdz|jjdz
�|j_|j	d�y)Nr�sDrir.s rrHzServerProtocol.index�s=���t�~�~�/�/�!�3�T�]�]�_�_�q�5H�I������
�
�8�rc��t|jjdz
d�|j_|jd�y)Nr�rsMrcr.s rrJzServerProtocol.reverseIndex�s0���t�~�~�/�/�!�3�Q�7������
�
�8�rc���d|j_t|jjdz|jjdz
�|j_|jd�y)Nrr��
)rer�rjr�rkr�r.s rrLzServerProtocol.nextLine�sI��������t�~�~�/�/�!�3�T�]�]�_�_�q�5H�I������
�
�5�rc��t|jj|jj�|_|jd�y)Ns7)r�rer�r��_savedCursorPosr�r.s rrNzServerProtocol.saveCursor�s1��%�d�n�n�&6�&6����8H�8H�I����
�
�8�rc�L�|j|_|`|jd�y)Ns8)rwrer�r.s rrPzServerProtocol.restoreCursor�s!���-�-���� ��
�
�8�rc�b�djd�|D��}|jd|zdz�y)NrGc3�(K�|]
}d|fz���y�w��%dNr
��.0rVs  r�	<genexpr>z*ServerProtocol.setModes.<locals>.<genexpr>������A�4�u��w��A���r�h�rr��r,rS�
modesBytess   rrTzServerProtocol.setModes��,���Y�Y�A�5�A�A�
��
�
�8�j�(�4�/�0rc�b�djd�|D��}|jd|zdz�y)NrGc3�(K�|]
}d|fz���y�wr{r
r}s  rrz1ServerProtocol.setPrivateModes.<locals>.<genexpr>�r�r��[?r�r�r�s   rrYzServerProtocol.setPrivateModes��,���Y�Y�A�5�A�A�
��
�
�9�z�)�D�0�1rc�b�djd�|D��}|jd|zdz�y)NrGc3�(K�|]
}d|fz���y�wr{r
r}s  rrz,ServerProtocol.resetModes.<locals>.<genexpr>�r�r�r�lr�r�s   rrWzServerProtocol.resetModes�r�rc�b�djd�|D��}|jd|zdz�y)NrGc3�(K�|]
}d|fz���y�wr{r
r}s  rrz3ServerProtocol.resetPrivateModes.<locals>.<genexpr>�r�r�r�r�r�r�s   rr[z ServerProtocol.resetPrivateModes�r�rc�&�|jd�y)Ns=rpr.s rr]z$ServerProtocol.applicationKeypadMode�����
�
�8�rc�&�|jd�y)Ns>rpr.s rr_z ServerProtocol.numericKeypadMode�r�rc��|tk(rd}n|tk(rd}ntd��|tk(rd}n;|tk(rd}n/|t
k(rd}n#|tk(rd}n|tk(rd}ntd	��|jd
|z|z�y)N�(�)z7`which' argument to selectCharacterSet must be G0 or G1r.r4�0�1�2z0Invalid `charSet' argument to selectCharacterSetr�)	�G0�G1r�CS_UK�CS_US�
CS_DRAWING�CS_ALTERNATE�CS_ALTERNATE_SPECIALr�)r,rarbs   rrcz!ServerProtocol.selectCharacterSet�s����B�;��E�
�b�[��E��V�W�W��e���G�
��
��G�
�
�
"��G�
��
$��G�
�,�
,��G��O�P�P��
�
�7�U�?�W�,�-rc�&�|jd�y)N�rpr.s rrezServerProtocol.shiftIn����
�
�7�rc�&�|jd�y)N�rpr.s rrgzServerProtocol.shiftOutr�rc�&�|jd�y)NsNrpr.s rrizServerProtocol.singleShift2
r�rc�&�|jd�y)NsOrpr.s rrkzServerProtocol.singleShift3
r�rc��g}|D]}|jt|���|jddj|�zdz�y)NrrG�m)rr	r�r)r,rm�attrsr�s    rrnz%ServerProtocol.selectGraphicRenditionsF�����	+�A��L�L��q�)�*�	+��
�
�8�d�i�i��.�.��5�6rc�&�|jd�y)NsHrpr.s rrpz&ServerProtocol.horizontalTabulationSetr�rc�&�|jd�y)Nsrpr.s rrrzServerProtocol.tabulationClear����
�
�9�rc�&�|jd�y)Nsrpr.s rrtz!ServerProtocol.tabulationClearAll����
�
�:�rc�N�|r|jd�y|jd�y)Ns#3s#4rp)r,rvs  rrwzServerProtocol.doubleHeightLine s����J�J�y�!��J�J�y�!rc�&�|jd�y)Ns#5rpr.s rryzServerProtocol.singleWidthLine&r�rc�&�|jd�y)Ns#6rpr.s rr{zServerProtocol.doubleWidthLine)r�rc�&�|jd�y)Nsrpr.s rr}zServerProtocol.eraseToLineEnd,r�rc�&�|jd�y)Nsrpr.s rrz#ServerProtocol.eraseToLineBeginning/r�rc�&�|jd�y)Nsrpr.s rr�zServerProtocol.eraseLine2r�rc�&�|jd�y)Nsrpr.s rr�z ServerProtocol.eraseToDisplayEnd5r�rc�&�|jd�y)Nsrpr.s rr�z&ServerProtocol.eraseToDisplayBeginning8r�rc�&�|jd�y)Nsrpr.s rr�zServerProtocol.eraseDisplay;r�rc�.�|jd|fz�y)Ns[%dPrprfs  rr�zServerProtocol.deleteCharacter>����
�
�;�!��%�&rc�.�|jd|fz�y)Ns[%dLrprfs  rr�zServerProtocol.insertLineAr�rc�.�|jd|fz�y)Ns[%dMrprfs  rr�zServerProtocol.deleteLineDr�rc�\�|�d|fz}nd}|�d|fz}nd}|jd||fz�y)Nr|rs[%b;%brrp)r,�first�lasts   r�setScrollRegionzServerProtocol.setScrollRegionGsD�����U�H�$�E��E����D�7�?�D��D��
�
�>�U�D�M�1�2rc�$�|j�yr))r�r.s r�resetScrollRegionz ServerProtocol.resetScrollRegionRs�����rc��tj�}|jj|�|j	d�|S)Ns)r�Deferredr�rr�)r,rRs  rr�z#ServerProtocol.reportCursorPositionUs3���N�N������"�"�1�%��
�
�:���rc��dx|j_|j_	|`|jd�y#t$rY�wxYw)Nrsc)rer�r�rwrr�r.s rr�zServerProtocol.reset[sG��./�/�����4�>�>�+�	��$�	
�
�
�8����	��	�s�8�	A�Ac���|rbt|t�s|jd�}||_|jjdj
|jd���yy)Nzutf-8s
ru)�
isinstancer�r��	lastWriterr�rrI�r,rs  rr�zServerProtocol.writedsM����d�E�*��{�{�7�+��!�D�N��N�N� � ����d�j�j��.?�!@�A�	rc�D�|jdj|��y)Nr)r�rr�s  r�
writeSequencezServerProtocol.writeSequenceks���
�
�3�8�8�D�>�"rc�X�|j�|jj�yr))r�r�loseConnectionr.s rr�zServerProtocol.loseConnectionns���
�
�����%�%�'rc�|�|j�$	|jj|�d|_yy#d|_wxYwr))rr"r4s  rr"zServerProtocol.connectionLostrs@��� � �,�
-��%�%�4�4�V�<�(,��%�	-��)-��%�s�2�	;r)r�r�)NN)Gr#r$r%r�rrV�	BACKSPACEr�rr�rkre�scrollRegionrr�rrr+rrrrrrarr:r<r>r@rDrFrHrJrLrNrPrTrYrWr[r]r_rcrergrirkrnrprrrtrwryr{r}rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r"r
rrr�r��st���O���
�C��I��I��E��b�"�~�H��q�!��I��L��G�!�$K�K�
7�2�>>�
5�<�K�d=�d=�L2�3��'�
'�
'�
'�
<���
��
��
1�
2�1�
2���.�,����7����"���������'�'�'�	3����B�#�(�-rr�c��eZdZdZdZdZdZddddddd	d
ddd
d�Zddddd�Ze	e
eee
d�ZdZdd�Zd�Zd�Zd�Zd�ZGd�d�Ze�Zd�Zy)�ClientProtocolNr�sindexsreverseIndexsnextLines
saveCursors
restoreCursorsapplicationKeypadModesnumericKeypadModessingleShift2ssingleShift3shorizontalTabulationSetsreset)r;�Mr>�7�8�=�>�NrrD�c�bracket-escape�	select-g0�	select-g1�select-height-width)rr�r��#)r.r4r�r�r�c�2�|�||_||_||_y)aw
        @param terminalFactory: A callable which will be invoked with
        *a, **kw and should return an ITerminalTransport provider.
        This will be invoked when this ClientProtocol establishes a
        connection.

        @param a: Any positional arguments to pass to terminalFactory.
        @param kw: Any keyword arguments to pass to terminalFactory.
        N)�terminalFactory�terminalArgs�terminalKwArgs)r,r�r�r�s    rr�zClientProtocol.__init__�s"���&�#2�D� ���� ��rc���|j�b|j|ji|j��|_|j|j_|jj|�yyr))r�r�r�r*rrr.s rr+zClientProtocol.connectionMade�sb�����+�0�D�0�0��"�"��&*�&9�&9��D�M�%)�L�L�D�M�M�!��M�M�(�(��.�,rc�h�|j�	|jj|�|`yy#|`wxYwr))r*r"r4s  rr"zClientProtocol.connectionLost�s6���=�=�$�
"��
�
�,�,�V�4��M�	%���M�s�-�1c�H�g}t|�D�]d}|jdk(�rE|dk(r9|r/|jjdj	|��|dd�=d|_�R|dk(rL|r/|jjdj	|��|dd�=|jj���|dk(rL|r/|jjdj	|��|dd�=|jj
���|dk(rM|r/|jjdj	|��|dd�=|jj���F|j|���Y|jdk(r�|jj|�}|�3d|_t|j|jd	������|jj|�}|�	||_���|jjd|z�d|_��|jd
k(r{|j�g|_|j!�s|dk(r6|j#dj	|j�|�|`d|_��r|jj|����|jdk(rC|jj%|j&j||�t(�d|_���|jd
k(rC|jj%|j&j||�t*�d|_��3|jdk(r|j-|�d|_��\t/d��|r+|jjdj	|��yy)z�
        Parse the given data from a terminal server, dispatching to event
        handlers defined by C{self.terminal}.
        r�r�rNr
r�r��r�r�r�r�r�r�r
)rrr*r�rrgrer@r�_shortsr!rr"�_longsr�_escBufrrrc�	_charsetsr�r��_handleHeightWidthr)r,r�toWrite�b�fNamers      rrzClientProtocol.dataReceived�s���
���4��7	2�A��z�z�W�$���<���
�
�+�+�C�H�H�W�,=�>�#�A�J�!+�D�J��'�\���
�
�+�+�C�H�H�W�,=�>�#�A�J��M�M�*�*�,��'�\���
�
�+�+�C�H�H�W�,=�>�#�A�J��M�M�)�)�+��'�\���
�
�+�+�C�H�H�W�,=�>�#�A�J��M�M�0�0�2��N�N�1�%����z�)����(�(��+���$�!(�D�J�A�G�D�M�M�5�<�<��+@�A�C� �K�K�O�O�A�.�E��(�%*��
��
�
�>�>�w��{�K�%,��
����0�0��<�<�'�#%�D�L��9�9�;�!�t�)��/�/�������0F��J���!(�D�J��L�L�'�'��*����|�+��
�
�0�0����1C�1C�A�q�1I�2�N�$��
����|�+��
�
�0�0����1C�1C�A�q�1I�2�N�$��
����5�5��'�'��*�$��
� ��1�1�o7	2�p��M�M������� 1�2�rc���t|jtj||�j	d�d�}|�"|j
j
d|z|z�y|||j
|�y)Nr�r)rrr r!r"r*r)r,r#r*r�s    rrz%ClientProtocol._handleControlSequencesc����&�&��G�G�H�h�'�.�.�w�7��
��

�9��M�M�2�2�8�c�>�H�3L�M�
�d�D�M�M�3�'rc��eZdZd�ZdD]\ZZeedz��[d�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zy)�$ClientProtocol.ControlSequenceParserc� ���d|z���fd�}|S)N�cursorc���|st|��d�y	t|�}t|��|�y#t$r|jd|z�z�YywxYw)Nr�r)rrKrr)r,r0r1r#�mrr9s     ��r�simplez@ClientProtocol.ControlSequenceParser._makeSimple.<locals>.simplesb����'�G�G�Q�'��*�/���H��,����+�A�.��&�N��8�8��C��"�9L�M�N�s�6� A�Ar
)rr�r�r9s`  @r�_makeSimplez0ClientProtocol.ControlSequenceParser._makeSimples����5� �A�	
/��Mr))r2�Up)r5�Down)r9�Forward)r<�Backwardz = _makeSimple(ch, fName)c���	|jd�D�cgc]
}t|���}}|j|�ycc}w#t$r|j	d|zdz�YywxYw)NrGrr�)rIrKrTrr�r,r0r1r#rVrSs      r�hz&ClientProtocol.ControlSequenceParser.h,sd��
(�/2�y�y���?�t��T��?��?�� � ��'��	@���
H��0�0��C��$�1F�G�
H���A�;�A�A� A#�"A#c���	|jd�D�cgc]
}t|���}}|j|�ycc}w#t$r|j	d|zdz�YywxYw)NrGr�l)rIrKrWrrr�s      rrz&ClientProtocol.ControlSequenceParser.l5sd��
*�/2�y�y���?�t��T��?��?��"�"�5�)��	@���
G��0�0��C��#�1E�F�
G�r�c�~�|jd�}t|�dk(r|jdd�yt|�dk(r@	|drt|d�}nd}|drt|d�}nd}|j||�y|jd|zdz�y#t$r|jd|zdz�YywxYw)NrGr�r�rr�r)rIrJr�rKrr)r,r0r1r#rO�pt�pbs       r�rz&ClientProtocol.ControlSequenceParser.r>s����I�I�d�O�E��5�z�Q���'�'��d�3��U��q��4��Q�x� ��q��]��!���Q�x� ��q��]��!���+�+�B��3��0�0��C��$�1F�G��"�L��4�4�X��^�d�5J�K�L�s�,B� B<�;B<c��|s|j�y|dk(r|j�y|dk(r|j�y|jd|zdz�y)Nr�r�r�K)r}rr�rr/s    r�Kz&ClientProtocol.ControlSequenceParser.KSsN����&�&�(�����,�,�.�����!�!�#��0�0��C��$�1F�Grc�$�|j�yr))rFr/s    rrEz&ClientProtocol.ControlSequenceParser.H]s����� rc��|s|j�y|dk(r|j�y|dk(r|j�y|jd|zdz�y)Nr�r�r�J)r�r�r�rr/s    r�Jz&ClientProtocol.ControlSequenceParser.J`sN����)�)�+�����/�/�1�����$�$�&��0�0��C��$�1F�Grc��|s|jd�y	t|�}|j|�y#t$r|jd|zdz�YywxYw)Nr�rr&)r�rKrr�r,r0r1r#r9s     r�Pz&ClientProtocol.ControlSequenceParser.Pjs[����'�'��*�/��C��A��+�+�A�.��"�L��4�4�X��^�d�5J�K�L���3� A�Ac��|s|jd�y	t|�}|j|�y#t$r|jd|zdz�YywxYw)Nr�r�L)r�rKrrrs     r�Lz&ClientProtocol.ControlSequenceParser.Lu�[����"�"�1�%�*��C��A��&�&�q�)��"�L��4�4�X��^�d�5J�K�L�rc��|s|jd�y	t|�}|j|�y#t$r|jd|zdz�YywxYw)Nr�rr�)r�rKrrrs     r�Mz&ClientProtocol.ControlSequenceParser.M�rrc��|dk(r:|j�\}}|jjd|dz|dzfz�y|jd|zdz�y)N�6s[%d;%dRr�r�n)r�rr�r)r,r0r1r#r�r�s      rr9z&ClientProtocol.ControlSequenceParser.n�sU���d�{��3�3�5���1����%�%�n��A��q�1�u�~�&E�F��0�0��C��$�1F�Grc���|s|jt�yg}|jd�D]}	t|�}|j|��!|j|�y#t$rY�.wxYw)NrG)rn�NORMALrIrKrr)r,r0r1r#r�r�s      rr�z&ClientProtocol.ControlSequenceParser.m�sp����.�.�v�6������4��$�A����F���L�L��O�$�/��.�.��6��&����s�A�	A*�)A*N)r#r$r%r�rr��execr�rrrrErrrrr9r�r
rrrar�sl��	� 
�	3�I�B��
��1�1�2�
	3�
�	(�	*�	H�*	H�	!�	H�		/�		*�		*�	H�	7rrac�D�|dk(r|jjd�y|dk(r|jjd�y|dk(r|jj�y|dk(r|jj�y|jj	d|z�y)N�3T�4F�5rs#)r*rwryr{r)r,r�s  rr�z!ClientProtocol._handleHeightWidth�sx����9��M�M�*�*�4�0�
�$�Y��M�M�*�*�5�1�
�$�Y��M�M�)�)�+�
�$�Y��M�M�)�)�+��M�M�2�2�8�a�<�@rr))r#r$r%r�r*rr�r�r�r�r�r�r�r�r�rr�r+r"rrrarr�r
rrr�r�s����O��H��E��G������&�"���(���G� ���$�	�F�����"��I��G�!� /�"�?3�B	(�K7�K7�Z2�3��
Arr�)rr6rSr��
FUNCTION_KEYSr�r�r�r�r�r�r��G2�G3�	UNDERLINE�
REVERSE_VIDEO�BLINK�BOLDrr�r�N)0r��zope.interfacerr�twisted.internetrr�	iinternetr�twisted.python.compatrr	rr'�
ITransportr6�CSIr rSr�r�r�r�r�r�r�r�r"r#rr'r$r&r%r�r��
_KEY_NAMESr�r�r!�Protocolr��zipr��const�setattrr��__all__)�_names0r�<module>r5s���
�2�E�E�:�&�	�&�R
�
��
�
� �
�0e��-�-�e�P���X��� � �8��,	����
�
���.����
����
��
����
�	�	���
�����
�<7�7�9C�C�u����(�(�*�C�
�
�
� �q-�X�&�&�q-�!�q-�j
�z�=�1�)�K�D�%��N�D�%�(�)�lA�X�&�&�lA�^	���YDs�%D