Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/prompt_toolkit/key_binding/emacs_state.py: 59%
17 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-20 06:09 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-20 06:09 +0000
1from __future__ import annotations
3from .key_processor import KeyPress
5__all__ = [
6 "EmacsState",
7]
10class EmacsState:
11 """
12 Mutable class to hold Emacs specific state.
13 """
15 def __init__(self) -> None:
16 # Simple macro recording. (Like Readline does.)
17 # (For Emacs mode.)
18 self.macro: list[KeyPress] | None = []
19 self.current_recording: list[KeyPress] | None = None
21 def reset(self) -> None:
22 self.current_recording = None
24 @property
25 def is_recording(self) -> bool:
26 "Tell whether we are recording a macro."
27 return self.current_recording is not None
29 def start_macro(self) -> None:
30 "Start recording macro."
31 self.current_recording = []
33 def end_macro(self) -> None:
34 "End recording macro."
35 self.macro = self.current_recording
36 self.current_recording = None