blob: 6a2ebf46d803e03bfab689a27c6e48f437ab355e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  | 
from __future__ import annotations
from .key_processor import KeyPress
__all__ = [
    "EmacsState",
]
class EmacsState:
    """
    Mutable class to hold Emacs specific state.
    """
    def __init__(self) -> None:
        # Simple macro recording. (Like Readline does.)
        # (For Emacs mode.)
        self.macro: list[KeyPress] | None = []
        self.current_recording: list[KeyPress] | None = None
    def reset(self) -> None:
        self.current_recording = None
    @property
    def is_recording(self) -> bool:
        "Tell whether we are recording a macro."
        return self.current_recording is not None
    def start_macro(self) -> None:
        "Start recording macro."
        self.current_recording = []
    def end_macro(self) -> None:
        "End recording macro."
        self.macro = self.current_recording
        self.current_recording = None
  |