""" Parser for VT100 input stream. """ # Copied from prompt_toolkit/terminal/vt100_input.py due to dependency on termios (which is not available on Windows) from __future__ import unicode_literals import re import six from six.moves import range from prompt_toolkit.keys import Keys from prompt_toolkit.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'(