diff options
author | Alexander Tkachev | 2016-07-26 12:21:15 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | b9bba9bd4bec1bf00a61c347f411a8ecf9ea69e8 (patch) | |
tree | dc84602db91c43f060dbcd7f869ace78132142ca /gui | |
parent | 527ab4cdf6fc314cb260ae329d88794440b875ef (diff) | |
download | scummvm-rg350-b9bba9bd4bec1bf00a61c347f411a8ecf9ea69e8.tar.gz scummvm-rg350-b9bba9bd4bec1bf00a61c347f411a8ecf9ea69e8.tar.bz2 scummvm-rg350-b9bba9bd4bec1bf00a61c347f411a8ecf9ea69e8.zip |
ALL: Move Clipboard support to OSystem
Commit adds kFeatureClipboardSupport. hasTextInClipboard() and
getTextFromClipboard().
OSystem_SDL has this feature if SDL2 is used.
EditableWidget and StorageWizardDialog use g_system to access clipboard
now.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/storagewizarddialog.cpp | 52 | ||||
-rw-r--r-- | gui/widgets/editable.cpp | 35 |
2 files changed, 30 insertions, 57 deletions
diff --git a/gui/storagewizarddialog.cpp b/gui/storagewizarddialog.cpp index 6d0c504521..dd1a3aae37 100644 --- a/gui/storagewizarddialog.cpp +++ b/gui/storagewizarddialog.cpp @@ -20,13 +20,6 @@ * */ -#ifdef USE_SDL2 -#define FORBIDDEN_SYMBOL_ALLOW_ALL - -#include <SDL2/SDL.h> -#include <SDL2/SDL_clipboard.h> -#endif - #include "gui/storagewizarddialog.h" #include "gui/gui-manager.h" #include "gui/message.h" @@ -217,32 +210,27 @@ void StorageWizardDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 break; } case kPasteCodeCmd: { -#ifdef USE_SDL2 - if (SDL_HasClipboardText() == SDL_TRUE) { - char *text = SDL_GetClipboardText(); - if (text != nullptr) { - Common::String message = text; - for (uint32 i = 0; i < CODE_FIELDS; ++i) { - if (message.empty()) break; - Common::String subcode = ""; - for (uint32 j = 0; j < message.size(); ++j) { - if (message[j] == ' ') { - message.erase(0, j+1); - break; - } - subcode += message[j]; - if (j+1 == message.size()) { - message = ""; - break; - } + if (g_system->hasTextInClipboard()) { + Common::String message = g_system->getTextFromClipboard(); + for (uint32 i = 0; i < CODE_FIELDS; ++i) { + if (message.empty()) break; + Common::String subcode = ""; + for (uint32 j = 0; j < message.size(); ++j) { + if (message[j] == ' ') { + message.erase(0, j+1); + break; + } + subcode += message[j]; + if (j+1 == message.size()) { + message = ""; + break; } - _codeWidget[i]->setEditString(subcode); } - handleCommand(sender, kCodeBoxCmd, data); - draw(); + _codeWidget[i]->setEditString(subcode); } + handleCommand(sender, kCodeBoxCmd, data); + draw(); } -#endif break; } case kConnectCmd: { @@ -302,11 +290,7 @@ void StorageWizardDialog::containerWidgetsReflow() { } if (_openUrlWidget) _openUrlWidget->setVisible(true); if (_pasteCodeWidget) { -#ifdef USE_SDL2 - bool visible = showFields; -#else - bool visible = false; -#endif + bool visible = showFields && g_system->hasFeature(OSystem::kFeatureClipboardSupport); _pasteCodeWidget->setVisible(visible); } diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp index 6c63074fd1..02defe9a56 100644 --- a/gui/widgets/editable.cpp +++ b/gui/widgets/editable.cpp @@ -20,13 +20,6 @@ * */ -#ifdef USE_SDL2 -#define FORBIDDEN_SYMBOL_ALLOW_ALL - -#include <SDL2/SDL.h> -#include <SDL2/SDL_clipboard.h> -#endif - #include "common/rect.h" #include "common/system.h" #include "gui/widgets/editable.h" @@ -192,24 +185,20 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) { forcecaret = true; break; -#ifdef USE_SDL2 - case Common::KEYCODE_v: - if (state.flags & Common::KBD_CTRL) { - if (SDL_HasClipboardText() == SDL_TRUE) { - char *text = SDL_GetClipboardText(); - if (text != nullptr) { - for (char *ptr = text; *ptr; ++ptr) { - if (tryInsertChar(*ptr, _caretPos)) - ++_caretPos; - } - dirty = true; - } + case Common::KEYCODE_v: + if (g_system->hasFeature(OSystem::kFeatureClipboardSupport) && state.flags & Common::KBD_CTRL) { + if (g_system->hasTextInClipboard()) { + String text = g_system->getTextFromClipboard(); + for (uint32 i = 0; i < text.size(); ++i) { + if (tryInsertChar(text[i], _caretPos)) + ++_caretPos; } - } else { - defaultKeyDownHandler(state, dirty, forcecaret, handled); + dirty = true; } - break; -#endif + } else { + defaultKeyDownHandler(state, dirty, forcecaret, handled); + } + break; #ifdef MACOSX // Let ctrl-a / ctrl-e move the caret to the start / end of the line. |