blob: a6742c91a5d7053b104ff61a34bb90a39fc3d5de (
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
46
47
48
49
50
51
52
53
54
55
56
57
|
#pragma once
#include <cstdint>
#include <memory>
#include <string_view>
#include <unordered_map>
#include "engine/data/style.hpp"
#include "engine/data/vector2.hpp"
#include "interfaces/component.hpp"
#include "interfaces/matrix.hpp"
#include "interfaces/statusline.hpp"
class Vector2;
constexpr std::uint32_t STATUSLINE_COLOR = 0x1A1A1AU;
class StatusLine : public IStatusLine
{
public:
explicit StatusLine(std::shared_ptr<ComponentMatrix> component_matrix) noexcept;
auto get() const noexcept -> const std::shared_ptr<ComponentMatrix> & override;
[[nodiscard]] auto get_need_render() const noexcept -> bool override;
void set_need_render(bool need_render) noexcept override;
auto get_foreground_color() const noexcept -> std::uint32_t override;
auto get_background_color() const noexcept -> std::uint32_t override;
void set_section_status(
StatusLineSection section,
const std::string_view &status,
std::int32_t start) noexcept override;
void
set_section_length(StatusLineSection section, std::int32_t length) noexcept override;
void
set_section_style(StatusLineSection section, const Style &style) noexcept override;
private:
std::shared_ptr<ComponentMatrix> _component_matrix;
std::unordered_map<StatusLineSection, std::int32_t> _section_lengths;
std::unordered_map<StatusLineSection, Style> _section_styles;
bool _need_render;
void
_matrix_write_string(const Vector2 &position, const std::string_view &str) noexcept;
[[nodiscard]] auto _get_section_start_x(StatusLineSection section) const noexcept
-> std::int32_t;
void _clear_section(StatusLineSection section, std::int32_t start) noexcept;
};
|