From 014bef9eab9fb409cfb3ec66830e033e4aaa29a9 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Thu, 19 Sep 2019 22:20:08 +0100 Subject: BACKENDS: Add a default clipboard implementation --- common/system.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'common/system.h') diff --git a/common/system.h b/common/system.h index f17625e215..ae0575f0e8 100644 --- a/common/system.h +++ b/common/system.h @@ -216,6 +216,12 @@ protected: */ FilesystemFactory *_fsFactory; + /** + * Used by the default clipboard implementation, for backends that don't + * implement clipboard support. + */ + Common::String _clipboard; + private: /** * Indicate if initBackend() has been called. @@ -374,8 +380,11 @@ public: kFeatureDisplayLogFile, /** - * The presence of this feature indicates whether the hasTextInClipboard(), - * getTextFromClipboard() and setTextInClipboard() calls are supported. + * The presence of this feature indicates whether the system clipboard is + * available. If this feature is not present, the hasTextInClipboard(), + * getTextFromClipboard() and setTextInClipboard() calls can still be used, + * however it should not be used in scenarios where the user is expected to + * copy data outside of the application. * * This feature has no associated state. */ @@ -1451,7 +1460,7 @@ public: * * @return true if there is text in the clipboard, false otherwise */ - virtual bool hasTextInClipboard() { return false; } + virtual bool hasTextInClipboard() { return !_clipboard.empty(); } /** * Returns clipboard contents as a String. @@ -1462,7 +1471,7 @@ public: * * @return clipboard contents ("" if hasTextInClipboard() == false) */ - virtual Common::String getTextFromClipboard() { return ""; } + virtual Common::String getTextFromClipboard() { return _clipboard; } /** * Set the content of the clipboard to the given string. @@ -1473,7 +1482,7 @@ public: * * @return true if the text was properly set in the clipboard, false otherwise */ - virtual bool setTextInClipboard(const Common::String &text) { return false; } + virtual bool setTextInClipboard(const Common::String &text) { _clipboard = text; return true; } /** * Open the given Url in the default browser (if available on the target -- cgit v1.2.3