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
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:07 +0000
1from __future__ import annotations
3from typing import List, Optional
5from .key_processor import KeyPress
7__all__ = [
8 "EmacsState",
9]
12class EmacsState:
13 """
14 Mutable class to hold Emacs specific state.
15 """
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
23 def reset(self) -> None:
24 self.current_recording = None
26 @property
27 def is_recording(self) -> bool:
28 "Tell whether we are recording a macro."
29 return self.current_recording is not None
31 def start_macro(self) -> None:
32 "Start recording macro."
33 self.current_recording = []
35 def end_macro(self) -> None:
36 "End recording macro."
37 self.macro = self.current_recording
38 self.current_recording = None