1from __future__ import unicode_literals 2 3from prompt_toolkit.keys import Keys 4 5from ..key_bindings import KeyBindings 6 7__all__ = [ 8 'load_cpr_bindings', 9] 10 11 12def load_cpr_bindings(): 13 key_bindings = KeyBindings() 14 15 @key_bindings.add(Keys.CPRResponse, save_before=lambda e: False) 16 def _(event): 17 """ 18 Handle incoming Cursor-Position-Request response. 19 """ 20 # The incoming data looks like u'\x1b[35;1R' 21 # Parse row/col information. 22 row, col = map(int, event.data[2:-1].split(';')) 23 24 # Report absolute cursor position to the renderer. 25 event.app.renderer.report_absolute_cursor_row(row) 26 27 return key_bindings 28