diff options
42 files changed, 133 insertions, 207 deletions
diff --git a/.clang-format b/.clang-format index 782b0a9..0ad23ca 100644 --- a/.clang-format +++ b/.clang-format @@ -15,5 +15,4 @@ AllowAllArgumentsOnNextLine: false AllowAllParametersOfDeclarationOnNextLine: false BinPackArguments: false BinPackParameters: false -AlignAfterOpenBracket: BlockIndent -Cpp11BracedListStyle: false +AlignAfterOpenBracket: AlwaysBreak diff --git a/src/argument_parser.cpp b/src/argument_parser.cpp index 367262f..117d979 100644 --- a/src/argument_parser.cpp +++ b/src/argument_parser.cpp @@ -21,7 +21,7 @@ void optarg_error(char arg, const std::string_view &error) noexcept */ auto get_str_optarg() noexcept -> std::string_view { - return { optarg }; + return {optarg}; } /** @@ -44,8 +44,7 @@ auto get_uint_optarg(char arg, bool check_zero = false) noexcept -> uint32_t } // namespace ArgumentParser::ArgumentParser( - IRandomNumberGeneratorFactory random_number_generator_factory -) noexcept + IRandomNumberGeneratorFactory random_number_generator_factory) noexcept : _random_number_generator_factory(random_number_generator_factory) { } @@ -54,9 +53,9 @@ auto ArgumentParser::parse( const std::vector<option> &options, const std::string_view &short_options, const int &argc, - char *const *argv -) noexcept -> ParsedArguments // NOLINT(cppcoreguidelines-avoid-c-arrays, - // modernize-avoid-c-arrays) + char *const *argv) noexcept + -> ParsedArguments // NOLINT(cppcoreguidelines-avoid-c-arrays, + // modernize-avoid-c-arrays) { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) const auto args = std::vector<std::string_view>(argv, argv + argc); @@ -66,9 +65,10 @@ auto ArgumentParser::parse( ParsedArguments parsed_arguments; char arg = 0; - while ((arg = static_cast<char>( - getopt_long(argc, argv, short_options.data(), options.data(), nullptr) - )) != -1) + while ( + (arg = static_cast<char>( + getopt_long(argc, argv, short_options.data(), options.data(), nullptr))) != + -1) { switch (arg) { diff --git a/src/argument_parser.hpp b/src/argument_parser.hpp index fee5960..3a32e0b 100644 --- a/src/argument_parser.hpp +++ b/src/argument_parser.hpp @@ -15,16 +15,16 @@ class ArgumentParser AutoWirable<IArgumentParser, ArgumentParser, IRandomNumberGeneratorFactory> { public: - explicit ArgumentParser(IRandomNumberGeneratorFactory random_number_generator_factory - ) noexcept; + explicit ArgumentParser( + IRandomNumberGeneratorFactory random_number_generator_factory) noexcept; auto parse( const std::vector<option> &options, const std::string_view &short_options, const int &argc, - char *const *argv - ) noexcept -> ParsedArguments override; // NOLINT(cppcoreguidelines-avoid-c-arrays, - // modernize-avoid-c-arrays) + char *const *argv) noexcept + -> ParsedArguments override; // NOLINT(cppcoreguidelines-avoid-c-arrays, + // modernize-avoid-c-arrays) private: IRandomNumberGeneratorFactory _random_number_generator_factory; diff --git a/src/bootstrap.cpp b/src/bootstrap.cpp index 7962910..b11f199 100644 --- a/src/bootstrap.cpp +++ b/src/bootstrap.cpp @@ -56,8 +56,7 @@ auto bootstrap() noexcept -> yacppdic::Container [&container]( const std::shared_ptr<IWindow> &window, const std::shared_ptr<IScene> &scene, - const std::shared_ptr<ICursorController> &cursor_controller - ) + const std::shared_ptr<ICursorController> &cursor_controller) { std::shared_ptr<IStatusLine> statusline = container.get<IStatusLineFactory>()(cursor_controller, window); @@ -78,51 +77,43 @@ auto bootstrap() noexcept -> yacppdic::Container statusline, generation_tracker, status_manager, - vector2_statusline_subscriber_adapter_factory - ); - } - ); + vector2_statusline_subscriber_adapter_factory); + }); container.bind<IRandomNumberGeneratorFactory>().to_factory( [](const uint32_t &seed) { return std::make_unique<RandomNumberGenerator>(seed); - } - ); + }); container.bind<IMatrixFactory<std::string_view>>().to_factory( [](const Bounds &bounds) { return std::make_unique<Matrix<std::string_view>>(bounds); - } - ); + }); container.bind<ISceneFactory>().to_factory( [&container]( const std::shared_ptr<ICursorController> &cursor_controller, - const std::shared_ptr<IWindow> &window - ) + const std::shared_ptr<IWindow> &window) { auto matrix_factory = container.get<IMatrixFactory<std::string_view>>(); return std::make_unique<Scene>(matrix_factory, cursor_controller, window); - } - ); + }); container.bind<IStatusLineFactory>().to_factory( [](const std::shared_ptr<ICursorController> &cursor_controller, const std::shared_ptr<IWindow> &window) { return std::make_unique<StatusLine>(cursor_controller, window); - } - ); + }); container.bind<IStatusManagerFactory>().to_factory( [](const std::shared_ptr<IStatusLine> &statusline) { return std::make_unique<StatusManager>(statusline); - } - ); + }); container.bind<IStatusLineSubscriberAdapterFactory<Vector2>>().to_factory( [](const std::shared_ptr<IStatusManager> &status_manager, @@ -142,17 +133,14 @@ auto bootstrap() noexcept -> yacppdic::Container return std::string(""); } }, - sections - ); - } - ); + sections); + }); container.bind<IGenerationTrackerFactory>().to_factory( [](bool is_paused) { return std::make_unique<GenerationTracker>(is_paused); - } - ); + }); return container; } diff --git a/src/commands/insert_cell.cpp b/src/commands/insert_cell.cpp index 3aa0fc8..86a5a52 100644 --- a/src/commands/insert_cell.cpp +++ b/src/commands/insert_cell.cpp @@ -4,8 +4,7 @@ InsertCellCommand::InsertCellCommand( const std::shared_ptr<ICursorController> &cursor_controller, - const std::shared_ptr<IScene> &scene -) noexcept + const std::shared_ptr<IScene> &scene) noexcept : _cursor_controller(cursor_controller), _scene(scene) { } diff --git a/src/commands/insert_cell.hpp b/src/commands/insert_cell.hpp index 7518ece..9d54736 100644 --- a/src/commands/insert_cell.hpp +++ b/src/commands/insert_cell.hpp @@ -11,8 +11,7 @@ class InsertCellCommand : public ICommand public: InsertCellCommand( const std::shared_ptr<ICursorController> &cursor_controller, - const std::shared_ptr<IScene> &scene - ) noexcept; + const std::shared_ptr<IScene> &scene) noexcept; void execute() noexcept override; diff --git a/src/commands/move_cursor.cpp b/src/commands/move_cursor.cpp index fe2f05f..12a247d 100644 --- a/src/commands/move_cursor.cpp +++ b/src/commands/move_cursor.cpp @@ -3,8 +3,7 @@ MoveCursorCommand::MoveCursorCommand( const Vector2 &direction, const std::shared_ptr<ICursorController> &cursor_controller, - const std::shared_ptr<IWindow> &window -) noexcept + const std::shared_ptr<IWindow> &window) noexcept : _direction(direction), _cursor_controller(cursor_controller), _window(window) { diff --git a/src/commands/move_cursor.hpp b/src/commands/move_cursor.hpp index 88d9c42..aab228c 100644 --- a/src/commands/move_cursor.hpp +++ b/src/commands/move_cursor.hpp @@ -14,8 +14,7 @@ public: MoveCursorCommand( const Vector2 &direction, const std::shared_ptr<ICursorController> &cursor_controller, - const std::shared_ptr<IWindow> &window - ) noexcept; + const std::shared_ptr<IWindow> &window) noexcept; void execute() noexcept override; diff --git a/src/commands/toggle_pause.cpp b/src/commands/toggle_pause.cpp index 54682c6..852e093 100644 --- a/src/commands/toggle_pause.cpp +++ b/src/commands/toggle_pause.cpp @@ -5,8 +5,7 @@ TogglePauseCommand::TogglePauseCommand( std::shared_ptr<IGenerationTracker> generation_tracker, - std::shared_ptr<IStatusManager> status_manager -) noexcept + std::shared_ptr<IStatusManager> status_manager) noexcept : _generation_tracker(std::move(generation_tracker)), _status_manager(std::move(status_manager)) { diff --git a/src/commands/toggle_pause.hpp b/src/commands/toggle_pause.hpp index 43502f8..41427cc 100644 --- a/src/commands/toggle_pause.hpp +++ b/src/commands/toggle_pause.hpp @@ -11,8 +11,7 @@ class TogglePauseCommand : public ICommand public: explicit TogglePauseCommand( std::shared_ptr<IGenerationTracker> generation_tracker, - std::shared_ptr<IStatusManager> status_manager - ) noexcept; + std::shared_ptr<IStatusManager> status_manager) noexcept; void execute() noexcept override; diff --git a/src/conversion.hpp b/src/conversion.hpp index 3b5a9df..b1f2438 100644 --- a/src/conversion.hpp +++ b/src/conversion.hpp @@ -12,8 +12,7 @@ public: explicit ConversionResult( const bool &success_, const ResultType &result_, - const std::string_view &fail_reason_ = "" - ) noexcept + const std::string_view &fail_reason_ = "") noexcept : success(success_), result(result_), fail_reason(fail_reason_) { } diff --git a/src/engine/data/vector2.cpp b/src/engine/data/vector2.cpp index 6d8ebad..0f203d0 100644 --- a/src/engine/data/vector2.cpp +++ b/src/engine/data/vector2.cpp @@ -25,7 +25,7 @@ void Vector2::set_y(Vector2::Value y) noexcept auto Vector2::to_direction(const Vector2 &direction, Vector2::Value amount) const noexcept -> Vector2 { - return *this + (direction * Vector2({ .x = amount, .y = amount })); + return *this + (direction * Vector2({.x = amount, .y = amount})); } auto Vector2::operator+=(const Vector2 &rhs) noexcept -> const Vector2 & diff --git a/src/engine/data/vector2.hpp b/src/engine/data/vector2.hpp index a6de35e..15df88f 100644 --- a/src/engine/data/vector2.hpp +++ b/src/engine/data/vector2.hpp @@ -48,7 +48,7 @@ public: */ static constexpr auto up() noexcept -> Vector2 { - return Vector2({ .x = 0, .y = -1 }); + return Vector2({.x = 0, .y = -1}); } /** @@ -56,7 +56,7 @@ public: */ static constexpr auto down() noexcept -> Vector2 { - return Vector2({ .x = 0, .y = 1 }); + return Vector2({.x = 0, .y = 1}); } /** @@ -65,7 +65,7 @@ public: static constexpr auto left() noexcept -> Vector2 { - return Vector2({ .x = -1, .y = 0 }); + return Vector2({.x = -1, .y = 0}); } /** @@ -73,7 +73,7 @@ public: */ static constexpr auto right() noexcept -> Vector2 { - return Vector2({ .x = 1, .y = 0 }); + return Vector2({.x = 1, .y = 0}); } private: diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 3bf8503..4ac6a37 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -10,8 +10,7 @@ CLIGameEngine::CLIGameEngine( ISceneFactory scene_factory, std::shared_ptr<IInputHandler> input_handler, std::shared_ptr<ICursorController> cursor_controller, - std::shared_ptr<IWindow> window -) noexcept + std::shared_ptr<IWindow> window) noexcept : _game_factory(std::move(game_factory)), _scene_factory(std::move(scene_factory)), _input_handler(std::move(input_handler)), @@ -38,8 +37,7 @@ void CLIGameEngine::start() noexcept _input_handler->leave_raw_mode(); game->on_exit(); - } - )); + })); _configure_input(game->get_input_config()); @@ -47,8 +45,7 @@ void CLIGameEngine::start() noexcept [this]() { _input_handler->listen(); - } - )); + })); while (true) { @@ -57,8 +54,7 @@ void CLIGameEngine::start() noexcept } void CLIGameEngine::_configure_input( - const std::unordered_map<char, std::shared_ptr<ICommand>> &input_config -) noexcept + const std::unordered_map<char, std::shared_ptr<ICommand>> &input_config) noexcept { for (const auto &config_pair : input_config) { diff --git a/src/engine/engine.hpp b/src/engine/engine.hpp index cf162d9..5073553 100644 --- a/src/engine/engine.hpp +++ b/src/engine/engine.hpp @@ -29,8 +29,7 @@ public: ISceneFactory scene_factory, std::shared_ptr<IInputHandler> input_handler, std::shared_ptr<ICursorController> cursor_controller, - std::shared_ptr<IWindow> window - ) noexcept; + std::shared_ptr<IWindow> window) noexcept; void start() noexcept override; @@ -43,6 +42,5 @@ private: std::shared_ptr<IWindow> _window; void _configure_input( - const std::unordered_map<char, std::shared_ptr<ICommand>> &input_config - ) noexcept; + const std::unordered_map<char, std::shared_ptr<ICommand>> &input_config) noexcept; }; diff --git a/src/engine/graphics/scene.cpp b/src/engine/graphics/scene.cpp index d5cf89b..73c1292 100644 --- a/src/engine/graphics/scene.cpp +++ b/src/engine/graphics/scene.cpp @@ -11,10 +11,9 @@ Scene::Scene( IMatrixFactory<std::string_view> matrix_factory, std::shared_ptr<ICursorController> cursor_controller, - std::shared_ptr<IWindow> window -) noexcept + std::shared_ptr<IWindow> window) noexcept : _is_shown(false), - _matrix(matrix_factory(window->size() - Bounds({ .width = 0U, .height = 1U }))), + _matrix(matrix_factory(window->size() - Bounds({.width = 0U, .height = 1U}))), _cursor_controller(std::move(cursor_controller)), _window(std::move(window)) { diff --git a/src/engine/graphics/scene.hpp b/src/engine/graphics/scene.hpp index aaf0095..5e74725 100644 --- a/src/engine/graphics/scene.hpp +++ b/src/engine/graphics/scene.hpp @@ -18,8 +18,7 @@ public: explicit Scene( IMatrixFactory<std::string_view> matrix_factory, std::shared_ptr<ICursorController> cursor_controller, - std::shared_ptr<IWindow> window - ) noexcept; + std::shared_ptr<IWindow> window) noexcept; void enter() noexcept override; diff --git a/src/engine/graphics/statusline.cpp b/src/engine/graphics/statusline.cpp index 1abb87b..3968fae 100644 --- a/src/engine/graphics/statusline.cpp +++ b/src/engine/graphics/statusline.cpp @@ -8,8 +8,7 @@ StatusLine::StatusLine( std::shared_ptr<ICursorController> cursor_controller, - std::shared_ptr<IWindow> window -) noexcept + std::shared_ptr<IWindow> window) noexcept : _cursor_controller(std::move(cursor_controller)), _window(std::move(window)) { } @@ -29,8 +28,7 @@ void StatusLine::initialize_background() noexcept void StatusLine::set_status( const StatusLineSection §ion, const std::string_view &status, - std::size_t start -) noexcept + std::size_t start) noexcept { _clear_section(section, start); @@ -51,8 +49,7 @@ void StatusLine::set_status( void StatusLine::set_section_length( const StatusLineSection §ion, - uint32_t length -) noexcept + uint32_t length) noexcept { _sections_lengths[section] = length; } @@ -67,7 +64,7 @@ auto StatusLine::_move_to_statusline(int32_t x) noexcept -> Vector2 auto window_height = static_cast<Vector2::Value>(window_size.get_height()); - _cursor_controller->move_to(Vector2({ .x = x, .y = window_height }), true); + _cursor_controller->move_to(Vector2({.x = x, .y = window_height}), true); return previous_position; } @@ -87,9 +84,8 @@ auto StatusLine::_get_section_start_x(const StatusLineSection §ion) const no while (section_index > 0) { - section_start += - static_cast<int32_t>(_sections_lengths.at(StatusLineSection(section_index - 1) - )); + section_start += static_cast<int32_t>( + _sections_lengths.at(StatusLineSection(section_index - 1))); section_index--; } @@ -99,8 +95,7 @@ auto StatusLine::_get_section_start_x(const StatusLineSection §ion) const no void StatusLine::_clear_section( const StatusLineSection §ion, - std::size_t start -) noexcept + std::size_t start) noexcept { auto section_start = _get_section_start_x(section); diff --git a/src/engine/graphics/statusline.hpp b/src/engine/graphics/statusline.hpp index 181090d..add8e02 100644 --- a/src/engine/graphics/statusline.hpp +++ b/src/engine/graphics/statusline.hpp @@ -19,16 +19,14 @@ class StatusLine : public IStatusLine public: StatusLine( std::shared_ptr<ICursorController> cursor_controller, - std::shared_ptr<IWindow> window - ) noexcept; + std::shared_ptr<IWindow> window) noexcept; void initialize_background() noexcept override; void set_status( const StatusLineSection §ion, const std::string_view &status, - std::size_t start - ) noexcept override; + std::size_t start) noexcept override; void set_section_length(const StatusLineSection §ion, uint32_t length) noexcept override; @@ -43,8 +41,8 @@ private: void _move_back(Vector2 previous_position) noexcept; - [[nodiscard]] auto _get_section_start_x(const StatusLineSection §ion - ) const noexcept -> int32_t; + [[nodiscard]] auto + _get_section_start_x(const StatusLineSection §ion) const noexcept -> int32_t; void _clear_section(const StatusLineSection §ion, std::size_t start) noexcept; }; diff --git a/src/engine/graphics/window.cpp b/src/engine/graphics/window.cpp index 2d880fc..bb33402 100644 --- a/src/engine/graphics/window.cpp +++ b/src/engine/graphics/window.cpp @@ -9,5 +9,5 @@ auto Window::size() const noexcept -> Bounds // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) ioctl(0, TIOCGWINSZ, &window_size); - return Bounds({ window_size.ws_col, window_size.ws_row }); + return Bounds({window_size.ws_col, window_size.ws_row}); } diff --git a/src/engine/matrix_iterator.tpp b/src/engine/matrix_iterator.tpp index 9697861..4b2c785 100644 --- a/src/engine/matrix_iterator.tpp +++ b/src/engine/matrix_iterator.tpp @@ -73,8 +73,7 @@ auto MatrixRow<Element>::end() const noexcept -> MatrixRowIterator<Element> template <typename Element> MatrixIterator<Element>::MatrixIterator( RowPtr row_ptr, - const uint32_t &column_cnt -) noexcept + const uint32_t &column_cnt) noexcept : _row_ptr(row_ptr), _column_cnt(column_cnt) { } diff --git a/src/engine/user/cursor.cpp b/src/engine/user/cursor.cpp index 71f02da..945433b 100644 --- a/src/engine/user/cursor.cpp +++ b/src/engine/user/cursor.cpp @@ -5,7 +5,7 @@ #include <cstdlib> #include <iostream> -CursorController::CursorController() noexcept : _position({ .x = 0, .y = 0 }) {} +CursorController::CursorController() noexcept : _position({.x = 0, .y = 0}) {} void CursorController::move(const Vector2 &direction, const uint32_t &amount) noexcept { @@ -14,8 +14,7 @@ void CursorController::move(const Vector2 &direction, const uint32_t &amount) no fmt::print( fmt::runtime(direction_format.data()), fmt::arg("esc", ESC), - fmt::arg("amount", amount) - ); + fmt::arg("amount", amount)); std::cout.flush(); _position = _position.to_direction(direction, static_cast<Vector2::Value>(amount)); @@ -29,8 +28,7 @@ void CursorController::move_to(const Vector2 &position, bool silent) noexcept MOVE_CURSOR_TO, fmt::arg("esc", ESC), fmt::arg("row", position.get_y()), - fmt::arg("column", position.get_x()) - ); + fmt::arg("column", position.get_x())); std::cout.flush(); _position = position; @@ -75,12 +73,11 @@ void CursorController::show() noexcept void CursorController::subscribe( const Event &event, - const Subscriber &subscriber -) noexcept + const Subscriber &subscriber) noexcept { if (_subscribers.count(event) == 0) { - _subscribers.insert({ event, std::vector<Subscriber>() }); + _subscribers.insert({event, std::vector<Subscriber>()}); } _subscribers.at(event).push_back(subscriber); diff --git a/src/engine/user/cursor.hpp b/src/engine/user/cursor.hpp index 080321e..ae6fe3c 100644 --- a/src/engine/user/cursor.hpp +++ b/src/engine/user/cursor.hpp @@ -24,11 +24,11 @@ constexpr fmt::string_view REQUEST_CURSOR_POSITION = "{esc}[6n"; constexpr fmt::string_view CURSOR_VISIBLE = "{esc}[?25h"; constexpr fmt::string_view CURSOR_INVISIBLE = "{esc}[?25l"; -const std::unordered_map<Vector2, std::string_view, Vector2Hasher> - direction_format_map = { { Vector2::up(), MOVE_CURSOR_UP }, - { Vector2::down(), MOVE_CURSOR_DOWN }, - { Vector2::left(), MOVE_CURSOR_LEFT }, - { Vector2::right(), MOVE_CURSOR_RIGHT } }; +const std::unordered_map<Vector2, std::string_view, Vector2Hasher> direction_format_map = + {{Vector2::up(), MOVE_CURSOR_UP}, + {Vector2::down(), MOVE_CURSOR_DOWN}, + {Vector2::left(), MOVE_CURSOR_LEFT}, + {Vector2::right(), MOVE_CURSOR_RIGHT}}; class CursorController : public ICursorController, public yacppdic::AutoWirable<ICursorController, CursorController> diff --git a/src/engine/user/input.cpp b/src/engine/user/input.cpp index d335fc9..7e9fe22 100644 --- a/src/engine/user/input.cpp +++ b/src/engine/user/input.cpp @@ -15,8 +15,7 @@ void InputHandler::listen() const noexcept void InputHandler::subscribe( const Event &event, - const std::shared_ptr<ISubscriber<Context>> &subscriber -) noexcept + const std::shared_ptr<ISubscriber<Context>> &subscriber) noexcept { auto event_index = _event_as_index(event); diff --git a/src/engine/user/input.hpp b/src/engine/user/input.hpp index c88809d..f17472b 100644 --- a/src/engine/user/input.hpp +++ b/src/engine/user/input.hpp @@ -21,8 +21,7 @@ public: void subscribe( const Event &event, - const std::shared_ptr<ISubscriber<Context>> &subscriber - ) noexcept override; + const std::shared_ptr<ISubscriber<Context>> &subscriber) noexcept override; void notify_subscribers(const Event &event, const Context &context) const noexcept override; diff --git a/src/game/game.cpp b/src/game/game.cpp index 02a0f65..4201b7b 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -17,8 +17,7 @@ Game::Game( std::shared_ptr<IGenerationTracker> generation_tracker, std::shared_ptr<IStatusManager> status_manager, IStatusLineSubscriberAdapterFactory<Vector2> - vector2_statusline_subscriber_adapter_factory -) noexcept + vector2_statusline_subscriber_adapter_factory) noexcept : _window(std::move(window)), _scene(std::move(scene)), _cursor_controller(std::move(cursor_controller)), @@ -26,8 +25,7 @@ Game::Game( _generation_tracker(std::move(generation_tracker)), _status_manager(std::move(status_manager)), _vector2_statusline_subscriber_adapter_factory( - vector2_statusline_subscriber_adapter_factory - ) + vector2_statusline_subscriber_adapter_factory) { } @@ -44,36 +42,31 @@ void Game::on_start() noexcept std::shared_ptr<ISubscriber<Vector2>> vector2_statusline_subscriber_adapter = _vector2_statusline_subscriber_adapter_factory( _status_manager, - { StatusLineSection::B, StatusLineSection::C } - ); + {StatusLineSection::B, StatusLineSection::C}); _cursor_controller->subscribe( CursorEvent::POSITION_CHANGE, - vector2_statusline_subscriber_adapter - ); + vector2_statusline_subscriber_adapter); const auto window_size = _window->size(); - const auto center_position = - Vector2({ .x = static_cast<Vector2::Value>(window_size.get_width()) / 2, - .y = static_cast<Vector2::Value>(window_size.get_height()) / 2 }); + const auto center_position = Vector2( + {.x = static_cast<Vector2::Value>(window_size.get_width()) / 2, + .y = static_cast<Vector2::Value>(window_size.get_height()) / 2}); _cursor_controller->move_to(center_position); _status_manager->set_section_body( StatusLineSection::B, - fmt::format("{}", center_position.get_x()) - ); + fmt::format("{}", center_position.get_x())); _status_manager->set_section_body( StatusLineSection::C, - fmt::format("{}", center_position.get_y()) - ); + fmt::format("{}", center_position.get_y())); _status_manager->set_section_body( StatusLineSection::D, - _generation_tracker->get_is_paused() ? "yes" : "no" - ); + _generation_tracker->get_is_paused() ? "yes" : "no"); _status_manager->set_section_body(StatusLineSection::E, "0"); } @@ -99,33 +92,24 @@ auto Game::get_input_config() const noexcept -> std::unordered_map<char, std::shared_ptr<ICommand>> { return { - { 'q', std::make_shared<QuitCommand>() }, - { 'i', std::make_shared<InsertCellCommand>(_cursor_controller, _scene) }, - { 'p', - std::make_shared<TogglePauseCommand>(_generation_tracker, _status_manager) }, - { 'k', - std::make_shared<MoveCursorCommand>( - Vector2::up(), - _cursor_controller, - _window - ) }, - { 'j', - std::make_shared<MoveCursorCommand>( - Vector2::down(), - _cursor_controller, - _window - ) }, - { 'h', - std::make_shared<MoveCursorCommand>( - Vector2::left(), - _cursor_controller, - _window - ) }, - { 'l', - std::make_shared<MoveCursorCommand>( - Vector2::right(), - _cursor_controller, - _window - ) } - }; + {'q', std::make_shared<QuitCommand>()}, + {'i', std::make_shared<InsertCellCommand>(_cursor_controller, _scene)}, + {'p', std::make_shared<TogglePauseCommand>(_generation_tracker, _status_manager)}, + {'k', + std::make_shared<MoveCursorCommand>(Vector2::up(), _cursor_controller, _window)}, + {'j', + std::make_shared<MoveCursorCommand>( + Vector2::down(), + _cursor_controller, + _window)}, + {'h', + std::make_shared<MoveCursorCommand>( + Vector2::left(), + _cursor_controller, + _window)}, + {'l', + std::make_shared<MoveCursorCommand>( + Vector2::right(), + _cursor_controller, + _window)}}; } diff --git a/src/game/game.hpp b/src/game/game.hpp index 9689215..fac9061 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -22,8 +22,7 @@ public: std::shared_ptr<IGenerationTracker> generation_tracker, std::shared_ptr<IStatusManager> status_manager, IStatusLineSubscriberAdapterFactory<Vector2> - vector2_statusline_subscriber_adapter_factory - ) noexcept; + vector2_statusline_subscriber_adapter_factory) noexcept; void on_start() noexcept override; diff --git a/src/game/status_manager.cpp b/src/game/status_manager.cpp index 727452c..927f645 100644 --- a/src/game/status_manager.cpp +++ b/src/game/status_manager.cpp @@ -18,8 +18,7 @@ StatusManager::StatusManager(std::shared_ptr<IStatusLine> statusline) noexcept void StatusManager::set_section_title( const StatusLineSection §ion, - const std::string_view &title -) noexcept + const std::string_view &title) noexcept { if (_title_lengths.count(section) != 0) { @@ -34,8 +33,7 @@ void StatusManager::set_section_title( void StatusManager::set_section_body( const StatusLineSection §ion, - const std::string_view &body -) noexcept + const std::string_view &body) noexcept { auto section_title_length = _title_lengths[section]; diff --git a/src/game/status_manager.hpp b/src/game/status_manager.hpp index 62b5bc7..cdc9de5 100644 --- a/src/game/status_manager.hpp +++ b/src/game/status_manager.hpp @@ -17,13 +17,11 @@ public: void set_section_title( const StatusLineSection §ion, - const std::string_view &title - ) noexcept override; + const std::string_view &title) noexcept override; void set_section_body( const StatusLineSection §ion, - const std::string_view &body - ) noexcept override; + const std::string_view &body) noexcept override; private: std::shared_ptr<IStatusLine> _statusline; diff --git a/src/game/statusline_subscriber_adapter.hpp b/src/game/statusline_subscriber_adapter.hpp index d53ae04..c0c5805 100644 --- a/src/game/statusline_subscriber_adapter.hpp +++ b/src/game/statusline_subscriber_adapter.hpp @@ -15,8 +15,7 @@ public: StatusLineSubscriberAdapter( std::shared_ptr<IStatusManager> status_manager, std::string (*format_func)(std::size_t section_index, const Context &context), - const std::vector<StatusLineSection> §ions - ) noexcept; + const std::vector<StatusLineSection> §ions) noexcept; void update(const Context &context) noexcept override; diff --git a/src/game/statusline_subscriber_adapter.tpp b/src/game/statusline_subscriber_adapter.tpp index 1de459c..9054772 100644 --- a/src/game/statusline_subscriber_adapter.tpp +++ b/src/game/statusline_subscriber_adapter.tpp @@ -10,7 +10,7 @@ StatusLineSubscriberAdapter<Context>::StatusLineSubscriberAdapter( std::string (*format_func)(std::size_t section_index, const Context &context), const std::vector<StatusLineSection> §ions -) noexcept + ) noexcept : _status_manager(std::move(status_manager)), _format_func(format_func), _sections(sections) diff --git a/src/game_of_life.cpp b/src/game_of_life.cpp index a6c327d..2d6d5ee 100644 --- a/src/game_of_life.cpp +++ b/src/game_of_life.cpp @@ -6,9 +6,10 @@ #include <getopt.h> #include <vector> -const std::vector<option> options = { option({ "seed", required_argument, nullptr, 's' }), - option({ "help", no_argument, nullptr, 'h' }), - option({ nullptr, 0, nullptr, 0 }) }; +const std::vector<option> options = { + option({"seed", required_argument, nullptr, 's'}), + option({"help", no_argument, nullptr, 'h'}), + option({nullptr, 0, nullptr, 0})}; auto main(int argc, char *argv[]) noexcept -> int { diff --git a/src/interfaces/argument_parser.hpp b/src/interfaces/argument_parser.hpp index d2dfb03..6415422 100644 --- a/src/interfaces/argument_parser.hpp +++ b/src/interfaces/argument_parser.hpp @@ -22,7 +22,7 @@ public: const std::vector<option> &options, const std::string_view &short_options, const int &argc, - char *const *argv - ) noexcept -> ParsedArguments = 0; // NOLINT(cppcoreguidelines-avoid-c-arrays, - // modernize-avoid-c-arrays) + char *const *argv) noexcept + -> ParsedArguments = 0; // NOLINT(cppcoreguidelines-avoid-c-arrays, + // modernize-avoid-c-arrays) }; diff --git a/src/interfaces/game.hpp b/src/interfaces/game.hpp index dee2218..e4df51c 100644 --- a/src/interfaces/game.hpp +++ b/src/interfaces/game.hpp @@ -35,5 +35,4 @@ using IGameFactory = std::unique_ptr<IGame> (*)( using IGameFactory = yacppdic::Factory<std::unique_ptr<IGame>( const std::shared_ptr<IWindow> &window, const std::shared_ptr<IScene> &scene, - const std::shared_ptr<ICursorController> &cursor_controller -)>; + const std::shared_ptr<ICursorController> &cursor_controller)>; diff --git a/src/interfaces/input.hpp b/src/interfaces/input.hpp index df4abb8..f93a8e2 100644 --- a/src/interfaces/input.hpp +++ b/src/interfaces/input.hpp @@ -19,8 +19,7 @@ public: void subscribe( const Event &event, - const std::shared_ptr<ISubscriber<Context>> &subscriber - ) noexcept override = 0; + const std::shared_ptr<ISubscriber<Context>> &subscriber) noexcept override = 0; void notify_subscribers(const Event &event, const Context &context) const noexcept override = 0; diff --git a/src/interfaces/publisher.hpp b/src/interfaces/publisher.hpp index 4e66d64..2c47c34 100644 --- a/src/interfaces/publisher.hpp +++ b/src/interfaces/publisher.hpp @@ -14,8 +14,7 @@ public: virtual void subscribe( const Event &event, - const std::shared_ptr<ISubscriber<Context>> &subscriber - ) noexcept = 0; + const std::shared_ptr<ISubscriber<Context>> &subscriber) noexcept = 0; virtual void notify_subscribers(const Event &event, const Context &context) const noexcept = 0; diff --git a/src/interfaces/scene.hpp b/src/interfaces/scene.hpp index 105b173..01be07d 100644 --- a/src/interfaces/scene.hpp +++ b/src/interfaces/scene.hpp @@ -24,5 +24,4 @@ public: using ISceneFactory = yacppdic::Factory<std::unique_ptr<IScene>( const std::shared_ptr<ICursorController> &cursor_controller, - const std::shared_ptr<IWindow> &window -)>; + const std::shared_ptr<IWindow> &window)>; diff --git a/src/interfaces/status_manager.hpp b/src/interfaces/status_manager.hpp index afc8416..94464f0 100644 --- a/src/interfaces/status_manager.hpp +++ b/src/interfaces/status_manager.hpp @@ -15,14 +15,12 @@ public: virtual void set_section_title( const StatusLineSection §ion, - const std::string_view &title - ) noexcept = 0; + const std::string_view &title) noexcept = 0; virtual void set_section_body( const StatusLineSection §ion, - const std::string_view &body - ) noexcept = 0; + const std::string_view &body) noexcept = 0; }; -using IStatusManagerFactory = yacppdic::Factory< - std::unique_ptr<IStatusManager>(const std::shared_ptr<IStatusLine> &statusline)>; +using IStatusManagerFactory = yacppdic::Factory<std::unique_ptr<IStatusManager>( + const std::shared_ptr<IStatusLine> &statusline)>; diff --git a/src/interfaces/statusline.hpp b/src/interfaces/statusline.hpp index 2b61d24..ca2a617 100644 --- a/src/interfaces/statusline.hpp +++ b/src/interfaces/statusline.hpp @@ -28,8 +28,7 @@ public: virtual void set_status( const StatusLineSection §ion, const std::string_view &status, - std::size_t start = 1UL - ) noexcept = 0; + std::size_t start = 1UL) noexcept = 0; virtual void set_section_length(const StatusLineSection §ion, uint32_t length) noexcept = 0; @@ -37,5 +36,4 @@ public: using IStatusLineFactory = yacppdic::Factory<std::unique_ptr<IStatusLine>( const std::shared_ptr<ICursorController> &cursor_controller, - const std::shared_ptr<IWindow> &window -)>; + const std::shared_ptr<IWindow> &window)>; diff --git a/src/interfaces/statusline_subscriber_adapter.hpp b/src/interfaces/statusline_subscriber_adapter.hpp index 53543f7..925341f 100644 --- a/src/interfaces/statusline_subscriber_adapter.hpp +++ b/src/interfaces/statusline_subscriber_adapter.hpp @@ -13,5 +13,4 @@ template <typename Context> using IStatusLineSubscriberAdapterFactory = yacppdic::Factory<std::unique_ptr<ISubscriber<Context>>( const std::shared_ptr<IStatusManager> &status_manager, - std::vector<StatusLineSection> sections - )>; + std::vector<StatusLineSection> sections)>; diff --git a/src/util/color.cpp b/src/util/color.cpp index 8f23f41..8ec3ad4 100644 --- a/src/util/color.cpp +++ b/src/util/color.cpp @@ -5,13 +5,11 @@ auto get_foreground_esc_seq(const uint32_t &color) noexcept -> std::string { return { - fmt::detail::make_foreground_color<char>(fmt::detail::color_type(color)).begin() - }; + fmt::detail::make_foreground_color<char>(fmt::detail::color_type(color)).begin()}; } auto get_background_esc_seq(const uint32_t &color) noexcept -> std::string { return { - fmt::detail::make_background_color<char>(fmt::detail::color_type(color)).begin() - }; + fmt::detail::make_background_color<char>(fmt::detail::color_type(color)).begin()}; } diff --git a/src/util/function.tpp b/src/util/function.tpp index 0a7a6d6..9d3d38c 100644 --- a/src/util/function.tpp +++ b/src/util/function.tpp @@ -52,8 +52,8 @@ get_normalized_lambda(Function &&func, Signature<Return(Args...)> /*unused*/) no // lamda capture static auto static_func = Function(std::forward<Function>(func)); - return +[](Args... args) noexcept(noexcept(std::declval<Function>( - )(std::forward<Args>(args)...))) -> Return + return +[](Args... args) noexcept( + noexcept(std::declval<Function>()(std::forward<Args>(args)...))) -> Return { return static_func(std::forward<Args>(args)...); }; @@ -72,6 +72,5 @@ constexpr auto normalize_lambda(Function &&func) noexcept { return get_normalized_lambda( std::forward<Function>(func), - extract_signature(std::forward<Function>(func)) - ); + extract_signature(std::forward<Function>(func))); } |