diff --git a/BareCode.desktop b/BareCode.desktop new file mode 100644 index 0000000..ade1b56 --- /dev/null +++ b/BareCode.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=BareCode +GenericName=Code Editor +Comment=Modularer Code-Editor für HTML, PHP, CSS und mehr +Exec=BareCode %F +Icon=barecode +Terminal=false +Categories=Development;TextEditor; +MimeType=text/plain;text/html;text/css;text/x-php;text/x-csrc;text/x-chdr;text/x-c++src;text/x-c++hdr; +Keywords=editor;code;html;php;css;c++; +StartupWMClass=BareCode diff --git a/BareCode.rc b/BareCode.rc new file mode 100644 index 0000000..8650ce3 --- /dev/null +++ b/BareCode.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON "resources/BareCode.ico" diff --git a/CMakeLists.txt b/CMakeLists.txt index 89f3cda..9321a67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,10 +43,18 @@ add_subdirectory(src) qt_add_resources(BARECODE_RESOURCES resources/resources.qrc) # Main executable -qt_add_executable(BareCode - main.cpp - ${BARECODE_RESOURCES} -) +if(WIN32) + qt_add_executable(BareCode + main.cpp + BareCode.rc + ${BARECODE_RESOURCES} + ) +else() + qt_add_executable(BareCode + main.cpp + ${BARECODE_RESOURCES} + ) +endif() target_link_libraries(BareCode PRIVATE BareCode_Core @@ -67,3 +75,18 @@ include(GNUInstallDirs) install(TARGETS BareCode RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) + +if(UNIX AND NOT APPLE) + # Icons in den Standard-Hicolor-Theme-Pfad installieren + foreach(SIZE 16 32 48 64 128 256 512) + install(FILES resources/icon_${SIZE}.png + DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/${SIZE}x${SIZE}/apps + RENAME barecode.png + ) + endforeach() + + # .desktop Datei + install(FILES BareCode.desktop + DESTINATION ${CMAKE_INSTALL_DATADIR}/applications + ) +endif() diff --git a/main.cpp b/main.cpp index c39869b..c24c0bc 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,5 @@ #include +#include #include "core/MainWindow.h" int main(int argc, char *argv[]) @@ -9,6 +10,17 @@ int main(int argc, char *argv[]) app.setApplicationVersion("1.0.0"); app.setOrganizationName("BareCode"); + // Icon in allen verfügbaren Größen setzen + QIcon appIcon; + appIcon.addFile(":/icon_16.png", QSize(16, 16)); + appIcon.addFile(":/icon_32.png", QSize(32, 32)); + appIcon.addFile(":/icon_48.png", QSize(48, 48)); + appIcon.addFile(":/icon_64.png", QSize(64, 64)); + appIcon.addFile(":/icon_128.png", QSize(128, 128)); + appIcon.addFile(":/icon_256.png", QSize(256, 256)); + appIcon.addFile(":/icon_512.png", QSize(512, 512)); + app.setWindowIcon(appIcon); + MainWindow window; window.show(); diff --git a/resources/BareCode.ico b/resources/BareCode.ico new file mode 100644 index 0000000..0cae478 Binary files /dev/null and b/resources/BareCode.ico differ diff --git a/resources/icon_128.png b/resources/icon_128.png new file mode 100644 index 0000000..8af0c1b Binary files /dev/null and b/resources/icon_128.png differ diff --git a/resources/icon_16.png b/resources/icon_16.png new file mode 100644 index 0000000..ef73abe Binary files /dev/null and b/resources/icon_16.png differ diff --git a/resources/icon_256.png b/resources/icon_256.png new file mode 100644 index 0000000..c890237 Binary files /dev/null and b/resources/icon_256.png differ diff --git a/resources/icon_32.png b/resources/icon_32.png new file mode 100644 index 0000000..8f82923 Binary files /dev/null and b/resources/icon_32.png differ diff --git a/resources/icon_48.png b/resources/icon_48.png new file mode 100644 index 0000000..3ddc136 Binary files /dev/null and b/resources/icon_48.png differ diff --git a/resources/icon_512.png b/resources/icon_512.png new file mode 100644 index 0000000..5019bd9 Binary files /dev/null and b/resources/icon_512.png differ diff --git a/resources/icon_64.png b/resources/icon_64.png new file mode 100644 index 0000000..ca5de95 Binary files /dev/null and b/resources/icon_64.png differ diff --git a/resources/resources.qrc b/resources/resources.qrc index 9f62ef3..38da93d 100644 --- a/resources/resources.qrc +++ b/resources/resources.qrc @@ -1,5 +1,11 @@ - + icon_512.png + icon_256.png + icon_128.png + icon_64.png + icon_48.png + icon_32.png + icon_16.png diff --git a/src/highlighter/SyntaxHighlighter.cpp b/src/highlighter/SyntaxHighlighter.cpp index 562e7d2..2a93936 100644 --- a/src/highlighter/SyntaxHighlighter.cpp +++ b/src/highlighter/SyntaxHighlighter.cpp @@ -373,6 +373,62 @@ void PhpHighlighter::highlightPhpRange(const QString &text, int start, int lengt ); } } + + // /* */ Block-Kommentare innerhalb des PHP-Bereichs mehrzeilig behandeln. + // Block-Zustand 3 = wir sind mitten in einem /* ... */ PHP-Kommentar. + static const QRegularExpression blockOpen(R"(/\*)"); + static const QRegularExpression blockClose(R"(\*/)"); + + int searchFrom = 0; + + // Waren wir bereits in einem Block-Kommentar? + if (previousBlockState() == 3) + { + QRegularExpressionMatch closeMatch = blockClose.match(phpText, 0); + if (closeMatch.hasMatch()) + { + const int end = static_cast(closeMatch.capturedStart()) + + static_cast(closeMatch.capturedLength()); + setFormat(start, end, m_phpCommentFormat); + searchFrom = end; + // Block-Kommentar geschlossen — Zustand wird weiter unten gesetzt + } + else + { + // Gesamter Bereich ist noch Kommentar + setFormat(start, length, m_phpCommentFormat); + setCurrentBlockState(3); + return; + } + } + + // Neue /* ... */ Kommentare innerhalb dieses PHP-Bereichs suchen + while (searchFrom < phpText.length()) + { + QRegularExpressionMatch openMatch = blockOpen.match(phpText, searchFrom); + if (!openMatch.hasMatch()) + { + break; + } + + const int openPos = static_cast(openMatch.capturedStart()); + QRegularExpressionMatch closeMatch = blockClose.match(phpText, openPos + 2); + + if (closeMatch.hasMatch()) + { + const int closeEnd = static_cast(closeMatch.capturedStart()) + + static_cast(closeMatch.capturedLength()); + setFormat(start + openPos, closeEnd - openPos, m_phpCommentFormat); + searchFrom = closeEnd; + } + else + { + // Kein schließendes */ gefunden — geht über Zeilenende + setFormat(start + openPos, length - openPos, m_phpCommentFormat); + setCurrentBlockState(3); + return; + } + } } void PhpHighlighter::highlightBlock(const QString &text) @@ -380,8 +436,10 @@ void PhpHighlighter::highlightBlock(const QString &text) // Zuerst HTML-Basis-Regeln auf den gesamten Text anwenden SyntaxHighlighter::highlightBlock(text); - // Dann PHP-Blöcke und finden und überschreiben - // Block-Zustände: 0 = HTML, 2 = innerhalb PHP-Block + // Block-Zustände: + // 0 = HTML-Modus + // 2 = innerhalb PHP-Block (kein /* */ Kommentar) + // 3 = innerhalb PHP /* */ Block-Kommentar setCurrentBlockState(0); static const QRegularExpression phpOpen(R"(<\?(?:php|=)?\s?)", @@ -390,9 +448,9 @@ void PhpHighlighter::highlightBlock(const QString &text) int pos = 0; - if (previousBlockState() == 2) + if (previousBlockState() == 2 || previousBlockState() == 3) { - // Wir befinden uns bereits in einem PHP-Block + // Wir befinden uns bereits in einem PHP-Block (ggf. in einem Kommentar) QRegularExpressionMatch closeMatch = phpClose.match(text, 0); if (closeMatch.hasMatch()) { @@ -408,7 +466,12 @@ void PhpHighlighter::highlightBlock(const QString &text) else { highlightPhpRange(text, 0, text.length()); - setCurrentBlockState(2); + // highlightPhpRange setzt den Zustand auf 3 falls nötig, + // sonst behalten wir 2 (offener PHP-Block ohne Kommentar) + if (currentBlockState() != 3) + { + setCurrentBlockState(2); + } return; } } @@ -424,7 +487,6 @@ void PhpHighlighter::highlightBlock(const QString &text) const int openStart = static_cast(openMatch.capturedStart()); const int openEnd = openStart + static_cast(openMatch.capturedLength()); - // (openMatch.capturedLength()), m_phpTagFormat); QRegularExpressionMatch closeMatch = phpClose.match(text, openEnd); @@ -441,9 +503,11 @@ void PhpHighlighter::highlightBlock(const QString &text) } else { - // PHP-Block geht über Zeilenende hinaus highlightPhpRange(text, openEnd, text.length() - openEnd); - setCurrentBlockState(2); + if (currentBlockState() != 3) + { + setCurrentBlockState(2); + } return; } }