aboutsummaryrefslogtreecommitdiff
path: root/src/engine/user/cursor.hpp
blob: 0317dc53a6eebe507ea100d6d83d8d4313d8837a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include "DI/auto_wirable.hpp"
#include "interfaces/direction.hpp"
#include "interfaces/vector2.hpp"

#include "fmt/core.h"
#include <array>
#include <memory>
#include <unordered_map>

constexpr std::string_view MOVE_CURSOR_UP = "{esc}[{amount}A";
constexpr std::string_view MOVE_CURSOR_DOWN = "{esc}[{amount}B";
constexpr std::string_view MOVE_CURSOR_LEFT = "{esc}[{amount}D";
constexpr std::string_view MOVE_CURSOR_RIGHT = "{esc}[{amount}C";

constexpr fmt::string_view MOVE_CURSOR_TO = "{esc}[{row};{column}H";

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";

class CursorController
	: public AutoWirable<CursorController, CursorController, IVector2Factory>
{
public:
	explicit CursorController(IVector2Factory vector2_factory);

	template <Direction::value_type direction>
	constexpr void move(const unsigned int &amount) const;

	static void move_to(const IVector2 &pos);

	static void hide();

	static void show();

	[[nodiscard]] std::shared_ptr<IVector2> where();

private:
	IVector2Factory _vector2_factory;
};

#include "cursor.tpp"