Highlighter für Kommentare hinzugefügt.
13
BareCode.desktop
Normal file
@@ -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
|
||||
1
BareCode.rc
Normal file
@@ -0,0 +1 @@
|
||||
IDI_ICON1 ICON "resources/BareCode.ico"
|
||||
@@ -43,10 +43,18 @@ add_subdirectory(src)
|
||||
qt_add_resources(BARECODE_RESOURCES resources/resources.qrc)
|
||||
|
||||
# Main executable
|
||||
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()
|
||||
|
||||
12
main.cpp
@@ -1,4 +1,5 @@
|
||||
#include <QApplication>
|
||||
#include <QIcon>
|
||||
#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();
|
||||
|
||||
|
||||
BIN
resources/BareCode.ico
Normal file
|
After Width: | Height: | Size: 707 B |
BIN
resources/icon_128.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
resources/icon_16.png
Normal file
|
After Width: | Height: | Size: 685 B |
BIN
resources/icon_256.png
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
resources/icon_32.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
resources/icon_48.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
resources/icon_512.png
Normal file
|
After Width: | Height: | Size: 269 KiB |
BIN
resources/icon_64.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
@@ -1,5 +1,11 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<!-- Icons and other assets can be added here -->
|
||||
<file>icon_512.png</file>
|
||||
<file>icon_256.png</file>
|
||||
<file>icon_128.png</file>
|
||||
<file>icon_64.png</file>
|
||||
<file>icon_48.png</file>
|
||||
<file>icon_32.png</file>
|
||||
<file>icon_16.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -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<int>(closeMatch.capturedStart())
|
||||
+ static_cast<int>(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<int>(openMatch.capturedStart());
|
||||
QRegularExpressionMatch closeMatch = blockClose.match(phpText, openPos + 2);
|
||||
|
||||
if (closeMatch.hasMatch())
|
||||
{
|
||||
const int closeEnd = static_cast<int>(closeMatch.capturedStart())
|
||||
+ static_cast<int>(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 <?php ... ?> 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());
|
||||
// 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<int>(openMatch.capturedStart());
|
||||
const int openEnd = openStart + static_cast<int>(openMatch.capturedLength());
|
||||
|
||||
// <?php-Tag selbst einfärben
|
||||
setFormat(openStart, static_cast<int>(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);
|
||||
if (currentBlockState() != 3)
|
||||
{
|
||||
setCurrentBlockState(2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||