aboutsummaryrefslogtreecommitdiff
path: root/src/engine/user/cursor.tpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-03 19:41:23 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:54 +0200
commit93123e97251fc791c1cac193d675cce9a1ac2de6 (patch)
tree4486453695d6f715e767bd91bcee89c92f54f7ba /src/engine/user/cursor.tpp
parent70b21e90d7be4d892b7d17440d64630e7ee1a575 (diff)
feat: add moving cursor
Diffstat (limited to 'src/engine/user/cursor.tpp')
-rw-r--r--src/engine/user/cursor.tpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/engine/user/cursor.tpp b/src/engine/user/cursor.tpp
new file mode 100644
index 0000000..224418e
--- /dev/null
+++ b/src/engine/user/cursor.tpp
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "cursor.hpp"
+
+#include "engine/escape.hpp"
+
+#include <iostream>
+
+constexpr auto get_direction_format_map()
+{
+ std::array<std::string_view, 4> direction_format_map;
+
+ direction_format_map[Direction::UP] = MOVE_CURSOR_UP;
+ direction_format_map[Direction::DOWN] = MOVE_CURSOR_DOWN;
+ direction_format_map[Direction::LEFT] = MOVE_CURSOR_LEFT;
+ direction_format_map[Direction::RIGHT] = MOVE_CURSOR_RIGHT;
+
+ return direction_format_map;
+}
+
+template <Direction::value_type direction>
+constexpr void CursorController::move(const unsigned int &amount) const
+{
+ constexpr auto direction_format_map = get_direction_format_map();
+
+ constexpr auto format = direction_format_map[direction];
+
+ fmt::vprint(format,
+ fmt::make_format_args(fmt::arg("esc", ESC), fmt::arg("amount", amount)));
+ std::cout.flush();
+}