blob: 224418e6308880729e8a21b288c584a10e828a59 (
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
|
#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();
}
|