Skip to content

Commit

Permalink
Update example
Browse files Browse the repository at this point in the history
Fix encoding issue on Windows
  • Loading branch information
HenryAWE committed May 28, 2024
1 parent 108b912 commit 1ca6bc7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion example/playground/ipapilio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ipapilio::ipapilio()

void ipapilio::mainloop()
{
papilio::println("Papilio Charontis {0[0]}.{0[1]}.{0[2]}", papilio::get_version());
print_info();
papilio::println("Type \"help\" for more information.");

while(!m_quit)
Expand Down Expand Up @@ -62,6 +62,11 @@ void ipapilio::mainloop()
}
}

void ipapilio::print_info()
{
papilio::println("Papilio Charontis {0[0]}.{0[1]}.{0[2]}", papilio::get_version());
}

void ipapilio::build_cmd()
{
auto emplace_cmd = [this](
Expand Down
2 changes: 2 additions & 0 deletions example/playground/ipapilio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class ipapilio

void mainloop();

void print_info();

private:
bool m_quit = false;

Expand Down
15 changes: 15 additions & 0 deletions example/playground/main.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
#include <memory>
#include "ipapilio.hpp"
#ifdef PAPILIO_PLATFORM_WINDOWS
# define WIN32_LEAN_AND_MEAN
# include <Windows.h>
#endif

std::unique_ptr<ipapilio> interactive_con;

int main(int argc, char* argv[])
{
interactive_con = std::make_unique<ipapilio>();

if(!papilio::os::is_terminal(stdout))
{
// Not running in a terminal, print information and quit
interactive_con->print_info();
return 0;
}

#ifdef PAPILIO_PLATFORM_WINDOWS
SetConsoleCP(CP_UTF8);
#endif

interactive_con->mainloop();

return 0;
Expand Down

0 comments on commit 1ca6bc7

Please sign in to comment.