2007-10-06 19:03:41 +00:00
|
|
|
/**
|
|
|
|
* \file LaTeXHighlighter.cpp
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Bo Peng
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2007-10-09 06:39:53 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2007-10-06 19:03:41 +00:00
|
|
|
#include "LaTeXHighlighter.h"
|
2007-12-24 13:55:01 +00:00
|
|
|
#include "qt_helpers.h"
|
2007-10-06 19:03:41 +00:00
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QTextDocument>
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2016-06-14 21:45:47 +01:00
|
|
|
|
2022-02-12 17:10:34 +01:00
|
|
|
LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent, bool at_letter, bool keyval)
|
|
|
|
: QSyntaxHighlighter(parent), at_letter_(at_letter), keyval_(keyval)
|
2007-10-06 19:03:41 +00:00
|
|
|
{
|
2016-06-14 21:45:47 +01:00
|
|
|
auto blend = [](QColor color1, QColor color2) {
|
|
|
|
int r = 0.5 * (color1.red() + color2.red());
|
|
|
|
int g = 0.5 * (color1.green() + color2.green());
|
|
|
|
int b = 0.5 * (color1.blue() + color2.blue());
|
|
|
|
return QColor(r, g, b);
|
|
|
|
};
|
|
|
|
QPalette palette = QPalette();
|
|
|
|
QColor text_color = palette.color(QPalette::Active, QPalette::Text);
|
|
|
|
keywordFormat.setForeground(blend(Qt::blue, text_color));
|
2007-10-06 19:03:41 +00:00
|
|
|
keywordFormat.setFontWeight(QFont::Bold);
|
2016-06-14 21:45:47 +01:00
|
|
|
commentFormat.setForeground(palette.color(QPalette::Disabled,
|
|
|
|
QPalette::Text));
|
|
|
|
mathFormat.setForeground(blend(Qt::red, text_color));
|
2007-12-24 13:55:01 +00:00
|
|
|
warningFormat.setForeground(Qt::red);
|
|
|
|
warningFormat.setFontWeight(QFont::Bold);
|
2022-02-12 17:10:34 +01:00
|
|
|
keyFormat.setForeground(blend(Qt::darkRed, text_color));
|
|
|
|
keyFormat.setFontWeight(QFont::Bold);
|
|
|
|
valFormat.setForeground(blend(Qt::darkGreen, text_color));
|
2007-10-06 19:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LaTeXHighlighter::highlightBlock(QString const & text)
|
|
|
|
{
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#if QT_VERSION < 0x060000
|
2022-02-12 17:10:34 +01:00
|
|
|
// keyval
|
|
|
|
if (keyval_) {
|
|
|
|
// Highlight key-val options. Used in some option widgets.
|
|
|
|
static const QRegExp exprKeyvalkey("[^=,]+");
|
|
|
|
static const QRegExp exprKeyvalval("[^,]+");
|
|
|
|
int kvindex = exprKeyvalkey.indexIn(text);
|
|
|
|
while (kvindex >= 0) {
|
|
|
|
int length = exprKeyvalkey.matchedLength();
|
|
|
|
setFormat(kvindex, length, keyFormat);
|
|
|
|
int kvvindex = exprKeyvalval.indexIn(text, kvindex + length);
|
|
|
|
if (kvvindex > 0) {
|
|
|
|
length += exprKeyvalval.matchedLength();
|
|
|
|
setFormat(kvvindex, length, valFormat);
|
|
|
|
}
|
|
|
|
kvindex = exprKeyvalkey.indexIn(text, kvindex + length);
|
|
|
|
}
|
|
|
|
}
|
2007-10-06 19:03:41 +00:00
|
|
|
// $ $
|
|
|
|
static const QRegExp exprMath("\\$[^\\$]*\\$");
|
2009-03-09 19:54:47 +00:00
|
|
|
int index = exprMath.indexIn(text);
|
2007-10-06 19:03:41 +00:00
|
|
|
while (index >= 0) {
|
|
|
|
int length = exprMath.matchedLength();
|
|
|
|
setFormat(index, length, mathFormat);
|
2009-03-09 19:54:47 +00:00
|
|
|
index = exprMath.indexIn(text, index + length);
|
2007-10-06 19:03:41 +00:00
|
|
|
}
|
|
|
|
// [ ]
|
|
|
|
static const QRegExp exprStartDispMath("(\\\\\\[|"
|
|
|
|
"\\\\begin\\{equation\\**\\}|"
|
|
|
|
"\\\\begin\\{eqnarray\\**\\}|"
|
|
|
|
"\\\\begin\\{align(ed|at)*\\**\\}|"
|
|
|
|
"\\\\begin\\{flalign\\**\\}|"
|
|
|
|
"\\\\begin\\{gather\\**\\}|"
|
|
|
|
"\\\\begin\\{multline\\**\\}|"
|
|
|
|
"\\\\begin\\{array\\**\\}|"
|
|
|
|
"\\\\begin\\{cases\\**\\}"
|
|
|
|
")");
|
|
|
|
static const QRegExp exprEndDispMath("(\\\\\\]|"
|
|
|
|
"\\\\end\\{equation\\**\\}|"
|
|
|
|
"\\\\end\\{eqnarray\\**\\}|"
|
|
|
|
"\\\\end\\{align(ed|at)*\\**\\}|"
|
|
|
|
"\\\\end\\{flalign\\**\\}|"
|
|
|
|
"\\\\end\\{gather\\**\\}|"
|
|
|
|
"\\\\end\\{multline\\**\\}|"
|
|
|
|
"\\\\end\\{array\\**\\}|"
|
|
|
|
"\\\\end\\{cases\\**\\}"
|
|
|
|
")");
|
|
|
|
int startIndex = 0;
|
|
|
|
// if previous block was in 'disp math'
|
|
|
|
// start search from 0 (for end disp math)
|
|
|
|
// otherwise, start search from 'begin disp math'
|
|
|
|
if (previousBlockState() != 1)
|
2009-03-09 19:54:47 +00:00
|
|
|
startIndex = exprStartDispMath.indexIn(text);
|
2009-03-09 19:47:46 +00:00
|
|
|
while (startIndex >= 0) {
|
2009-03-09 19:54:47 +00:00
|
|
|
int endIndex = exprEndDispMath.indexIn(text, startIndex);
|
2007-10-06 19:03:41 +00:00
|
|
|
int length;
|
|
|
|
if (endIndex == -1) {
|
|
|
|
setCurrentBlockState(1);
|
|
|
|
length = text.length() - startIndex;
|
|
|
|
} else {
|
|
|
|
length = endIndex - startIndex + exprEndDispMath.matchedLength();
|
|
|
|
}
|
|
|
|
setFormat(startIndex, length, mathFormat);
|
2009-03-09 19:54:47 +00:00
|
|
|
startIndex = exprStartDispMath.indexIn(text, startIndex + length);
|
2007-10-06 19:03:41 +00:00
|
|
|
}
|
|
|
|
// \whatever
|
2016-07-15 17:45:47 +01:00
|
|
|
static const QRegExp exprKeywordAtOther("\\\\[A-Za-z]+");
|
|
|
|
// \wh@tever
|
|
|
|
static const QRegExp exprKeywordAtLetter("\\\\[A-Za-z@]+");
|
|
|
|
QRegExp const & exprKeyword = at_letter_ ? exprKeywordAtLetter
|
|
|
|
: exprKeywordAtOther;
|
2009-03-09 19:54:47 +00:00
|
|
|
index = exprKeyword.indexIn(text);
|
2009-03-09 19:47:46 +00:00
|
|
|
while (index >= 0) {
|
2007-10-06 19:03:41 +00:00
|
|
|
int length = exprKeyword.matchedLength();
|
|
|
|
setFormat(index, length, keywordFormat);
|
2009-03-09 19:54:47 +00:00
|
|
|
index = exprKeyword.indexIn(text, index + length);
|
2007-10-06 19:03:41 +00:00
|
|
|
}
|
2007-11-26 21:48:41 +00:00
|
|
|
// %comment
|
|
|
|
// Treat a line as a comment starting at a percent sign
|
|
|
|
// * that is the first character in a line
|
2017-07-03 13:53:14 -04:00
|
|
|
// * that is preceded by
|
2007-11-26 21:48:41 +00:00
|
|
|
// ** an even number of backslashes
|
2007-12-24 13:55:01 +00:00
|
|
|
// ** any character other than a backslash
|
2017-07-03 13:53:14 -04:00
|
|
|
QRegExp exprComment("(?:^|[^\\\\])(?:\\\\\\\\)*(%).*$");
|
2009-03-09 19:54:47 +00:00
|
|
|
exprComment.indexIn(text);
|
2007-11-26 21:48:41 +00:00
|
|
|
index = exprComment.pos(1);
|
2009-03-09 19:47:46 +00:00
|
|
|
while (index >= 0) {
|
2017-07-03 13:53:14 -04:00
|
|
|
int const length = exprComment.matchedLength()
|
2007-11-26 21:48:41 +00:00
|
|
|
- (index - exprComment.pos(0));
|
2007-10-06 19:03:41 +00:00
|
|
|
setFormat(index, length, commentFormat);
|
2009-03-09 19:54:47 +00:00
|
|
|
exprComment.indexIn(text, index + length);
|
2007-11-26 21:48:41 +00:00
|
|
|
index = exprComment.pos(1);
|
2007-10-06 19:03:41 +00:00
|
|
|
}
|
2007-12-30 21:28:38 +00:00
|
|
|
// <LyX Warning: ...>
|
|
|
|
QString lyxwarn = qt_("LyX Warning: ");
|
|
|
|
QRegExp exprWarning("<" + lyxwarn + "[^<]*>");
|
2009-03-09 19:54:47 +00:00
|
|
|
index = exprWarning.indexIn(text);
|
2009-03-09 19:47:46 +00:00
|
|
|
while (index >= 0) {
|
2007-12-24 13:55:01 +00:00
|
|
|
int length = exprWarning.matchedLength();
|
|
|
|
setFormat(index, length, warningFormat);
|
2009-03-09 19:54:47 +00:00
|
|
|
index = exprWarning.indexIn(text, index + length);
|
2007-12-24 13:55:01 +00:00
|
|
|
}
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#else
|
2022-02-12 17:10:34 +01:00
|
|
|
// keyval
|
|
|
|
if (keyval_) {
|
|
|
|
// Highlight key-val options. Used in some option widgets.
|
|
|
|
static const QRegularExpression exprKeyvalkey("[^=,]+");
|
|
|
|
static const QRegularExpression exprKeyvalval("[^,]+");
|
|
|
|
QRegularExpressionMatch matchkey = exprKeyvalkey.match(text);
|
|
|
|
int kvindex = matchkey.capturedStart(0);
|
|
|
|
while (kvindex >= 0) {
|
|
|
|
int length = matchkey.capturedLength(0);
|
|
|
|
setFormat(kvindex, length, keyFormat);
|
|
|
|
QRegularExpressionMatch matchval =
|
|
|
|
exprKeyvalval.match(text, kvindex + length);
|
|
|
|
int kvvindex = matchval.capturedStart(0);
|
|
|
|
if (kvvindex > 0) {
|
|
|
|
length += matchval.capturedLength(0);
|
|
|
|
setFormat(kvvindex, length, valFormat);
|
|
|
|
}
|
|
|
|
matchkey = exprKeyvalkey.match(text, kvindex + length);
|
|
|
|
kvindex = matchkey.capturedStart(0);
|
|
|
|
}
|
|
|
|
}
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
// $ $
|
|
|
|
static const QRegularExpression exprMath("\\$[^\\$]*\\$");
|
|
|
|
QRegularExpressionMatch match = exprMath.match(text);
|
2021-03-17 10:17:10 +01:00
|
|
|
int index = match.capturedStart(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
while (index >= 0) {
|
2021-03-17 10:17:10 +01:00
|
|
|
int length = match.capturedLength(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
setFormat(index, length, mathFormat);
|
|
|
|
match = exprMath.match(text, index + length);
|
2021-03-17 10:17:10 +01:00
|
|
|
index = match.capturedStart(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
}
|
|
|
|
// [ ]
|
|
|
|
static const QRegularExpression exprStartDispMath("(\\\\\\[|"
|
|
|
|
"\\\\begin\\{equation\\**\\}|"
|
|
|
|
"\\\\begin\\{eqnarray\\**\\}|"
|
|
|
|
"\\\\begin\\{align(ed|at)*\\**\\}|"
|
|
|
|
"\\\\begin\\{flalign\\**\\}|"
|
|
|
|
"\\\\begin\\{gather\\**\\}|"
|
|
|
|
"\\\\begin\\{multline\\**\\}|"
|
|
|
|
"\\\\begin\\{array\\**\\}|"
|
|
|
|
"\\\\begin\\{cases\\**\\}"
|
|
|
|
")");
|
|
|
|
static const QRegularExpression exprEndDispMath("(\\\\\\]|"
|
|
|
|
"\\\\end\\{equation\\**\\}|"
|
|
|
|
"\\\\end\\{eqnarray\\**\\}|"
|
|
|
|
"\\\\end\\{align(ed|at)*\\**\\}|"
|
|
|
|
"\\\\end\\{flalign\\**\\}|"
|
|
|
|
"\\\\end\\{gather\\**\\}|"
|
|
|
|
"\\\\end\\{multline\\**\\}|"
|
|
|
|
"\\\\end\\{array\\**\\}|"
|
|
|
|
"\\\\end\\{cases\\**\\}"
|
|
|
|
")");
|
|
|
|
int startIndex = 0;
|
|
|
|
// if previous block was in 'disp math'
|
|
|
|
// start search from 0 (for end disp math)
|
|
|
|
// otherwise, start search from 'begin disp math'
|
|
|
|
if (previousBlockState() != 1) {
|
|
|
|
match = exprStartDispMath.match(text);
|
2021-03-17 10:17:10 +01:00
|
|
|
startIndex = match.capturedStart(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
}
|
|
|
|
while (startIndex >= 0) {
|
|
|
|
match = exprEndDispMath.match(text, startIndex);
|
2021-03-17 10:17:10 +01:00
|
|
|
int endIndex = match.capturedStart(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
int length;
|
|
|
|
if (endIndex == -1) {
|
|
|
|
setCurrentBlockState(1);
|
|
|
|
length = text.length() - startIndex;
|
|
|
|
} else {
|
2021-03-17 10:17:10 +01:00
|
|
|
length = endIndex - startIndex + match.capturedLength(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
}
|
|
|
|
setFormat(startIndex, length, mathFormat);
|
|
|
|
match = exprStartDispMath.match(text, startIndex + length);
|
2021-03-17 10:17:10 +01:00
|
|
|
startIndex = match.capturedStart(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
}
|
|
|
|
// \whatever
|
|
|
|
static const QRegularExpression exprKeywordAtOther("\\\\[A-Za-z]+");
|
|
|
|
// \wh@tever
|
|
|
|
static const QRegularExpression exprKeywordAtLetter("\\\\[A-Za-z@]+");
|
|
|
|
QRegularExpression const & exprKeyword = at_letter_
|
|
|
|
? exprKeywordAtLetter : exprKeywordAtOther;
|
|
|
|
match = exprKeyword.match(text);
|
2021-03-17 10:17:10 +01:00
|
|
|
index = match.capturedStart(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
while (index >= 0) {
|
2021-03-17 10:17:10 +01:00
|
|
|
int length = match.capturedLength(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
setFormat(index, length, keywordFormat);
|
|
|
|
match = exprKeyword.match(text, index + length);
|
2021-03-17 10:17:10 +01:00
|
|
|
index = match.capturedStart(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
}
|
|
|
|
// %comment
|
|
|
|
// Treat a line as a comment starting at a percent sign
|
|
|
|
// * that is the first character in a line
|
|
|
|
// * that is preceded by
|
|
|
|
// ** an even number of backslashes
|
|
|
|
// ** any character other than a backslash
|
|
|
|
QRegularExpression exprComment("(?:^|[^\\\\])(?:\\\\\\\\)*(%).*$");
|
|
|
|
match = exprComment.match(text);
|
|
|
|
index = match.capturedStart(1);
|
|
|
|
while (index >= 0) {
|
2021-03-17 10:17:10 +01:00
|
|
|
int const length = match.capturedLength(0)
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
- (index - match.capturedStart(0));
|
|
|
|
setFormat(index, length, commentFormat);
|
|
|
|
match = exprComment.match(text, index + length);
|
|
|
|
index = match.capturedStart(1);
|
|
|
|
}
|
|
|
|
// <LyX Warning: ...>
|
|
|
|
QString lyxwarn = qt_("LyX Warning: ");
|
|
|
|
QRegularExpression exprWarning("<" + lyxwarn + "[^<]*>");
|
|
|
|
match = exprWarning.match(text);
|
2021-03-17 10:17:10 +01:00
|
|
|
index = match.capturedStart(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
while (index >= 0) {
|
2021-03-17 10:17:10 +01:00
|
|
|
int length = match.capturedLength(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
setFormat(index, length, warningFormat);
|
|
|
|
match = exprWarning.match(text, index + length);
|
2021-03-17 10:17:10 +01:00
|
|
|
index = match.capturedStart(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
}
|
|
|
|
#endif
|
2007-10-06 19:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|