Require double CTRL+C to exit

This commit is contained in:
Ted John 2018-03-22 20:44:58 +00:00
parent 85031f2b9a
commit 3a341816bf
1 changed files with 19 additions and 7 deletions

View File

@ -7,23 +7,35 @@ void StdInOutConsole::Start()
{
std::thread replThread ([this]() -> void
{
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
linenoise::SetMultiLine(true);
linenoise::SetHistoryMaxLen(32);
std::string prompt = "\033[32mopenrct2 $\x1b[0m ";
bool lastPromptQuit = false;
while (true)
{
std::string line;
std::string left = prompt;
auto quit = linenoise::Readline(left.c_str(), line);
if (quit) {
openrct2_finish();
break;
if (quit)
{
if (lastPromptQuit)
{
openrct2_finish();
break;
}
else
{
lastPromptQuit = true;
std::puts("(To exit, press ^C again or type exit)");
}
}
else
{
lastPromptQuit = false;
linenoise::AddHistory(line.c_str());
Eval(line).wait();
}
linenoise::AddHistory(line.c_str());
Eval(line).wait();
}
});
replThread.detach();