aboutsummaryrefslogtreecommitdiff
path: root/src/input_actions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_actions.cpp')
-rw-r--r--src/input_actions.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/input_actions.cpp b/src/input_actions.cpp
new file mode 100644
index 0000000..854dc62
--- /dev/null
+++ b/src/input_actions.cpp
@@ -0,0 +1,35 @@
+#include "input_actions.hpp"
+
+#include <fmt/core.h>
+
+namespace InputActions
+{
+
+void exit_success()
+{
+ exit(EXIT_SUCCESS);
+}
+
+Callback move_cursor(const Vector2 &direction,
+ const std::shared_ptr<ICursorController> &cursor_controller,
+ const std::shared_ptr<IWindow> &window)
+{
+ return [direction, cursor_controller, window]()
+ {
+ constexpr int32_t amount = 1;
+
+ const auto new_position =
+ cursor_controller->where().to_direction(direction, amount);
+
+ const auto window_size = window->size();
+
+ if (window_size.validate_coords(new_position) != CoordsValidation::VALID)
+ {
+ return;
+ }
+
+ cursor_controller->move_to(new_position);
+ };
+}
+
+} // namespace InputActions