aboutsummaryrefslogtreecommitdiff
path: root/src/commands/toggle_pause.cpp
blob: 434330e6536d4c2c04b309aa4233fc70e3651ed2 (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
#include "toggle_pause.hpp"

#include <fmt/core.h>
#include <utility>

TogglePauseCommand::TogglePauseCommand(
	std::shared_ptr<IGenerationTracker> generation_tracker,
	std::shared_ptr<IStatusLine> statusline
) noexcept
	: _generation_tracker(std::move(generation_tracker)),
	  _statusline(std::move(statusline))
{
}

void TogglePauseCommand::execute() noexcept
{
	auto onoff = !_generation_tracker->get_is_paused();

	_generation_tracker->set_is_paused(onoff);

	_statusline->set_status(
		StatusLineSection::B,
		fmt::format(
			"Paused: {}    Generation: {}",
			_generation_tracker->get_is_paused() ? "yes" : "no",
			_generation_tracker->get_current_generation()
		)
	);
}