blob: 4c996224a077d8e593ca160f16b49a1f3485c59f (
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 typing import List, Optional
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: Optional[List[KeyPress]] = []
self.current_recording: Optional[List[KeyPress]] = 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
|