aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/input.hpp17
-rw-r--r--src/interfaces/observable.hpp16
2 files changed, 33 insertions, 0 deletions
diff --git a/src/interfaces/input.hpp b/src/interfaces/input.hpp
new file mode 100644
index 0000000..956ec4f
--- /dev/null
+++ b/src/interfaces/input.hpp
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "interfaces/observable.hpp"
+
+class IInputHandler : public IObservable<char>
+{
+public:
+ void listen() const override = 0;
+
+ void attach(const char &event, Callback callback) override = 0;
+
+ void notify(const char &event) const override = 0;
+
+ virtual void enter_raw_mode() = 0;
+
+ virtual void leave_raw_mode() = 0;
+};
diff --git a/src/interfaces/observable.hpp b/src/interfaces/observable.hpp
new file mode 100644
index 0000000..ca8ffda
--- /dev/null
+++ b/src/interfaces/observable.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <functional>
+
+using Callback = std::function<void()>;
+
+template <typename Event>
+class IObservable
+{
+public:
+ virtual void listen() const = 0;
+
+ virtual void attach(const Event &event, Callback callback) = 0;
+
+ virtual void notify(const Event &event) const = 0;
+};