File 0001-Replace-tinyclipboard-with-SFML-closes-690.patch of Package tsc

From 48f981f3ff459f742d5f30596e7866ae4b9005f7 Mon Sep 17 00:00:00 2001
From: Balint Kiss <balintkissdev@gmail.com>
Date: Sun, 14 Feb 2021 12:19:01 +0100
Subject: [PATCH] Replace tinyclipboard with SFML closes #690

diff -Nur TSC-2.1.0/INSTALL.md new/INSTALL.md
--- TSC-2.1.0/INSTALL.md	2020-02-25 09:20:41.000000000 +0100
+++ new/INSTALL.md	2021-05-03 10:48:39.832443274 +0200
@@ -174,15 +174,6 @@
   by executing $ git status in the mruby/mruby directory after
   updating the Git submodules.
 
-USE_SYSTEM_TINYCLIPBOARD [OFF]
-: For clipboard access, TSC uses the `tinyclipboard` library written
-  by Marvin Gülker (Quintus). The library is not part of many Linux
-  distributions yet, so it is build as part of building TSC itself
-  as a static library. If you *are* on a Linux distribution where
-  this library is packaged, set this value to ON and the build
-  system will dynamically link to the tinyclipboard library of
-  the system and not build its own variant.
-
 USE_SYSTEM_PODPARSER [OFF]
 : This option only has an effect if ENABLE_SCRIPT_DOCS is set to ON.
   If ON, it configures cmake to link the scripting API generator (scrdg)
diff -Nur TSC-2.1.0/tsc/cmake/modules/ProvideTinyclipboard.cmake new/tsc/cmake/modules/ProvideTinyclipboard.cmake
--- TSC-2.1.0/tsc/cmake/modules/ProvideTinyclipboard.cmake	2020-05-17 12:21:38.000000000 +0200
+++ new/tsc/cmake/modules/ProvideTinyclipboard.cmake	1970-01-01 01:00:00.000000000 +0100
@@ -1,13 +0,0 @@
-if (USE_SYSTEM_TINYCLIPBOARD)
-  find_path(Tinyclipboard_INCLUDE_DIRS tinyclipboard.h)
-  find_library(Tinyclipboard_LIBRARIES tinyclipboard)
-  message("-- Found tinyclipboard at ${Tinyclipboard_LIBRARIES}")
-else()
-  message("-- Building tinyclipboard statically")
-  add_library(tinyclipboard STATIC
-    "${TSC_SOURCE_DIR}/../tinyclipboard/src/tinyclipboard.c"
-    "${TSC_SOURCE_DIR}/../tinyclipboard/include/tinyclipboard.h")
-
-  set(Tinyclipboard_LIBRARIES tinyclipboard)
-  set(Tinyclipboard_INCLUDE_DIRS "${TSC_SOURCE_DIR}/../tinyclipboard/include")
-endif()
diff -Nur TSC-2.1.0/tsc/CMakeLists.txt new/tsc/CMakeLists.txt
--- TSC-2.1.0/tsc/CMakeLists.txt	2020-05-17 12:21:43.000000000 +0200
+++ new/tsc/CMakeLists.txt	2021-05-03 10:48:42.252460923 +0200
@@ -49,7 +49,6 @@
 
 option(ENABLE_NLS "Enable translations and localisations" ON)
 option(ENABLE_SCRIPT_DOCS "Build the scripting documentation" ON)
-option(USE_SYSTEM_TINYCLIPBOARD "Use the system's tinyclipboard library" OFF)
 option(USE_SYSTEM_PODPARSER "Use the system's pod-cpp library" OFF)
 option(USE_SYSTEM_MRUBY "Use the system's mruby library" OFF)
 option(USE_LIBXMLPP3 "Use libxml++3.0 instead of libxml++2.6 (experimental)" OFF)
@@ -122,7 +121,6 @@
 set(Boost_COMPONENTS Boost::filesystem Boost::chrono Boost::thread)
 
 # Libraries we can build ourselves under certain cirumstances if missing
-include("ProvideTinyclipboard")
 include("ProvidePodParser")
 include("ProvideMRuby")
 
@@ -148,7 +146,6 @@
   ${SFML_INCLUDE_DIR}
   ${Boost_INCLUDE_DIRS}
   ${LibXmlPP_INCLUDE_DIRS}
-  ${Tinyclipboard_INCLUDE_DIRS}
   ${PodParser_INCLUDE_DIRS}
   ${CEGUI_INCLUDE_DIR}
   ${OPENGL_INCLUDE_DIR}
