diff --git a/gui/console.cpp b/gui/console.cpp index 4bfcac94171..262860c9cac 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -133,6 +133,18 @@ void ConsoleDialog::resetPrompt() { _prompt = PROMPT; } +void ConsoleDialog::clearBuffer() { + // Reset the line buffer. + memset(_buffer, ' ', kBufferSize); + + // Along with a few key vars. + _currentPos = 0; + _scrollLine = _linesPerPage - 1; + _firstLineInBuffer = 0; + + updateScrollBuffer(); +} + void ConsoleDialog::slideUpAndClose() { if (_slideMode == kNoSlideMode) { _slideTime = g_system->getMillis(); diff --git a/gui/console.h b/gui/console.h index 97b5ca62271..b1d6622f164 100644 --- a/gui/console.h +++ b/gui/console.h @@ -165,6 +165,7 @@ public: void setPrompt(Common::String prompt); void resetPrompt(); + void clearBuffer(); protected: inline char &buffer(int idx) { diff --git a/gui/debugger.cpp b/gui/debugger.cpp index 0a89c950ca2..032061f5b43 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -73,6 +73,8 @@ Debugger::Debugger() { registerCmd("md5", WRAP_METHOD(Debugger, cmdMd5)); registerCmd("md5mac", WRAP_METHOD(Debugger, cmdMd5Mac)); #endif + registerCmd("clear", WRAP_METHOD(Debugger, cmdClearLog)); + registerCmd("cls", WRAP_METHOD(Debugger, cmdClearLog)); // alias registerCmd("exec", WRAP_METHOD(Debugger, cmdExecFile)); registerCmd("debuglevel", WRAP_METHOD(Debugger, cmdDebugLevel)); @@ -808,6 +810,13 @@ bool Debugger::cmdDebugFlagEnable(int argc, const char **argv) { return true; } +bool Debugger::cmdClearLog(int argc, const char **argv) { + #ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER + _debuggerDialog->clearBuffer(); + #endif + return true; +} + bool Debugger::cmdExecFile(int argc, const char **argv) { if (argc <= 1) { debugPrintf("Expected to get the file with debug commands\n"); diff --git a/gui/debugger.h b/gui/debugger.h index 24fb705c93c..a8aa2339b49 100644 --- a/gui/debugger.h +++ b/gui/debugger.h @@ -275,6 +275,7 @@ protected: bool cmdDebugFlagsList(int argc, const char **argv); bool cmdDebugFlagEnable(int argc, const char **argv); bool cmdDebugFlagDisable(int argc, const char **argv); + bool cmdClearLog(int argc, const char **argv); bool cmdExecFile(int argc, const char **argv); #ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER