[Scummvm-git-logs] scummvm master -> f720fba1aa12f83a87f2c97bf0658d6e1a947564

bluegr noreply at scummvm.org
Sun Oct 8 06:36:34 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f720fba1aa GUI: Adds clear and cls alias for gui console debugger


Commit: f720fba1aa12f83a87f2c97bf0658d6e1a947564
    https://github.com/scummvm/scummvm/commit/f720fba1aa12f83a87f2c97bf0658d6e1a947564
Author: Ralph Caraveo (deckarep at gmail.com)
Date: 2023-10-08T08:36:31+02:00

Commit Message:
GUI: Adds clear and cls alias for gui console debugger

Changed paths:
    gui/console.cpp
    gui/console.h
    gui/debugger.cpp
    gui/debugger.h


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




More information about the Scummvm-git-logs mailing list