git: b071a62b5e75 - main - editors:diamond: new port, CopperSpice-based editor

From: Adriaan de Groot <adridg_at_FreeBSD.org>
Date: Sun, 20 Feb 2022 15:45:48 UTC
The branch main has been updated by adridg:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b071a62b5e7518503dc9a2d6e88625b1f0a82863

commit b071a62b5e7518503dc9a2d6e88625b1f0a82863
Author:     Adriaan de Groot <adridg@FreeBSD.org>
AuthorDate: 2022-02-19 20:21:23 +0000
Commit:     Adriaan de Groot <adridg@FreeBSD.org>
CommitDate: 2022-02-20 15:45:30 +0000

    editors:diamond: new port, CopperSpice-based editor
    
    This needs patching to consider the installed location
    (e.g. share/) as a source of data, rather than the installed
    location of the binary.
---
 editors/Makefile                               |  1 +
 editors/diamond/Makefile                       | 26 ++++++++++
 editors/diamond/distinfo                       |  3 ++
 editors/diamond/files/patch-CMakeLists.txt     | 18 +++++++
 editors/diamond/files/patch-src_CMakeLists.txt | 67 ++++++++++++++++++++++++++
 editors/diamond/files/patch-src_json.cpp       | 11 +++++
 editors/diamond/pkg-descr                      | 19 ++++++++
 editors/diamond/pkg-plist                      | 23 +++++++++
 8 files changed, 168 insertions(+)

diff --git a/editors/Makefile b/editors/Makefile
index 1c05ff426891..9809b87bf2b9 100644
--- a/editors/Makefile
+++ b/editors/Makefile
@@ -24,6 +24,7 @@
     SUBDIR += deforaos-editor
     SUBDIR += dhex
     SUBDIR += diakonos
+    SUBDIR += diamond
     SUBDIR += dkns
     SUBDIR += drjava
     SUBDIR += dte
