Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/prompt_toolkit/key_binding/bindings/cpr.py: 54%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

13 statements  

1from __future__ import annotations 

2 

3from prompt_toolkit.key_binding.key_processor import KeyPressEvent 

4from prompt_toolkit.keys import Keys 

5 

6from ..key_bindings import KeyBindings 

7 

8__all__ = [ 

9 "load_cpr_bindings", 

10] 

11 

12E = KeyPressEvent 

13 

14 

15def load_cpr_bindings() -> KeyBindings: 

16 key_bindings = KeyBindings() 

17 

18 @key_bindings.add(Keys.CPRResponse, save_before=lambda e: False) 

19 def _(event: E) -> None: 

20 """ 

21 Handle incoming Cursor-Position-Request response. 

22 """ 

23 # The incoming data looks like u'\x1b[35;1R' 

24 # Parse row/col information. 

25 row, col = map(int, event.data[2:-1].split(";")) 

26 

27 # Report absolute cursor position to the renderer. 

28 event.app.renderer.report_absolute_cursor_row(row) 

29 

30 return key_bindings