[Scummvm-git-logs] scummvm master -> 7930e282463ddbfb457fd43538abca4bfcd0d846

bluegr noreply at scummvm.org
Tue Nov 14 07:35:45 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:
7930e28246 GUI: Handle Copy and Paste events in ConsoleDialog


Commit: 7930e282463ddbfb457fd43538abca4bfcd0d846
    https://github.com/scummvm/scummvm/commit/7930e282463ddbfb457fd43538abca4bfcd0d846
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-11-14T09:35:42+02:00

Commit Message:
GUI: Handle Copy and Paste events in ConsoleDialog

ConsoleDialog had a hard-coded handler for Copy and Paste
shortcuts. These shortcuts are now handled by the keymapper
and produce Copy and Paste events.

Fixes CTRL+C and CTRL+V in the console on Windows builds.

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


diff --git a/gui/console.cpp b/gui/console.cpp
index 262860c9cac..d7b520951b8 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -534,6 +534,30 @@ void ConsoleDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
 	}
 }
 
+void ConsoleDialog::handleOtherEvent(const Common::Event &evt) {
+	if (evt.type == Common::EVENT_CUSTOM_ENGINE_ACTION_START) {
+		switch (evt.customType) {
+			case kActionCopy:
+				{
+					Common::String userInput = getUserInput();
+					if (!userInput.empty())
+						g_system->setTextInClipboard(userInput);
+				}
+				break;
+			case kActionPaste:
+				if (g_system->hasTextInClipboard()) {
+					Common::U32String text = g_system->getTextFromClipboard();
+					insertIntoPrompt(text.encode().c_str());
+					scrollToCurrent();
+					drawLine(pos2line(_currentPos));
+				}
+				break;
+			default:
+				break;
+		}
+	}
+}
+
 void ConsoleDialog::specialKeys(Common::KeyCode keycode) {
 	switch (keycode) {
 	case Common::KEYCODE_a:
@@ -558,21 +582,6 @@ void ConsoleDialog::specialKeys(Common::KeyCode keycode) {
 		killLastWord();
 		g_gui.scheduleTopDialogRedraw();
 		break;
-	case Common::KEYCODE_v:
-		if (g_system->hasTextInClipboard()) {
-			Common::U32String text = g_system->getTextFromClipboard();
-			insertIntoPrompt(text.encode().c_str());
-			scrollToCurrent();
-			drawLine(pos2line(_currentPos));
-		}
-		break;
-	case Common::KEYCODE_c:
-		{
-			Common::String userInput = getUserInput();
-			if (!userInput.empty())
-				g_system->setTextInClipboard(userInput);
-		}
-		break;
 	default:
 		break;
 	}
diff --git a/gui/console.h b/gui/console.h
index b1d6622f164..eb5c0702cfb 100644
--- a/gui/console.h
+++ b/gui/console.h
@@ -144,6 +144,7 @@ public:
 	void handleMouseWheel(int x, int y, int direction) override;
 	void handleKeyDown(Common::KeyState state) override;
 	void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
+	void handleOtherEvent(const Common::Event &evt) override;
 
 	int printFormat(int dummy, MSVC_PRINTF const char *format, ...) GCC_PRINTF(3, 4);
 	int vprintFormat(int dummy, const char *format, va_list argptr);




More information about the Scummvm-git-logs mailing list