Skip to content

Commit

Permalink
refactor: Remove internal declaration from header
Browse files Browse the repository at this point in the history
  • Loading branch information
oboukli committed Nov 4, 2023
1 parent 8d54d82 commit 4a2ab2e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# MSBuild

.vs/
*.user
[Dd]ebug/
[Rr]elease/
Expand Down
41 changes: 38 additions & 3 deletions src/cli/trmn_graph_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,51 @@

#include "trmn_graph_windows.hpp"

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#include <algorithm>
#include <array>
#include <cassert>
#include <chrono>
#include <iostream>
#include <thread>

#include "tromino/core/tromino.h"

namespace tromino::cli::windows {

namespace {

constexpr char const neutral{'N'};
constexpr char const empty{'\xB0'};

constexpr char const mark{'\xFE'};
constexpr char const horizontal{'\xCD'};
constexpr char const vertical{'\xBA'};
constexpr char const top_left{'\xC9'};
constexpr char const top_right{'\xBB'};
constexpr char const bottom_left{'\xC8'};
constexpr char const bottom_right{'\xBC'};

void add_tromino(
int const pos_x,
int const pos_y,
int const flip_x,
int const flip_y,
void* const state) noexcept;

void ensure_success(::BOOL const is_success, std::string const& msg) noexcept;

void draw_board(board_t const& board) noexcept;

inline void init_board(board_t const& board) noexcept
{
std::fill_n(board.board_matrix.get(), board.size, empty);

board.board_matrix[calc_index(board.mark_x, board.mark_y, board.order)]
= mark;
}

inline void draw_at(int const x, int const y, char const c) noexcept
{
std::cout << c;
Expand Down Expand Up @@ -50,8 +85,6 @@ void ensure_success(::BOOL const is_success, std::string const& msg) noexcept
}
}

} // namespace

void draw_board(board_t const& board) noexcept
{
int const order{board.order};
Expand Down Expand Up @@ -122,6 +155,8 @@ void add_tromino(
std::this_thread::sleep_for(DELAY_AFTER);
}

} // namespace

void use_wch(board_t& tromino_board, std::ostream& os) noexcept
{
::SetConsoleTitle(TEXT("Tromino Puzzle"));
Expand Down
37 changes: 4 additions & 33 deletions src/cli/trmn_graph_windows.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,16 @@
#ifndef CLI_TRMN_GRAPH_WINDOWS_HPP
#define CLI_TRMN_GRAPH_WINDOWS_HPP

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#ifndef _WIN64
#error "Included Windows-only header"
#endif // ndef _WIN64

#include <algorithm>

#include <tromino/core/tromino.h>
#include <iostream>

#include "trmn_graph.hpp"

namespace tromino::cli::windows {

constexpr char const neutral{'N'};
constexpr char const empty{'\xB0'};

constexpr char const mark{'\xFE'};
constexpr char const horizontal{'\xCD'};
constexpr char const vertical{'\xBA'};
constexpr char const top_left{'\xC9'};
constexpr char const top_right{'\xBB'};
constexpr char const bottom_left{'\xC8'};
constexpr char const bottom_right{'\xBC'};

void draw_board(board_t const& board) noexcept;

void add_tromino(
int const pos_x,
int const pos_y,
int const flip_x,
int const flip_y,
void* const state) noexcept;

inline void init_board(board_t const& board) noexcept
{
std::fill_n(board.board_matrix.get(), board.size, empty);

board.board_matrix[calc_index(board.mark_x, board.mark_y, board.order)]
= mark;
}

void use_wch(board_t& tromino_board, std::ostream& os) noexcept;

} // namespace tromino::cli::windows
Expand Down

0 comments on commit 4a2ab2e

Please sign in to comment.