-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split source to core and shell parts
Ahead of distinct macOS shell
- Loading branch information
Showing
59 changed files
with
282 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
find_package(Qt6 REQUIRED COMPONENTS Widgets) | ||
|
||
find_package(Git) | ||
if(Git_FOUND) | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} log -1 --format=%h | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
OUTPUT_VARIABLE KATVAN_GIT_SHA | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
else() | ||
set(KATVAN_GIT_SHA "unknown") | ||
endif() | ||
configure_file(katvan_version.h.in katvan_version.h @ONLY) | ||
|
||
set(SOURCES | ||
katvan_codemodel.cpp | ||
katvan_diagnosticsmodel.cpp | ||
katvan_editor.cpp | ||
katvan_editorlayout.cpp | ||
katvan_editorsettings.cpp | ||
katvan_editortheme.cpp | ||
katvan_highlighter.cpp | ||
katvan_parsing.cpp | ||
katvan_previewerview.cpp | ||
katvan_spellchecker.cpp | ||
katvan_typstdriverwrapper.cpp | ||
katvan_text_utils.cpp | ||
) | ||
|
||
qt_add_resources(SOURCES themes/themes.qrc) | ||
|
||
if(APPLE) | ||
list(APPEND SOURCES | ||
katvan_spellchecker_macos.mm | ||
) | ||
else() | ||
list(APPEND SOURCES | ||
katvan_spellchecker_hunspell.cpp | ||
) | ||
endif() | ||
|
||
add_library(katvan_core STATIC ${SOURCES}) | ||
|
||
target_include_directories(katvan_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | ||
target_compile_definitions(katvan_core PUBLIC QT_RESTRICTED_CAST_FROM_ASCII QT_NO_EMIT) | ||
|
||
if(MSVC) | ||
target_compile_options(katvan_core PUBLIC /W4) | ||
else() | ||
target_compile_options(katvan_core PUBLIC -Wall -Wextra -pedantic -Wno-switch) | ||
endif() | ||
|
||
target_link_libraries(katvan_core PUBLIC | ||
typstdriver | ||
Qt6::Widgets | ||
) | ||
|
||
if(NOT APPLE) | ||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(hunspell REQUIRED IMPORTED_TARGET hunspell) | ||
|
||
target_link_libraries(katvan_core PUBLIC PkgConfig::hunspell) | ||
endif() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* This file is part of Katvan | ||
* Copyright (c) 2024 Igor Khanin | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include "katvan_text_utils.h" | ||
|
||
namespace katvan::utils { | ||
|
||
bool isBidiControlChar(QChar ch) | ||
{ | ||
return ch == ALM_MARK | ||
|| ch == LRM_MARK | ||
|| ch == RLM_MARK | ||
|| ch == LRI_MARK | ||
|| ch == RLI_MARK | ||
|| ch == PDI_MARK; | ||
} | ||
|
||
Qt::LayoutDirection naturalTextDirection(const QString& text) | ||
{ | ||
int count = 0; | ||
const QChar* ptr = text.constData(); | ||
const QChar* end = ptr + text.length(); | ||
|
||
while (ptr < end) { | ||
if (count++ > 100) { | ||
break; | ||
} | ||
|
||
uint codepoint = ptr->unicode(); | ||
if (QChar::isHighSurrogate(codepoint) && ptr + 1 < end) { | ||
ushort low = ptr[1].unicode(); | ||
if (QChar::isLowSurrogate(low)) { | ||
codepoint = QChar::surrogateToUcs4(codepoint, low); | ||
ptr++; | ||
} | ||
} | ||
|
||
QChar::Direction direction = QChar::direction(codepoint); | ||
if (direction == QChar::DirR || direction == QChar::DirAL) { | ||
return Qt::RightToLeft; | ||
} | ||
else if (direction == QChar::DirL) { | ||
return Qt::LeftToRight; | ||
} | ||
ptr++; | ||
} | ||
return Qt::LayoutDirectionAuto; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
find_package(Qt6 REQUIRED COMPONENTS LinguistTools) | ||
|
||
set(SOURCES | ||
katvan_backuphandler.cpp | ||
katvan_compileroutput.cpp | ||
katvan_mainwindow.cpp | ||
katvan_previewer.cpp | ||
katvan_recentfiles.cpp | ||
katvan_searchbar.cpp | ||
katvan_settingsdialog.cpp | ||
katvan_utils.cpp | ||
main.cpp | ||
) | ||
|
||
qt_add_resources(SOURCES ${PROJECT_SOURCE_DIR}/assets/assets.qrc) | ||
if(WIN32) | ||
file(COPY ${PROJECT_SOURCE_DIR}/assets/katvan.ico DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) | ||
configure_file(${PROJECT_SOURCE_DIR}/assets/katvan.rc.in katvan.rc @ONLY) | ||
list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/katvan.rc) | ||
elseif(APPLE) | ||
list(APPEND SOURCES | ||
katvan_utils_macos.mm | ||
) | ||
|
||
set(macos_icon "${PROJECT_SOURCE_DIR}/assets/katvan.icns") | ||
set_source_files_properties(${macos_icon} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") | ||
list(APPEND SOURCES ${macos_icon}) | ||
endif() | ||
|
||
add_executable(katvan ${SOURCES}) | ||
target_link_libraries(katvan PRIVATE katvan_core) | ||
|
||
if(KATVAN_DISABLE_PORTABLE) | ||
target_compile_definitions(katvan PRIVATE KATVAN_DISABLE_PORTABLE) | ||
elseif(KATVAN_PORTABLE_BUILD) | ||
target_compile_definitions(katvan PRIVATE KATVAN_PORTABLE_BUILD) | ||
endif() | ||
|
||
set_target_properties(katvan PROPERTIES | ||
OUTPUT_NAME $<IF:$<PLATFORM_ID:Darwin>,Katvan,katvan> | ||
WIN32_EXECUTABLE ON | ||
MACOSX_BUNDLE ON | ||
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/assets/Info.plist.in | ||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION} | ||
XCODE_EMBED_FRAMEWORKS typstdriver | ||
) | ||
|
||
qt_create_translation(QM_FILES . ../core translations/katvan_en.ts OPTIONS -pluralonly -no-obsolete -locations none) | ||
qt_create_translation(QM_FILES . ../core translations/katvan_he.ts OPTIONS -no-obsolete -locations none) | ||
|
||
qt_add_resources(katvan "translations" | ||
PREFIX "/i18n" | ||
BASE "${CMAKE_CURRENT_BINARY_DIR}" | ||
FILES "${QM_FILES}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.