""" Parser for VT100 input stream. """ from __future__ import unicode_literals import os import re import six import termios import tty from six.moves import range from ..keys import Keys from ..key_binding.input_processor import KeyPress __all__ = ( 'InputStream', 'raw_mode', 'cooked_mode', ) _DEBUG_RENDERER_INPUT = False _DEBUG_RENDERER_INPUT_FILENAME = 'prompt-toolkit-render-input.log' # Regex matching any CPR response # (Note that we use '\Z' instead of '$', because '$' could include a trailing # newline.) _cpr_response_re = re.compile('^' + re.escape('\x1b[') + r'\d+;\d+R\Z') # Mouse events: # Typical: "Esc[MaB*" Urxvt: "Esc[96;14;13M" and for Xterm SGR: "Esc[<64;85;12M" _mouse_event_re = re.compile('^' + re.escape('\x1b[') + r'(