#include "status_manager.hpp" #include #include StatusManager::StatusManager(std::shared_ptr statusline) noexcept : _statusline(std::move(statusline)) { } void StatusManager::initialize() noexcept { _statusline->set_section_length(StatusLineSection::A, 5); _statusline->set_section_length(StatusLineSection::B, 15); _statusline->set_section_length(StatusLineSection::C, 15); _statusline->set_section_length(StatusLineSection::D, 20); _statusline->set_section_length(StatusLineSection::E, 25); _statusline->set_section_length(StatusLineSection::F, 60); _statusline->set_section_length(StatusLineSection::G, 30); _statusline->set_section_length(StatusLineSection::H, 30); } void StatusManager::set_section_title( const StatusLineSection §ion, const std::string_view &title) noexcept { if (_title_lengths.contains(section)) { fmt::print(stderr, "Error: can't set statusbar section title more than once"); return; } _statusline->set_status(section, title); _title_lengths[section] = static_cast(title.length()); } void StatusManager::set_section_body( const StatusLineSection §ion, const std::string_view &body) noexcept { auto section_title_length = _title_lengths[section]; _statusline->set_status(section, body, section_title_length + 1); } auto StatusManager::get_statusline() const noexcept -> std::shared_ptr { return _statusline; }