Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/prompt_toolkit/key_binding/emacs_state.py: 61%

18 statements  

« prev     ^ index     » next       coverage.py v7.2.2, created at 2023-03-26 06:07 +0000

1from __future__ import annotations 

2 

3from typing import List, Optional 

4 

5from .key_processor import KeyPress 

6 

7__all__ = [ 

8 "EmacsState", 

9] 

10 

11 

12class EmacsState: 

13 """ 

14 Mutable class to hold Emacs specific state. 

15 """ 

16 

17 def __init__(self) -> None: 

18 # Simple macro recording. (Like Readline does.) 

19 # (For Emacs mode.) 

20 self.macro: list[KeyPress] | None = [] 

21 self.current_recording: list[KeyPress] | None = None 

22 

23 def reset(self) -> None: 

24 self.current_recording = None 

25 

26 @property 

27 def is_recording(self) -> bool: 

28 "Tell whether we are recording a macro." 

29 return self.current_recording is not None 

30 

31 def start_macro(self) -> None: 

32 "Start recording macro." 

33 self.current_recording = [] 

34 

35 def end_macro(self) -> None: 

36 "End recording macro." 

37 self.macro = self.current_recording 

38 self.current_recording = None