1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 21:13:05 +01:00

Fix logging of replay info to stdout (#14430)

Use Console::WriteLine and replace \n with \r\n.
This commit is contained in:
Ted John
2021-05-09 19:11:04 +01:00
committed by GitHub
parent 984a660ad7
commit c63e072974
3 changed files with 23 additions and 7 deletions

View File

@@ -134,7 +134,23 @@ void StdInOutConsole::WriteLine(const std::string& s, FormatToken colourFormat)
{
if (_isPromptShowing)
{
std::printf("\r%s%s\x1b[0m\x1b[0K\r\n", formatBegin.c_str(), s.c_str());
auto* mainString = s.c_str();
// If string contains \n, we need to replace with \r\n
std::string newString;
if (s.find('\n') != std::string::npos)
{
for (auto ch : s)
{
if (ch == '\n')
newString += "\r\n";
else
newString += ch;
}
mainString = newString.c_str();
}
std::printf("\r%s%s\x1b[0m\x1b[0K\r\n", formatBegin.c_str(), mainString);
std::fflush(stdout);
linenoise::linenoiseEditRefreshLine();
}