diff --git a/include/TConsole.h b/include/TConsole.h index 1f990b8..22a3b01 100644 --- a/include/TConsole.h +++ b/include/TConsole.h @@ -35,6 +35,7 @@ private: void Command_List(const std::string& cmd, const std::vector& args); void Command_Status(const std::string& cmd, const std::vector& args); void Command_Settings(const std::string& cmd, const std::vector& args); + void Command_Clear(const std::string&, const std::vector& args); void Command_Say(const std::string& FullCommand); bool EnsureArgsCount(const std::vector& args, size_t n); @@ -50,6 +51,7 @@ private: { "list", [this](const auto& a, const auto& b) { Command_List(a, b); } }, { "status", [this](const auto& a, const auto& b) { Command_Status(a, b); } }, { "settings", [this](const auto& a, const auto& b) { Command_Settings(a, b); } }, + { "clear", [this](const auto& a, const auto& b) { Command_Clear(a, b); } }, { "say", [this](const auto&, const auto&) { Command_Say(""); } }, // shouldn't actually be called }; diff --git a/src/TConsole.cpp b/src/TConsole.cpp index c26f957..d26c95e 100644 --- a/src/TConsole.cpp +++ b/src/TConsole.cpp @@ -227,7 +227,8 @@ void TConsole::Command_Help(const std::string&, const std::vector& say sends the message to all players in chat lua [state id] switches to lua, optionally into a specific state id's lua settings [command] sets or gets settings for the server, run `settings help` for more info - status how the server is doing and what it's up to)"; + status how the server is doing and what it's up to + clear clears the console window)"; Application::Console().WriteRaw("BeamMP-Server Console: " + std::string(sHelpString)); } @@ -240,6 +241,13 @@ std::string TConsole::ConcatArgs(const std::vector& args, char spac return Result; } +void TConsole::Command_Clear(const std::string&, const std::vector& args) { + if (!EnsureArgsCount(args, 0, size_t(-1))) { + return; + } + mCommandline.write("\x1b[;H\x1b[2J"); +} + void TConsole::Command_Kick(const std::string&, const std::vector& args) { if (!EnsureArgsCount(args, 1, size_t(-1))) { return;