#include "scene.hpp" #include "engine/escape.hpp" #include "util/color.hpp" #include #include #include #include #include Scene::Scene( IMatrixFactory matrix_factory, std::shared_ptr cursor_controller) noexcept : _is_shown(false), _matrix(matrix_factory(size() - Bounds({.width = 0U, .height = 1U}))), _cursor_controller(std::move(cursor_controller)) { _matrix->fill(" "); } void Scene::enter() noexcept { if (_is_shown) { return; } fmt::print(ENABLE_ALT_BUFFER, fmt::arg("esc", ESC)); std::cout.flush(); _is_shown = true; } void Scene::leave() noexcept { if (!_is_shown) { return; } fmt::print(DISABLE_ALT_BUFFER, fmt::arg("esc", ESC)); std::cout.flush(); _is_shown = false; } auto Scene::size() const noexcept -> Bounds { winsize window_size = {}; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) ioctl(0, TIOCGWINSZ, &window_size); return Bounds({window_size.ws_col, window_size.ws_row}); } auto Scene::get_matrix() const noexcept -> const std::shared_ptr> & { return _matrix; }