2 #include <QGLSLHighlighter>
4 #include <QSyntaxStyle>
13 m_includePattern (QRegularExpression(R
"(#include\s+([<"][a-zA-Z0-9*._]+[">]))")),
14 m_functionPattern (QRegularExpression(R"(\b([A-Za-z0-9_]+(?:\s+|::))*([A-Za-z0-9_]+)(?=\())")),
15 m_defTypePattern (QRegularExpression(R"(\b([A-Za-z0-9_]+)\s+[A-Za-z]{1}[A-Za-z0-9_]+\s*[;=])")),
16 m_commentStartPattern(QRegularExpression(R"(/\*)")),
17 m_commentEndPattern (QRegularExpression(R"(\*/)"))
19 Q_INIT_RESOURCE(qcodeeditor_resources);
20 QFile fl(":/languages/glsl.xml");
22 if (!fl.open(QIODevice::ReadOnly))
34 auto keys = language.
keys();
35 for (
auto&& key : keys)
37 auto names = language.
names(key);
38 for (
auto&& name : names)
41 QRegularExpression(QString(R
"(\b%1\b)").arg(name)),
52 QRegularExpression(R
"(\b(0b|0x){0,1}[\d.']+\b)"),
58 QRegularExpression(R
"(#[a-zA-Z_]+)"),
64 QRegularExpression(
"//[^\n]*"),
75 while (matchIterator.hasNext())
77 auto match = matchIterator.next();
80 match.capturedStart(),
81 match.capturedLength(),
86 match.capturedStart(1),
87 match.capturedLength(1),
96 while (matchIterator.hasNext())
98 auto match = matchIterator.next();
101 match.capturedStart(),
102 match.capturedLength(),
107 match.capturedStart(2),
108 match.capturedLength(2),
116 auto matchIterator = rule.pattern.globalMatch(text);
118 while (matchIterator.hasNext())
120 auto match = matchIterator.next();
123 match.capturedStart(),
124 match.capturedLength(),
130 setCurrentBlockState(0);
133 if (previousBlockState() != 1)
138 while (startIndex >= 0)
142 int endIndex =
match.capturedStart();
143 int commentLength = 0;
147 setCurrentBlockState(1);
148 commentLength = text.length() - startIndex;
152 commentLength = endIndex - startIndex +
match.capturedLength();