aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/emacs_state.py
diff options
context:
space:
mode:
authornkozlovskiy <nmk@ydb.tech>2023-09-29 12:24:06 +0300
committernkozlovskiy <nmk@ydb.tech>2023-09-29 12:41:34 +0300
commite0e3e1717e3d33762ce61950504f9637a6e669ed (patch)
treebca3ff6939b10ed60c3d5c12439963a1146b9711 /contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/emacs_state.py
parent38f2c5852db84c7b4d83adfcb009eb61541d1ccd (diff)
downloadydb-e0e3e1717e3d33762ce61950504f9637a6e669ed.tar.gz
add ydb deps
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/emacs_state.py')
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/emacs_state.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/emacs_state.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/emacs_state.py
new file mode 100644
index 0000000000..6a2ebf46d8
--- /dev/null
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/emacs_state.py
@@ -0,0 +1,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