diff --git a/editors/diamond/Makefile b/editors/diamond/Makefile
new file mode 100644
index 000000000000..37f3d8a80606
--- /dev/null
+++ b/editors/diamond/Makefile
@@ -0,0 +1,26 @@
+PORTNAME=	diamond
+DISTVERSIONPREFIX=	diamond-
+DISTVERSION=	1.3.6
+CATEGORIES=	editors
+
+MAINTAINER=	adridg@FreeBSD.org
+COMMENT=	Compact programmers editor
+
+LICENSE=	GPLv2
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+LIB_DEPENDS=    libhunspell-1.7.so:textproc/hunspell
+BUILD_DEPENDS=	copperspice>=1.7:x11-toolkits/copperspice
+RUN_DEPENDS=	copperspice>=1.7:x11-toolkits/copperspice
+
+USES=		compiler:c++17-lang cmake gl gnome iconv jpeg pkgconfig ssl xorg
+USE_GL=		gl
+USE_GNOME=	cairo glib20 libxml2
+USE_XORG=	ice sm x11 xau xcb xcursor xext xfixes xi xinerama xrandr xrender
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	copperspice
+GH_PROJECT=	diamond
+
+.include <bsd.port.mk>
+
diff --git a/editors/diamond/distinfo b/editors/diamond/distinfo
new file mode 100644
index 000000000000..d907474b1d5a
--- /dev/null
+++ b/editors/diamond/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1645301383
+SHA256 (copperspice-diamond-diamond-1.3.6_GH0.tar.gz) = e1b85890a870236370207c5d6b7aa7d44d7414a090723ecea513f8b5cec4fb67
+SIZE (copperspice-diamond-diamond-1.3.6_GH0.tar.gz) = 4626624
diff --git a/editors/diamond/files/patch-CMakeLists.txt b/editors/diamond/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..9973587f5eb2
--- /dev/null
+++ b/editors/diamond/files/patch-CMakeLists.txt
@@ -0,0 +1,18 @@
+--- CMakeLists.txt.orig	2022-02-19 20:16:57 UTC
++++ CMakeLists.txt
+@@ -31,7 +31,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ elseif(CMAKE_SYSTEM_NAME MATCHES "(Linux|OpenBSD|FreeBSD|NetBSD|DragonFly)")
+    include(GNUInstallDirs)
+ 
+-   set(CMAKE_INSTALL_RPATH "\$ORIGIN")
++   # set(CMAKE_INSTALL_RPATH "\$ORIGIN")
+ 
+ elseif(MSVC)
+    # use defaults
+@@ -109,4 +109,4 @@ message("")
+ message("Diamond configured to run on:  ${CMAKE_SYSTEM_NAME} ${TARGETBITS} bit, ${CMAKE_BUILD_TYPE} Mode")
+ message("Diamond will be built in:      ${CMAKE_BINARY_DIR}")
+ message("Diamond will be installed in:  ${CMAKE_INSTALL_PREFIX}")
+-message("\n")
+\ No newline at end of file
++message("\n")
diff --git a/editors/diamond/files/patch-src_CMakeLists.txt b/editors/diamond/files/patch-src_CMakeLists.txt
new file mode 100644
index 000000000000..2105866af22a
--- /dev/null
+++ b/editors/diamond/files/patch-src_CMakeLists.txt
@@ -0,0 +1,67 @@
+--- src/CMakeLists.txt.orig	2021-01-28 22:43:22 UTC
++++ src/CMakeLists.txt
+@@ -120,6 +120,8 @@ target_link_libraries(Diamond
+    CopperSpice::CsNetwork
+ )
+ 
++set(install_resource_dir ${CMAKE_INSTALL_DATADIR}/copperspice/diamond)
++
+ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+    set_target_properties(Diamond PROPERTIES OUTPUT_NAME diamond)
+ 
+@@ -169,8 +171,9 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "(Linux|OpenBSD|FreeB
+       PRIVATE
+       PkgConfig::Hunspell
+    )
++   target_compile_definitions(Diamond PRIVATE DIAMOND_SHARE_DIR="${CMAKE_INSTALL_PREFIX}/${install_resource_dir}")
+ 
+-   install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../resources/diamond.png  DESTINATION .)
++   install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../resources/diamond.png  DESTINATION ${install_resource_dir})
+ 
+ elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
+ 
+@@ -198,28 +201,21 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
+    install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../resources/diamond.ico  DESTINATION .)
+ endif()
+ 
+-install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../source_extra/syntax/ DESTINATION syntax)
++install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../source_extra/syntax/ DESTINATION ${install_resource_dir}/syntax)
+ 
+ # installs English by default
+-install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../source_extra/dictionary/en_US.aff DESTINATION dictionary)
+-install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../source_extra/dictionary/en_US.dic DESTINATION dictionary)
++install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../source_extra/dictionary/en_US.aff DESTINATION ${install_resource_dir}/dictionary)
++install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../source_extra/dictionary/en_US.dic DESTINATION ${install_resource_dir}/dictionary)
+ 
+-# will not overwrite dictionary/userDict.txt
+-install(CODE "
+-   if (NOT EXISTS  \"${CMAKE_INSTALL_PREFIX}/dictionary/userDict.txt    \")
+-      file(INSTALL \"${CMAKE_CURRENT_SOURCE_DIR}/../source_extra/dictionary/userDict.txt\" DESTINATION  \"${CMAKE_INSTALL_PREFIX}/dictionary\")
+-   endif()
+-")
+-
+ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+    install(TARGETS Diamond DESTINATION ../MacOS)
+ else()
+-   install(TARGETS Diamond DESTINATION .)
++   install(TARGETS Diamond)
+ endif()
+ 
+-cs_copy_library(CsCore)
+-cs_copy_library(CsGui)
+-cs_copy_library(CsNetwork)
++# cs_copy_library(CsCore)
++# cs_copy_library(CsGui)
++# cs_copy_library(CsNetwork)
+ 
+ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+    # copy required plugins to the bundle
+@@ -227,6 +223,6 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+    cs_copy_plugins(CsPrinterDriver ../plugins)
+ else()
+    # installs required plugins
+-   cs_copy_plugins(CsGui)
+-   cs_copy_plugins(CsPrinterDriver)
++   # cs_copy_plugins(CsGui)
++   # cs_copy_plugins(CsPrinterDriver)
+ endif()
diff --git a/editors/diamond/files/patch-src_json.cpp b/editors/diamond/files/patch-src_json.cpp
new file mode 100644
index 000000000000..a11b06bdf71a
--- /dev/null
+++ b/editors/diamond/files/patch-src_json.cpp
@@ -0,0 +1,11 @@
+--- src/json.cpp.orig	2022-02-20 12:59:53 UTC
++++ src/json.cpp
+@@ -36,7 +36,7 @@ bool MainWindow::json_Read(Config trail)
+ {
+    bool ok = true;
+ 
+-   m_appPath = QCoreApplication::applicationDirPath();
++   m_appPath = DIAMOND_SHARE_DIR; // QCoreApplication::applicationDirPath();
+ 
+    QSettings settings("Diamond Editor", "Settings");
+    m_jsonFname = settings.value("configName").toString();
diff --git a/editors/diamond/pkg-descr b/editors/diamond/pkg-descr
new file mode 100644
index 000000000000..610a1f4847df
--- /dev/null
+++ b/editors/diamond/pkg-descr
@@ -0,0 +1,19 @@
+Diamond is a cross platform compact editor designed for programmers.
+It was developed using the CopperSpice libraries and was written in C++.
+
+ - View multiple documents in movable tabs
+ - Auto Load previously open Files
+ - Configuration saved as a JSON format
+ - Define preset Folders
+ - Insert Date, Time, and Symbols
+ - Search and Replace
+ - Advanced Find
+ - Syntax Highlighting based on File Type
+ - Horizontal or Vertical split Window
+ - Spell Check
+ - Customize printed Header and Footer
+ - Show Spaces and Tabs
+ - User definable standard and custom Keyboard Shortcuts
+ - Record, Save, and Play back Macros
+
+WWW: https://github.com/copperspice/diamond
diff --git a/editors/diamond/pkg-plist b/editors/diamond/pkg-plist
new file mode 100644
index 000000000000..a4f2eb0d70d1
--- /dev/null
+++ b/editors/diamond/pkg-plist
@@ -0,0 +1,23 @@
+bin/diamond
+share/copperspice/diamond/diamond.png
+share/copperspice/diamond/dictionary/en_US.aff
+share/copperspice/diamond/dictionary/en_US.dic
+share/copperspice/diamond/syntax/syn_clipper.json
+share/copperspice/diamond/syntax/syn_cmake.json
+share/copperspice/diamond/syntax/syn_cpp.json
+share/copperspice/diamond/syntax/syn_css.json
+share/copperspice/diamond/syntax/syn_doxy.json
+share/copperspice/diamond/syntax/syn_errlog.json
+share/copperspice/diamond/syntax/syn_html.json
+share/copperspice/diamond/syntax/syn_java.json
+share/copperspice/diamond/syntax/syn_js.json
+share/copperspice/diamond/syntax/syn_json.json
+share/copperspice/diamond/syntax/syn_make.json
+share/copperspice/diamond/syntax/syn_none.json
+share/copperspice/diamond/syntax/syn_nsi.json
+share/copperspice/diamond/syntax/syn_php.json
+share/copperspice/diamond/syntax/syn_pl.json
+share/copperspice/diamond/syntax/syn_py.json
+share/copperspice/diamond/syntax/syn_sh.json
+share/copperspice/diamond/syntax/syn_txt.json
+share/copperspice/diamond/syntax/syn_xml.json