@@ -205,7 +202,6 @@
   ${OPENGL_LIBRARIES}
   ${PNG_LIBRARIES}
   ${MRuby_LIBRARIES}
-  ${Tinyclipboard_LIBRARIES}
   ${LibXmlPP_LIBRARIES}
   ${PCRE_LIBRARIES})
 
@@ -418,7 +414,6 @@
 message(STATUS "--------------- Configuration summary -------------")
 message(STATUS "Enable native language support:    ${ENABLE_NLS}")
 message(STATUS "Enable the scripting API docs:     ${ENABLE_SCRIPT_DOCS}")
-message(STATUS "Use system-provided tinyclipboard: ${USE_SYSTEM_TINYCLIPBOARD}")
 message(STATUS "Use system-provided pod-cpp:       ${USE_SYSTEM_PODPARSER}")
 message(STATUS "Use system-provided mruby:         ${USE_SYSTEM_MRUBY}")
 
diff -Nur TSC-2.1.0/tsc/docs/authors.txt new/tsc/docs/authors.txt
--- TSC-2.1.0/tsc/docs/authors.txt	2020-05-17 12:21:43.000000000 +0200
+++ new/tsc/docs/authors.txt	2021-05-03 10:48:42.256460952 +0200
@@ -25,6 +25,7 @@
 Chris Jacobsen (datahead)
 Luiji
 Brian Allen Vanderburg II (brianvanderburg2)
+Balint Kiss (balintkissdev)
 
 -- Graphic Artists --
 
diff -Nur TSC-2.1.0/tsc/src/core/global_basic.hpp new/tsc/src/core/global_basic.hpp
--- TSC-2.1.0/tsc/src/core/global_basic.hpp	2020-05-17 12:21:43.000000000 +0200
+++ new/tsc/src/core/global_basic.hpp	2021-05-03 10:48:42.256460952 +0200
@@ -141,11 +141,6 @@
 #include <mruby/proc.h>
 #include <mruby/range.h>
 
-// tinyclipboard
-extern "C" {
-#include <tinyclipboard.h>
-}
-
 #ifndef PNG_COLOR_TYPE_RGBA
 #define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA
 #endif
diff -Nur TSC-2.1.0/tsc/src/gui/generic.cpp new/tsc/src/gui/generic.cpp
--- TSC-2.1.0/tsc/src/gui/generic.cpp	2020-05-17 12:21:43.000000000 +0200
+++ new/tsc/src/gui/generic.cpp	2021-05-03 10:48:42.256460952 +0200
@@ -487,13 +487,9 @@
         return 0;
     }
 
-    if (tiny_clipwrite(sel_text.c_str()) < 0) {
-        perror("Failed to write to clipboard");
-        return 0;
-    }
-    else {
-        return 1;
-    }
+    sf::Clipboard::setString(sel_text.c_str());
+
+    return 1;
 }
 
 bool GUI_Paste_From_Clipboard(void)
@@ -530,14 +526,8 @@
         new_text.erase(beg, len);
 
         // get clipboard text
-        char* cliptext = tiny_clipread(NULL);
-        if (!cliptext) {
-            perror("Failed to read from clipboard");
-            return 0;
-        }
-
-        CEGUI::String clipboard_text = reinterpret_cast<const CEGUI::utf8*>(cliptext);
-        free(cliptext);
+        const sf::String cliptext = sf::Clipboard::getString();
+        CEGUI::String clipboard_text = reinterpret_cast<const CEGUI::utf8*>(cliptext.toUtf8().c_str());
 
         // set new text
         editbox->setText(new_text.insert(beg, clipboard_text));
@@ -560,14 +550,8 @@
         new_text.erase(beg, len);
 
         // get clipboard text
-        char* cliptext = tiny_clipread(NULL);
-        if (!cliptext) {
-            perror("Failed to read from clipboard");
-            return 0;
-        }
-
-        CEGUI::String clipboard_text = reinterpret_cast<const CEGUI::utf8*>(cliptext);
-        free(cliptext);
+        const sf::String cliptext = sf::Clipboard::getString();
+        CEGUI::String clipboard_text = reinterpret_cast<const CEGUI::utf8*>(cliptext.toUtf8().c_str());
 
         // set new text
         editbox->setText(new_text.insert(beg, clipboard_text));
openSUSE Build Service is sponsored by