From 3a341816bfa275e321e2fe74cada976f7ca3d9bc Mon Sep 17 00:00:00 2001 From: Ted John Date: Thu, 22 Mar 2018 20:44:58 +0000 Subject: [PATCH] Require double CTRL+C to exit --- src/openrct2/interface/StdInOutConsole.cpp | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/openrct2/interface/StdInOutConsole.cpp b/src/openrct2/interface/StdInOutConsole.cpp index 6da9ac4866..b19ef5dca2 100644 --- a/src/openrct2/interface/StdInOutConsole.cpp +++ b/src/openrct2/interface/StdInOutConsole.cpp @@ -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();