From 01a40bf7c3b7dbea27d368b98a3a9d21fa1f8c3e Mon Sep 17 00:00:00 2001 From: XiaoPb Date: Tue, 7 Feb 2023 12:49:17 +0000 Subject: [PATCH] =?UTF-8?q?!21=20Cmake=E5=85=BC=E5=AE=B9Win=E5=92=8CLinux?= =?UTF-8?q?=E4=B8=8B=E7=BC=96=E8=AF=91=20*=20=E6=96=87=E4=BB=B6=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E5=90=8C=E6=AD=A5=20*=20!1=20=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E5=90=88=E5=B9=B6=20*=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8=20*=201.?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9win.mk=E4=B8=ADQt=5FMSVC/MINGW=5FPREFIX=5F?= =?UTF-8?q?PATH=E5=8F=98=E9=87=8F=E5=90=8E=E5=8F=AF=E4=BB=A5=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E8=BF=9B=E8=A1=8C=E7=BC=96=E8=AF=91=E6=89=93=E5=8C=85?= =?UTF-8?q?=20*=20=E4=BC=98=E5=8C=96=E6=89=93=E5=8C=85=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=20*=20=E6=94=AF=E6=8C=81Win=E4=B8=8B=E8=BF=9E=E5=90=8C?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=80=E8=B5=B7=E6=89=93=E5=8C=85=20*=20Me?= =?UTF-8?q?rge=20branch=20'master'=20of=20gitee.com:XiaoPb/notepad--=20*?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E6=8F=92=E4=BB=B6=E6=89=93=E5=8C=85?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=20*=20update=20linux.mk=20*=20update=20defin?= =?UTF-8?q?e=20"NDD=5FEXPORT"=20of=20Linux=20*=201.=20=E5=8E=BB=E9=99=A4SP?= =?UTF-8?q?ARK=E4=BE=9D=E8=B5=96=20*=201.=20=E4=BC=98=E5=8C=96CMake=20*=20?= =?UTF-8?q?1.=20rc=E6=96=87=E4=BB=B6=E9=80=82=E9=85=8DMinGw=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=99=A8=20*=20=E5=8E=BB=E9=99=A4=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E6=89=93=E5=8D=B0=20*=20=E4=BF=AE=E5=A4=8Dli?= =?UTF-8?q?nux.mk=E4=B8=8D=E5=85=BC=E5=AE=B9CMakeLists.txt=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20*=20=E6=9B=B4=E6=AD=A3linux.mk=E7=9A=84=E8=B0=83?= =?UTF-8?q?=E7=94=A8=20*=20python=E7=89=88=E6=9C=AC=E9=9C=80=E8=A6=813?= =?UTF-8?q?=E4=BB=A5=E4=B8=8A=20*=20=E6=94=AF=E6=8C=81=E5=88=B0Win?= =?UTF-8?q?=E4=B8=8B=E4=BD=BF=E7=94=A8Cmake=E7=BC=96=E8=AF=91=20*=20update?= =?UTF-8?q?=20CMakeLists.txt=20*=20=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8D=B3=E5=B0=86=E5=BA=9F=E9=99=A4=E7=9A=84api=E7=94=A8?= =?UTF-8?q?=E6=B3=95=20*=20cmake-version:=20=E5=B0=86=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E9=99=8D=E5=88=B0=203.22=20=E4=BB=A5=E9=80=82=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=20cmake=20=E6=9E=84=E5=BB=BA=20*=20repo:=20=E5=AF=B9?= =?UTF-8?q?=20desktop=20=E6=96=87=E4=BB=B6=E6=B7=BB=E5=8A=A0=20%F=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=EF=BC=8C=E4=BB=A5=E4=BF=9D=E8=AF=81=E5=8F=AF?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E4=BC=A0=E5=85=A5=E5=8F=82=E6=95=B0=20*=20de?= =?UTF-8?q?sktop:=20=E4=B8=BA=20desktop=20=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E6=96=87=E4=BB=B6=E7=9A=84=E7=9B=B8=E5=85=B3=20MimeTy?= =?UTF-8?q?pe=20*=20repo:=20=E5=BC=95=E5=85=A5=20Spark=20=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=EF=BC=8C=E6=94=AF=E6=8C=81=E6=9E=84=E5=BB=BA=20Appima?= =?UTF-8?q?ge=20*=20repo:=20=E5=BC=95=E5=85=A5=20Spark=20=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=EF=BC=8C=E6=94=AF=E6=8C=81=E6=9E=84=E5=BB=BA=20deb=20?= =?UTF-8?q?*=20add=20cmake=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 44 ++++++-- CMakeLists.txt | 99 ++++++++++++------ Makefile | 17 +++ ..._config.cmake => deb_package_config.cmake} | 0 cmake/nsis_package_config.cmake | 59 +++++++++++ linux.mk | 42 ++++++++ src/RealCompare.rc | Bin 5134 -> 2505 bytes src/RealCompareToMinGw.rc | 38 +++++++ src/columnedit.cpp | 4 +- src/ctipwin.cpp | 2 +- src/include/pluginGl.h | 10 +- src/plugin/helloworld/CMakeLists.txt | 42 ++++++++ src/plugin/helloworld/helloworldexport.cpp | 10 +- src/plugin/test/test.cpp | 10 +- src/qscint/CMakeLists.txt | 23 +++- win.bat | 5 + win.mk | 42 ++++++++ 17 files changed, 391 insertions(+), 56 deletions(-) create mode 100644 Makefile rename cmake/{package_config.cmake => deb_package_config.cmake} (100%) create mode 100644 cmake/nsis_package_config.cmake create mode 100644 linux.mk create mode 100644 src/RealCompareToMinGw.rc create mode 100644 src/plugin/helloworld/CMakeLists.txt create mode 100644 win.bat create mode 100644 win.mk diff --git a/.gitignore b/.gitignore index 8d723bc..2c6580d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ *.user *.userosscache *.sln.docstates - +build # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs @@ -390,9 +390,39 @@ FodyWeavers.xsd # Windows Installer files from build outputs *.cab *.msi -*.msix -*.msm -*.msp - -# JetBrains Rider -*.sln.iml +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + + + +# Ignore the build directory generated by the vsocde cmake extension +build/ +# Ignore the build directory generated by the vsocde clangd extension +.cache + +# Created by https://www.toptal.com/developers/gitignore/api/cmake +# Edit at https://www.toptal.com/developers/gitignore?templates=cmake + +### CMake ### +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +### CMake Patch ### +# External projects +*-prefix/ + +# End of https://www.toptal.com/developers/gitignore/api/cmake +!/Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt index f1d6eea..ec442ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -project(notepad--) +project(NotePad-- VERSION 1.22.0) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) @@ -7,49 +7,84 @@ set(CMAKE_AUTORCC ON) find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns) -# TODO: use system provided libraries to build -# current status: some header can not be found,for example: Scintilla.h -find_library(QSCINTILLA_LIB_PATH qscintilla2_qt5) -find_path(QSCINTILLA_INC_PATH qsciscintilla.h PATHS /usr/include/) -find_path(SCINTILLA_INC_PATH Scintilla.h PATHS /usr/include/) -if((${QSCINTILLA_LIB_PATH} STREQUAL "QSCINTILLA_LIB_PATH-NOTFOUND") OR - (${QSCINTILLA_INC_PATH} STREQUAL "QSCINTILLA_INC_PATH-NOTFOUND") OR - (${SCINTILLA_INC_PATH} STREQUAL "SCINTILLA_INC_PATH-NOTFOUND") ) -set(NOTEPAD_USE_SYS_LIB OFF) -message("system libraries or header not found,build from local") +# qscint 关键依赖库 add_subdirectory(${PROJECT_SOURCE_DIR}/src/qscint) -else() -set(NOTEPAD_USE_SYS_LIB ON) -message("use system libraries") -message("QSCINTILLA_LIB_PATH:" ${QSCINTILLA_LIB_PATH}) -message("QSCINTILLA_INC_PATH:" ${QSCINTILLA_INC_PATH}) -message("SCINTILLA_INC_PATH:" ${SCINTILLA_INC_PATH}) + +# 插件库包含 +# helloworld 动态插件库 +add_subdirectory(${PROJECT_SOURCE_DIR}/src/plugin/helloworld) + +# win下需要开启UNICODE进行支持TCHAR +if(CMAKE_HOST_WIN32) + add_definitions(-D_UNICODE -DUNICODE) endif() + +if(${PLUGIN_EN}) + if(${PLUGIN_EN} STREQUAL on) + add_definitions(-DNO_PLUGIN=1) + endif(${PLUGIN_EN}) +endif() + + + file(GLOB UI_SRC ${PROJECT_SOURCE_DIR}/src/*.ui) set(UI_SRC ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/cceditor/ccnotepad.ui) aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC) aux_source_directory(${PROJECT_SOURCE_DIR}/src/cceditor SRC) -add_executable(${PROJECT_NAME} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc) -target_include_directories(${PROJECT_NAME} PRIVATE -${PROJECT_SOURCE_DIR}/src -${PROJECT_SOURCE_DIR}/src/cceditor -) -if(NOTEPAD_USE_SYS_LIB) -target_include_directories(${PROJECT_NAME} PRIVATE ${QSCINTILLA_INC_PATH} ${SCINTILLA_INC_PATH}) +if(CMAKE_HOST_WIN32) +# 添加 WIN32 保证主程序启动没有命令行 + list(APPEND WIN_RCS ${PROJECT_SOURCE_DIR}/src/RealCompareToMinGw.rc) + add_executable(${PROJECT_NAME} WIN32 ${WIN_RCS} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc) +else() + add_executable(${PROJECT_NAME} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc) endif() -target_link_libraries(${PROJECT_NAME} qscintilla2_qt5 Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) +target_include_directories(${PROJECT_NAME} PRIVATE +${PROJECT_SOURCE_DIR}/src +${PROJECT_SOURCE_DIR}/src/cceditor -install( - TARGETS ${PROJECT_NAME} - DESTINATION "bin" +${PROJECT_SOURCE_DIR}/src/qscint/src +${PROJECT_SOURCE_DIR}/src/qscint/src/Qsci +${PROJECT_SOURCE_DIR}/src/qscint/scintilla/src +${PROJECT_SOURCE_DIR}/src/qscint/scintilla/include +${PROJECT_SOURCE_DIR}/src/qscint/scintilla/lexlib +${PROJECT_SOURCE_DIR}/src/qscint/scintilla/boostregex ) -install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/linux/usr - DESTINATION "/") +target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) -include(${PROJECT_SOURCE_DIR}/cmake/package_config.cmake) -include(CPack) +# set(PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}/bin") +# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) + +if(CMAKE_HOST_UNIX) + install( + TARGETS ${PROJECT_NAME} + DESTINATION "bin" + ) + + install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/linux/usr + DESTINATION "/") + + include(${PROJECT_SOURCE_DIR}/cmake/deb_package_config.cmake) + include(CPack) +elseif(CMAKE_HOST_WIN32) + install(TARGETS ${PROJECT_NAME} + DESTINATION "/") + + install(DIRECTORY ${PROJECT_SOURCE_DIR}/build/bin/ + DESTINATION "/") + # 设置软件版本 + set(CPACK_PACKAGE_NAME "NotePad--") + set(CPACK_PACKAGE_DESCRIPTION "NotePad--") + set(CPACK_PACKAGE_COPYRIGHT "Copyright (c) 2023") + set(CPACK_PACKAGE_VERSION "1.22.0") + set(CPACK_PACKAGE_VERSION_MAJOR "1") + set(CPACK_PACKAGE_VERSION_MINOR "22") + set(CPACK_PACKAGE_VERSION_PATCH "0") + + include(${PROJECT_SOURCE_DIR}/cmake/nsis_package_config.cmake) + include(CPack) +endif() diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2db5182 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +UNAME:=WIN32 +UNAME:=$(shell uname) + +# Win下使用Git Bash运行make + +ifeq ($(UNAME), Linux) +all:linux +linux: + make -f linux.mk package +else +all: + make -f win.mk all +msvc: + make -f win.mk msvc +mingw: + make -f win.mk mingw +endif diff --git a/cmake/package_config.cmake b/cmake/deb_package_config.cmake similarity index 100% rename from cmake/package_config.cmake rename to cmake/deb_package_config.cmake diff --git a/cmake/nsis_package_config.cmake b/cmake/nsis_package_config.cmake new file mode 100644 index 0000000..0098d39 --- /dev/null +++ b/cmake/nsis_package_config.cmake @@ -0,0 +1,59 @@ +set(CPACK_GENERATOR NSIS) + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME}") +# 维护人员 +set(CPACK_PACKAGE_CONTACT "XiaoPb") + +set(P4_VERSION_INFO_CL_HIGH "0") +set(P4_VERSION_INFO_CL_LOW "0") +# set(CPACK_PACKAGE_VERSION_PATCH "0") + +set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}") + +set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_NAME}V${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME}V${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") + +set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON") + +set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/ico/txt (9).ico") +set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/ico/txt (9).ico") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License") + +set (CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME}" "${PROJECT_NAME}" ) + +# 设置 安装包属性信息 +set (CPACK_NSIS_DEFINES " + ${CPACK_NSIS_DEFINES} + VIProductVersion ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${P4_VERSION_INFO_CL_HIGH}.${P4_VERSION_INFO_CL_LOW} + VIFileVersion ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${P4_VERSION_INFO_CL_HIGH}.${P4_VERSION_INFO_CL_LOW} + VIAddVersionKey /LANG=0 \\\"ProductName\\\" \\\"${CPACK_PACKAGE_NAME}\\\" + VIAddVersionKey /LANG=0 \\\"ProductVersion\\\" \\\"v${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}${CPACK_PACKAGE_BUILD_TYPE_REVISION}\\\" + VIAddVersionKey /LANG=0 \\\"Comments\\\" \\\"${CPACK_PACKAGE_DESCRIPTION}\\\" + VIAddVersionKey /LANG=0 \\\"CompanyName\\\" \\\"${CPACK_PACKAGE_VENDOR}\\\" + VIAddVersionKey /LANG=0 \\\"LegalCopyright\\\" \\\"${CPACK_PACKAGE_COPYRIGHT}\\\" + VIAddVersionKey /LANG=0 \\\"FileDescription\\\" \\\"${CPACK_PACKAGE_NAME} Installer\\\" + VIAddVersionKey /LANG=0 \\\"FileVersion\\\" \\\"v${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}${CPACK_PACKAGE_BUILD_TYPE_REVISION}\\\" + " +) + +# 设置 安装时需要的环境变量 +set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS " + WriteRegStr SHCTX \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\App Paths\\\\${PROJECT_NAME}\\\" \\\"\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\\shell\\\" \\\"\\\" \\\"open\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\\shell\\\\open\\\\command\\\" \\\"\\\" \\\"$\\\\\\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe$\\\\\\\" $\\\\\\\"%1$\\\\\\\"\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\.txt\\\\OpenWithProgids\\\" \\\"${PROJECT_NAME}\\\" \\\"\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" \\\"\\\" \\\"Edit with ${PROJECT_NAME}\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" \\\"Icon\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\\command\\\" \\\"\\\" \\\"$\\\\\\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe$\\\\\\\" $\\\\\\\"%1$\\\\\\\"\\\" + ") + +# 设置 卸载时需要的环境变量 +set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " + Delete \\\"$DESKTOP\\\\${PROJECT_NAME}.lnk\\\" + Delete \\\"$SMPROGRAMS\\\\${PROJECT_NAME}.lnk\\\" + DeleteRegKey SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" + DeleteRegKey SHCTX \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\App Paths\\\\bin\\\\${PROJECT_NAME}.exe\\\" \\\"\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\" + DeleteRegKey SHCTX \\\"Software\\\\${PROJECT_NAME}\\\" + DeleteRegValue SHCTX \\\"Software\\\\Classes\\\\.txt\\\\OpenWithProgids\\\" \\\"${PROJECT_NAME}\\\" + DeleteRegKey SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\" + ") diff --git a/linux.mk b/linux.mk new file mode 100644 index 0000000..43f4a79 --- /dev/null +++ b/linux.mk @@ -0,0 +1,42 @@ +CPUS=$(shell nproc) +CALENDAR=$(shell date '+%Y%m%d') +OSID=$(shell lsb_release -si) +OSRELEASE=$(shell lsb_release -sr) +SUFFIX= +ifneq ("$(OSID)", "") +SUFFIX=_$(OSID)$(OSRELEASE) +endif + +PROJECT_NAME=notepad-- +PACKAGE_NAME=com.hmja.notepad + +all: + mkdir -p build + cd build && cmake .. + cd build && make -j$(CPUS) + +run: all + exec $(shell find build/ -maxdepth 1 -type f -executable | grep $(PROJECT_NAME)) + +debug: + mkdir -p build + cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. + cd build && make -j$(CPUS) + +release: + mkdir -p build + cd build && cmake -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=off -DPACKAGE_SUFFIX="$(SUFFIX)" .. + cd build && make -j$(CPUS) + +package: release + cd build && make package + tree build/_CPack_Packages/Linux/DEB/$(PROJECT_NAME)-* +# dpkg-deb --contents build/$(PROJECT_NAME)$(SUFFIX).deb + +builddeps: + cd build && make builddeps + +cpus: + @echo "CPU数量: $(CPUS)" + + diff --git a/src/RealCompare.rc b/src/RealCompare.rc index 6a8f8d37265dabff9050c897da0dcaebd07d0c87..55fa7fd77d9d11d31b77a8f18a16ddb09303ee79 100755 GIT binary patch literal 2505 zcmcIm&2HO95We#%ru4-|WQn4E$dw`~bzzzmL`jGN0t6$jw1E%# z0eVUAJvHY7t=}fL+f!d5vm`}PiS6W|>_OU{otd5ezS$YJT5!xJNu0*h48|;71`+5F z9>9!pngkgQA)#r!OePf4Nx~LcQ);!O9mXfoGNd4{cAKZNB<+NB$~XnB?+!->ar}X) z8IEn8`0mMZ$FW?r-Qp0Dv|7-sLY*e@9I{giL-Wy)*t#_`Oi-&Ed=dH?;~0G&_!ff_ z=qxz`aSsYxhXFqQ_2>0(uXb-fKL2$2{{Me2aDDaRa<962isY~<{8SJW?rPmfNRI1_ z2D<4RmbC}ZoEbr+9m+%G0S6{-^-NayNIwLjF-=ky^BkSA>yOQWOB~xLcGrP&A?6ZviDi}oXg5@~ zp)?c;`UA%p>BFx#gnHM~dhW629)a@oU}}jZ6U_UD*%|c;kGTqNw{e$7DczJRLMkvR z#Ey%ahl-*cT7_VE(l-m^JUq<0Qi6tSZabEvAA#&<3FEUaizwmKxL|6nBv3CEm50iq za`+h2KnTUyR1=c1W{pgc^?1Gr__-a-soVhh`jo&uu0H;HbNTk> z@856!czgZ&`PyI2gNVnVMfF4;gclxXbPLd513H8BKT) zt>RptaBEB!oduB|FU}J-JI#dmY5}|Y9;k|{?BmbDt=0}&F+5D%jF-TCY_qo z!B=C?S1IN9pYizKYhQ;vSXfurGxy9nXU?4W_~Sp@wr!Ce*}0wB$c8rN?b!ra3)tAE zc48NN73@o%$okf`0q+R-gs}r`#3;Hcvoq!qU*dLdSKw^fXZ9((Y`bv-=z!G=usaSn zw?w~XKU&UVi*m!^^&Fjee{D6ZTf>^RZzZc*+g@1_=sxp`mF;^Vb$*X*4@jAL*k3ZN z-xH(@V`PWuWl_gHv^2C!&Obpr(nEt&f5&f$Qx`a=^ic%9%e!ci|F*%;PQRWmt^f7Y zSdhqj#}r-3lX{%{e!dYjANa1<7^I7Av+}M=BzSG8o$~@xx8&9;7vH_1*_-Pxumqgf8w`&<_1!$A;(D`D3 zcszM(5$vKpgLfUgJ$Canix`UG5;0r@qlCOAsP-4mw%Y32sl~~@nNzKoO_S0D`-X8< zWQTQ)dUw#_svMy8J&*^`}Zk1apTxJ5J<>sh(vK6_+k`J651n4BGxtB#3a zpYLNSS4s5zo)X=4pADCTJ7h)W75~U;Svh9e+k%afc3!W!B$Py9RJ~VKA9La%_6YEB zk{0pU2B%2eD>7AU+s?ZVn2S2OB8>c~ZJne{YIga<#PTJ7?icdy5;u|pLfY?50V zx1>>i&<+PKpBy6L5qYIf{73Nq#hzouvXe%h*_+o3WxOJh(j-#Svc{Y|hn+cnm)>QJ zu5QN9C-7CDv}>B8ihQ2;3uM&uVn!2dtU(`BL&CHS@w(5UX{@kwcKj>jR?)09lS6_D zHdja1M|bC(tcxZG$U0nz$ZT#QGSXc0_LV!0PISsF9osQYR(=YrVQgVX^)}K$4!P9> zUD10E>>3|C;j0T=^(1GXpMLoBkH#nOzG(dZ!?$n#e*M?=+tcj5v$+Qi?87tJ!TN{@ zy9|&)ov)1Vp7-WG)6p09N^-p`XW3D5ju_R$FKR369Cy)H8Qy)z zSys8i9`d9<-RWd*k>!<${-fYJj9oOPchmju5~Fw7y*k@XzN^y(+vzLm6AwLQjeUmL zdCHw-^1tga&HW)h5ZCSCXUmXul(x{+Xs);WM149o8*o!xjZFSqKy zxQnay5RJHA@aSHDJzKqG^tVb$TyniYfyz>GeQEH)tg%G=3omOe3znlFNdLbureiz? zrm8w|^FGoIsWp;QYpS>% + +IDI_ICON1 ICON DISCARDABLE ".\\Resources\\edit\\global\\ndd.ico" + +LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,22,0,0 + PRODUCTVERSION 1,22,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080404b0" + BEGIN + VALUE "FileDescription", "notepad-- v1.22.0\0" + VALUE "FileVersion", "1.22.0.0\0" + VALUE "LegalCopyright", "Copyright (C) 2020-2023\0" + VALUE "OriginalFilename", "Notepad--.exe\0" + VALUE "ProductName", "notepad-- \0" + VALUE "ProductVersion", "1.22.0.0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0804, 1200 + END + END +/* End of Version info */ + diff --git a/src/columnedit.cpp b/src/columnedit.cpp index 50fd9ae..3fae34a 100755 --- a/src/columnedit.cpp +++ b/src/columnedit.cpp @@ -216,13 +216,13 @@ void ColumnEdit::slot_ok() { QByteArray s_space(cursorCol - lineEndCol, ' '); lineData.append(s_space); - lineData.append(text); + lineData.append(text.toUtf8()); } else { int posAbs2Start = pEdit->execute(SCI_FINDCOLUMN, i, cursorCol); int posRelative2Start = posAbs2Start - lineBegin; - lineData.insert(posRelative2Start, text); + lineData.insert(posRelative2Start, text.toUtf8()); } pEdit->SendScintilla(SCI_SETTARGETRANGE, lineBegin, lineEnd); diff --git a/src/ctipwin.cpp b/src/ctipwin.cpp index 9412777..f894ad8 100755 --- a/src/ctipwin.cpp +++ b/src/ctipwin.cpp @@ -9,7 +9,7 @@ CTipWin::CTipWin(QWidget *parent) this->setWindowFlags(Qt::ToolTip); QPalette palette(this->palette()); - palette.setColor(QPalette::Background, QColor(0xfff29d)); + palette.setColor(QPalette::Window, QColor(0xfff29d)); this->setPalette(palette); } diff --git a/src/include/pluginGl.h b/src/include/pluginGl.h index 069f6c2..135babf 100755 --- a/src/include/pluginGl.h +++ b/src/include/pluginGl.h @@ -4,11 +4,13 @@ #define NDD_EXPORTDLL #if defined(Q_OS_WIN) -#if defined(NDD_EXPORTDLL) -#define NDD_EXPORT __declspec(dllexport) + #if defined(NDD_EXPORTDLL) + #define NDD_EXPORT __declspec(dllexport) + #else + #define NDD_EXPORT __declspec(dllimport) + #endif #else -#define NDD_EXPORT __declspec(dllimport) -#endif + #define NDD_EXPORT __attribute__((visibility("default"))) #endif struct ndd_proc_data diff --git a/src/plugin/helloworld/CMakeLists.txt b/src/plugin/helloworld/CMakeLists.txt new file mode 100644 index 0000000..f4acbcd --- /dev/null +++ b/src/plugin/helloworld/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.16) +project(helloworld) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) + +find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns) + +add_definitions(-D_UNICODE -DUNICODE) + + + + +file(GLOB UI_SRC ${PROJECT_SOURCE_DIR}/*.ui) +file(GLOB SRC ${PROJECT_SOURCE_DIR}/*.cpp) +file(GLOB MOC_HEADER ${PROJECT_SOURCE_DIR}/*.h) +# add_executable(${PROJECT_NAME} ${IS_WIN} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc) + +add_library(${PROJECT_NAME} SHARED ${SRC} ${UI_SRC} ${MOC_HEADER}) + +target_include_directories(${PROJECT_NAME} PRIVATE +${PROJECT_SOURCE_DIR} + +${PROJECT_SOURCE_DIR}/../../include +${PROJECT_SOURCE_DIR}/../../qscint/src +${PROJECT_SOURCE_DIR}/../../qscint/src/Qsci +${PROJECT_SOURCE_DIR}/../../qscint/scintilla/src +${PROJECT_SOURCE_DIR}/../../qscint/scintilla/include +${PROJECT_SOURCE_DIR}/../../qscint/scintilla/lexlib +${PROJECT_SOURCE_DIR}/../../qscint/scintilla/boostregex +) + +target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) + +# if(NOT DEFINED ${notepad--_BINARY_DIR}) +# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# set(LIBRARY_OUTPUT_PATH ${notepad--_BINARY_DIR}/bin/plugin) +# set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# endif() diff --git a/src/plugin/helloworld/helloworldexport.cpp b/src/plugin/helloworld/helloworldexport.cpp index 84c3f49..aba2a40 100755 --- a/src/plugin/helloworld/helloworldexport.cpp +++ b/src/plugin/helloworld/helloworldexport.cpp @@ -8,11 +8,13 @@ #define NDD_EXPORTDLL #if defined(Q_OS_WIN) -#if defined(NDD_EXPORTDLL) -#define NDD_EXPORT __declspec(dllexport) + #if defined(NDD_EXPORTDLL) + #define NDD_EXPORT __declspec(dllexport) + #else + #define NDD_EXPORT __declspec(dllimport) + #endif #else -#define NDD_EXPORT __declspec(dllimport) -#endif + #define NDD_EXPORT __attribute__((visibility("default"))) #endif #ifdef __cplusplus diff --git a/src/plugin/test/test.cpp b/src/plugin/test/test.cpp index bd11bb4..c2ccca1 100755 --- a/src/plugin/test/test.cpp +++ b/src/plugin/test/test.cpp @@ -7,11 +7,13 @@ #define NDD_EXPORTDLL #if defined(Q_OS_WIN) -#if defined(NDD_EXPORTDLL) -#define NDD_EXPORT __declspec(dllexport) + #if defined(NDD_EXPORTDLL) + #define NDD_EXPORT __declspec(dllexport) + #else + #define NDD_EXPORT __declspec(dllimport) + #endif #else -#define NDD_EXPORT __declspec(dllimport) -#endif + #define NDD_EXPORT __attribute__((visibility("default"))) #endif #ifdef __cplusplus diff --git a/src/qscint/CMakeLists.txt b/src/qscint/CMakeLists.txt index b114614..b213b21 100644 --- a/src/qscint/CMakeLists.txt +++ b/src/qscint/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -project(qscintilla2_qt5 CXX) +project(qscint CXX) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) @@ -19,6 +19,9 @@ file(GLOB MOC_HEADER ${PROJECT_SOURCE_DIR}/src/Qsci/*.h) add_library(${PROJECT_NAME} STATIC ${SRC} ${MOC_HEADER}) +# add_definitions(-DQSCINTILLA_MAKE_DLL) +# add_library(${PROJECT_NAME} SHARED ${SRC} ${MOC_HEADER}) + target_compile_definitions(${PROJECT_NAME} PRIVATE SCINTILLA_QT SCI_LEXER INCLUDE_DEPRECATED_FEATURES) target_include_directories(${PROJECT_NAME} PRIVATE @@ -28,8 +31,24 @@ ${PROJECT_SOURCE_DIR}/scintilla/boostregex target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/src -${PROJECT_SOURCE_DIR}/src/Qsci +${PROJECT_SOURCE_DIR}/src/Qsci ${PROJECT_SOURCE_DIR}/scintilla/src ${PROJECT_SOURCE_DIR}/scintilla/include) target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport) + +if(${CMAKE_BUILD_TYPE} STREQUAL "Release") + set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "qmyedit_qt5") +else() + set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "qmyedit_qt5d") +endif() + + + +# if(NOT DEFINED ${notepad--_BINARY_DIR}) +# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# set(LIBRARY_OUTPUT_PATH ${notepad--_BINARY_DIR}/bin/plugin) +# set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# endif() diff --git a/win.bat b/win.bat new file mode 100644 index 0000000..f2d9d63 --- /dev/null +++ b/win.bat @@ -0,0 +1,5 @@ +cd build/bin + +windeployqt notepad--.exe +@REM copy .\src\qscint\libqscint.a .\%1\plugin +@REM copy .\src\plugin\^*\^*.dll .\%1\plugin diff --git a/win.mk b/win.mk new file mode 100644 index 0000000..7ac2002 --- /dev/null +++ b/win.mk @@ -0,0 +1,42 @@ + +# 基于 Git Bash 环境编写 +# 设置编译链信息是为了避免环境存在多个Qt环境时编译异常 + +# 填入Qt的Mingw相关工具安装路径 (不使用MINGW时可不填) +# 填入Mingw Qt G++程序完整路径 +Qt_MINGW_CXX_COMPILER:=d:/SOFT/Qt/Qt5.14.2/Tools/mingw730_64/bin/g++.exe +# 填入Mingw Qt GCC程序完整路径 +Qt_MINGW_C_COMPILER:=d:/SOFT/Qt/Qt5.14.2/Tools/mingw730_64/bin/gcc.exe +# 填入Mingw Qt库查找路径 +Qt_MINGW_PREFIX_PATH:=d:/SOFT/Qt/Qt5.14.2/5.14.2/mingw73_64 +# 指定生成的Makefiles格式 +Qt_MINGW_G:=CodeBlocks - MinGW Makefiles + +# 填入Qt的msvc相关工具安装路径 (不使用MSVC时可不填) +# 填入Msvc Qt库查找路径 +Qt_MSVC_PREFIX_PATH:=d:/CompilationTools/Qt/5.15.2/msvc2019_64 + + +all:msvc + + +mingw: + cmake -G"${Qt_MINGW_G}" -Bbuild -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=on -DCMAKE_PREFIX_PATH=${Qt_MINGW_PREFIX_PATH} -DCMAKE_CXX_COMPILER=${Qt_MINGW_CXX_COMPILER} -DCMAKE_C_COMPILER=${Qt_MINGW_C_COMPILER} . + cmake --build ./build --config=Release -- -j$$(nproc) + mkdir -p build/bin/plugin + cp -f build/NotePad--.exe build/bin/ + cd build/bin && windeployqt --qmldir=${Qt_MINGW_PREFIX_PATH}/qml NotePad--.exe + cp -r -f build/src/*/*/*.dll build/bin/plugin + cp -r -f build/src/*/*.a build/bin/plugin + cd build && cpack --config CPackConfig.cmake + +msvc: + cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=on -DCMAKE_PREFIX_PATH=${Qt_MSVC_PREFIX_PATH} . + cmake --build ./build --config=Release -j$$(nproc) + mkdir -p build/bin/plugin + cp -f build/Release/NotePad--.exe build/bin/ + cd build/bin && windeployqt --qmldir=${Qt_MSVC_PREFIX_PATH}/qml NotePad--.exe + cp -r -f build/src/*/*/Release/*.dll build/bin/plugin + cp -r -f build/src/*/Release/*.lib build/bin/plugin + cd build && cpack --config CPackConfig.cmake +