diff options
author | HampusM <hampus@hampusmat.com> | 2022-03-07 20:20:18 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:55 +0200 |
commit | f0824fdebc79fbf3843c2053522107c33e3ce2a3 (patch) | |
tree | e5bd34fa89cbe80cf8a30596766cf95098465aec /src/engine/user/cursor.hpp | |
parent | 12fffa7df0685ef6d23ffe888a06695ae490df81 (diff) |
refactor: move directions to vector2 & make vector2 hashable
Diffstat (limited to 'src/engine/user/cursor.hpp')
-rw-r--r-- | src/engine/user/cursor.hpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/engine/user/cursor.hpp b/src/engine/user/cursor.hpp index 70a2bf2..84117c1 100644 --- a/src/engine/user/cursor.hpp +++ b/src/engine/user/cursor.hpp @@ -1,13 +1,13 @@ #pragma once #include "DI/auto_wirable.hpp" -#include "interfaces/direction.hpp" #include "engine/data/vector2.hpp" -#include "fmt/core.h" #include <array> +#include <fmt/core.h> #include <memory> +#include <string_view> #include <unordered_map> constexpr std::string_view MOVE_CURSOR_UP = "{esc}[{amount}A"; @@ -22,13 +22,18 @@ constexpr fmt::string_view REQUEST_CURSOR_POSITION = "{esc}[6n"; constexpr fmt::string_view CURSOR_VISIBLE = "{esc}[?25h"; constexpr fmt::string_view CURSOR_INVISIBLE = "{esc}[?25l"; +const std::unordered_map<Vector2, std::string_view, Vector2Hasher> direction_format_map = + {{Vector2::up(), MOVE_CURSOR_UP}, + {Vector2::down(), MOVE_CURSOR_DOWN}, + {Vector2::left(), MOVE_CURSOR_LEFT}, + {Vector2::right(), MOVE_CURSOR_RIGHT}}; + class CursorController : public AutoWirable<CursorController, CursorController> { public: CursorController() = default; - template <Direction::value_type direction> - constexpr void move(const uint32_t &amount) const; + static void move(const Vector2 &direction, const uint32_t &amount); static void move_to(const Vector2 &pos); @@ -38,5 +43,3 @@ public: [[nodiscard]] static Vector2 where(); }; - -#include "cursor.tpp" |