3rdparty
QCodeEditor
src
internal
QCSVHighlighter.cpp
Go to the documentation of this file.
1
/*
2
MIT License
3
4
Copyright (c) 2013-2019 Megaxela
5
6
Permission is hereby granted, free of charge, to any person obtaining a copy
7
of this software and associated documentation files (the "Software"), to deal
8
in the Software without restriction, including without limitation the rights
9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
copies of the Software, and to permit persons to whom the Software is
11
furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in all
14
copies or substantial portions of the Software.
15
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
SOFTWARE.
23
24
*/
25
26
// QCodeEditor
27
#include <QCSVHighlighter>
28
#include <QSyntaxStyle>
29
#include <QLanguage>
30
31
// Qt
32
#include <QFile>
33
34
35
QCSVHighlighter::QCSVHighlighter
(QTextDocument* document) :
36
QStyleSyntaxHighlighter
(document),
37
m_delimiter(QRegularExpression(
","
))
38
{
39
Q_INIT_RESOURCE(qcodeeditor_resources);
40
41
}
42
43
void
QCSVHighlighter::highlightBlock
(
const
QString& text)
44
{
45
{
// Checking for require
46
QRegularExpression
m_delimiter
;
47
//m_delimiter = QRegularExpression(delimiter);
48
m_delimiter
.setPattern(
delimiter
);
49
auto
matchIterator =
m_delimiter
.globalMatch(text);
50
51
while
(matchIterator.hasNext())
52
{
53
auto
match
= matchIterator.next();
54
55
setFormat(
56
match
.capturedStart(),
57
match
.capturedLength(),
58
syntaxStyle
()->getFormat(
"VisualWhitespace"
)
59
);
60
61
}
62
}
63
}
QCSVHighlighter::m_delimiter
QRegularExpression m_delimiter
Definition:
QCSVHighlighter.hpp:37
QStyleSyntaxHighlighter::syntaxStyle
QSyntaxStyle * syntaxStyle() const
Method for getting syntax style.
Definition:
QStyleSyntaxHighlighter.cpp:16
QStyleSyntaxHighlighter
Class, that descrubes highlighter with syntax style.
Definition:
QStyleSyntaxHighlighter.hpp:12
QCSVHighlighter::highlightBlock
void highlightBlock(const QString &text) override
Definition:
QCSVHighlighter.cpp:43
QCSVHighlighter::delimiter
QChar delimiter
Definition:
QCSVHighlighter.hpp:31
match
static const char * match(MatchState *ms, const char *s, const char *p)
Definition:
lstrlib.c:570
QCSVHighlighter::QCSVHighlighter
QCSVHighlighter(QTextDocument *document=nullptr)
Constructor.
Definition:
QCSVHighlighter.cpp:35
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:45