2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiLog.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
2007-10-06 11:45:53 +00:00
|
|
|
* \author Angus Leeming
|
2009-06-18 09:35:51 +00:00
|
|
|
* \author Jürgen Spitzmüller
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiLog.h"
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2007-11-18 20:36:52 +00:00
|
|
|
#include "GuiApplication.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "qt_helpers.h"
|
2007-10-06 11:45:53 +00:00
|
|
|
#include "Lexer.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2014-04-29 15:28:21 +02:00
|
|
|
#include "frontends/Clipboard.h"
|
|
|
|
|
2008-05-24 10:15:52 +00:00
|
|
|
#include "support/docstring.h"
|
|
|
|
#include "support/gettext.h"
|
2017-01-02 12:00:10 +01:00
|
|
|
#include "support/lstrings.h"
|
2008-05-24 10:15:52 +00:00
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#include <QTextBrowser>
|
2007-09-05 20:33:29 +00:00
|
|
|
#include <QSyntaxHighlighter>
|
2007-10-11 19:35:49 +00:00
|
|
|
#include <QClipboard>
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2007-10-06 11:45:53 +00:00
|
|
|
#include <fstream>
|
2007-09-05 20:33:29 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
using namespace lyx::support;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2009-06-18 09:35:51 +00:00
|
|
|
|
|
|
|
// Regular expressions needed at several places
|
2013-05-27 18:48:46 +02:00
|
|
|
// FIXME: These regexes are incomplete. It would be good if we could collect those used in LaTeX::scanLogFile
|
|
|
|
// and LaTeX::scanBlgFile and re-use them here!(spitz, 2013-05-27)
|
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
|
2009-06-18 09:35:51 +00:00
|
|
|
// Information
|
2017-07-24 09:09:48 +02:00
|
|
|
QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|.*> INFO - |\\(|\\\\).*$");
|
2009-06-18 09:35:51 +00:00
|
|
|
// Warnings
|
2019-12-15 13:48:21 +01:00
|
|
|
QRegExp exprWarning("^(## Warning|LaTeX Warning|LaTeX Font Warning|Package [\\w\\.]+ Warning|Class \\w+ Warning|Warning--|Underfull|Overfull|.*> WARN - ).*$");
|
2009-06-18 09:35:51 +00:00
|
|
|
// Errors
|
2019-12-15 13:48:21 +01:00
|
|
|
QRegExp exprError("^(ERROR: |!|.*---line [0-9]+ of file|.*> FATAL - |.*> ERROR - |Missing character: There is no ).*$");
|
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
|
|
|
|
// Information
|
|
|
|
QRegularExpression exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|.*> INFO - |\\(|\\\\).*$");
|
|
|
|
// Warnings
|
|
|
|
QRegularExpression exprWarning("^(## Warning|LaTeX Warning|LaTeX Font Warning|Package [\\w\\.]+ Warning|Class \\w+ Warning|Warning--|Underfull|Overfull|.*> WARN - ).*$");
|
|
|
|
// Errors
|
|
|
|
QRegularExpression exprError("^(ERROR: |!|.*---line [0-9]+ of file|.*> FATAL - |.*> ERROR - |Missing character: There is no ).*$");
|
|
|
|
#endif
|
2009-06-18 09:35:51 +00:00
|
|
|
|
|
|
|
|
2007-04-24 19:37:34 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2007-09-05 20:33:29 +00:00
|
|
|
// LogHighlighter
|
2007-04-24 19:37:34 +00:00
|
|
|
//
|
2007-09-05 20:33:29 +00:00
|
|
|
////////////////////////////////////////////////////////////////////
|
2007-04-24 19:37:34 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
class LogHighlighter : public QSyntaxHighlighter
|
2007-04-24 19:37:34 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
public:
|
|
|
|
LogHighlighter(QTextDocument * parent);
|
2007-04-24 19:37:34 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
private:
|
2020-10-01 10:42:11 +03:00
|
|
|
void highlightBlock(QString const & text) override;
|
2007-04-24 19:37:34 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
private:
|
|
|
|
QTextCharFormat infoFormat;
|
|
|
|
QTextCharFormat warningFormat;
|
|
|
|
QTextCharFormat errorFormat;
|
|
|
|
};
|
2007-04-24 19:37:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LogHighlighter::LogHighlighter(QTextDocument * parent)
|
|
|
|
: QSyntaxHighlighter(parent)
|
2007-03-26 04:25:49 +00:00
|
|
|
{
|
2007-03-28 00:26:04 +00:00
|
|
|
infoFormat.setForeground(Qt::darkGray);
|
2007-03-26 04:25:49 +00:00
|
|
|
warningFormat.setForeground(Qt::darkBlue);
|
|
|
|
errorFormat.setForeground(Qt::red);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-24 19:37:34 +00:00
|
|
|
void LogHighlighter::highlightBlock(QString const & text)
|
2007-03-26 04:25:49 +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
|
|
|
#if QT_VERSION < 0x060000
|
2007-03-26 04:25:49 +00:00
|
|
|
// Info
|
2009-03-09 19:54:47 +00:00
|
|
|
int index = exprInfo.indexIn(text);
|
2007-03-26 04:25:49 +00:00
|
|
|
while (index >= 0) {
|
|
|
|
int length = exprInfo.matchedLength();
|
|
|
|
setFormat(index, length, infoFormat);
|
2009-03-09 19:54:47 +00:00
|
|
|
index = exprInfo.indexIn(text, index + length);
|
2007-03-26 04:25:49 +00:00
|
|
|
}
|
|
|
|
// LaTeX Warning:
|
2009-03-09 19:54:47 +00:00
|
|
|
index = exprWarning.indexIn(text);
|
2007-03-26 04:25:49 +00:00
|
|
|
while (index >= 0) {
|
|
|
|
int length = exprWarning.matchedLength();
|
|
|
|
setFormat(index, length, warningFormat);
|
2009-03-09 19:54:47 +00:00
|
|
|
index = exprWarning.indexIn(text, index + length);
|
2007-03-26 04:25:49 +00:00
|
|
|
}
|
2007-05-28 22:27:45 +00:00
|
|
|
// ! error
|
2009-03-09 19:54:47 +00:00
|
|
|
index = exprError.indexIn(text);
|
2007-03-26 04:25:49 +00:00
|
|
|
while (index >= 0) {
|
|
|
|
int length = exprError.matchedLength();
|
|
|
|
setFormat(index, length, errorFormat);
|
2009-03-09 19:54:47 +00:00
|
|
|
index = exprError.indexIn(text, index + length);
|
2007-03-26 04:25:49 +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
|
|
|
|
// Info
|
|
|
|
QRegularExpressionMatch match = exprInfo.match(text);
|
|
|
|
int index = match.capturedStart(1);
|
|
|
|
while (index >= 0) {
|
|
|
|
int length = match.capturedEnd(1) - index;
|
|
|
|
setFormat(index, length, infoFormat);
|
|
|
|
match = exprInfo.match(text, index + length);
|
|
|
|
index = match.capturedStart(1);
|
|
|
|
}
|
|
|
|
// LaTeX Warning:
|
|
|
|
match = exprWarning.match(text);
|
|
|
|
index = match.capturedStart(1);
|
|
|
|
while (index >= 0) {
|
|
|
|
int length = match.capturedEnd(1) - index;
|
|
|
|
setFormat(index, length, warningFormat);
|
|
|
|
match = exprWarning.match(text, index + length);
|
|
|
|
index = match.capturedStart(1);
|
|
|
|
}
|
|
|
|
// ! error
|
|
|
|
match = exprError.match(text);
|
|
|
|
index = match.capturedStart(1);
|
|
|
|
while (index >= 0) {
|
|
|
|
int length = match.capturedEnd(1) - index;
|
|
|
|
setFormat(index, length, errorFormat);
|
|
|
|
match = exprError.match(text, index + length);
|
|
|
|
index = match.capturedStart(1);
|
|
|
|
}
|
|
|
|
#endif
|
2007-03-26 04:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-24 19:37:34 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2007-08-31 05:53:55 +00:00
|
|
|
// GuiLog
|
2007-04-24 19:37:34 +00:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiLog::GuiLog(GuiView & lv)
|
2008-02-05 12:43:19 +00:00
|
|
|
: GuiDialog(lv, "log", qt_("LaTeX Log")), type_(LatexLog)
|
2007-09-05 20:33:29 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-04-24 19:37:34 +00:00
|
|
|
|
2018-07-10 09:04:42 +02:00
|
|
|
connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
|
|
|
|
this, SLOT(slotButtonBox(QAbstractButton *)));
|
2007-10-06 11:45:53 +00:00
|
|
|
connect(updatePB, SIGNAL(clicked()), this, SLOT(updateContents()));
|
2009-06-18 09:35:51 +00:00
|
|
|
connect(findPB, SIGNAL(clicked()), this, SLOT(find()));
|
|
|
|
connect(findLE, SIGNAL(returnPressed()), this, SLOT(find()));
|
2009-11-29 17:15:22 +00:00
|
|
|
connect(logTypeCO, SIGNAL(activated(int)),
|
|
|
|
this, SLOT(typeChanged(int)));
|
2007-04-24 19:37:34 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
|
2007-04-24 19:37:34 +00:00
|
|
|
|
2007-03-26 04:25:49 +00:00
|
|
|
// set syntax highlighting
|
2007-09-05 20:33:29 +00:00
|
|
|
highlighter = new LogHighlighter(logTB->document());
|
|
|
|
|
|
|
|
logTB->setReadOnly(true);
|
2016-04-15 11:49:04 +02:00
|
|
|
logTB->setFont(guiApp->typewriterSystemFont());
|
2020-08-14 20:49:39 +03:00
|
|
|
|
|
|
|
QPushButton * closePB = buttonBox->button(QDialogButtonBox::Close);
|
|
|
|
closePB->setAutoDefault(false);
|
2007-09-05 20:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 11:45:53 +00:00
|
|
|
void GuiLog::updateContents()
|
2007-09-05 20:33:29 +00:00
|
|
|
{
|
2008-02-05 12:43:19 +00:00
|
|
|
setTitle(toqstr(title()));
|
2007-10-06 11:45:53 +00:00
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
ostringstream ss;
|
2007-10-06 11:45:53 +00:00
|
|
|
getContents(ss);
|
|
|
|
|
|
|
|
logTB->setPlainText(toqstr(ss.str()));
|
2009-06-18 09:35:51 +00:00
|
|
|
|
|
|
|
nextErrorPB->setEnabled(contains(exprError));
|
|
|
|
nextWarningPB->setEnabled(contains(exprWarning));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-29 17:15:22 +00:00
|
|
|
void GuiLog::typeChanged(int i)
|
|
|
|
{
|
|
|
|
string const type =
|
|
|
|
fromqstr(logTypeCO->itemData(i).toString());
|
|
|
|
string ext;
|
|
|
|
if (type == "latex")
|
|
|
|
ext = "log";
|
|
|
|
else if (type == "bibtex")
|
|
|
|
ext = "blg";
|
|
|
|
else if (type == "index")
|
|
|
|
ext = "ilg";
|
|
|
|
|
|
|
|
if (!ext.empty())
|
|
|
|
logfile_.changeExtension(ext);
|
|
|
|
|
|
|
|
updateContents();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-18 09:35:51 +00:00
|
|
|
void GuiLog::find()
|
|
|
|
{
|
|
|
|
logTB->find(findLE->text());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiLog::on_nextErrorPB_clicked()
|
|
|
|
{
|
|
|
|
goTo(exprError);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiLog::on_nextWarningPB_clicked()
|
|
|
|
{
|
|
|
|
goTo(exprWarning);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-02 18:19:40 +00:00
|
|
|
void GuiLog::on_openDirPB_clicked()
|
2020-08-12 14:24:40 -04:00
|
|
|
{
|
|
|
|
showDirectory(logfile_.onlyPath());
|
2015-11-02 18:19:40 +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
|
|
|
#if QT_VERSION < 0x060000
|
2009-06-18 09:35:51 +00:00
|
|
|
void GuiLog::goTo(QRegExp const & exp) const
|
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
|
|
|
|
void GuiLog::goTo(QRegularExpression const & exp) const
|
|
|
|
#endif
|
2009-06-18 09:35:51 +00:00
|
|
|
{
|
|
|
|
QTextCursor const newc =
|
|
|
|
logTB->document()->find(exp, logTB->textCursor());
|
|
|
|
logTB->setTextCursor(newc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
2009-06-18 09:35:51 +00:00
|
|
|
bool GuiLog::contains(QRegExp const & exp) const
|
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
|
|
|
|
bool GuiLog::contains(QRegularExpression const & exp) const
|
|
|
|
#endif
|
2009-06-18 09:35:51 +00:00
|
|
|
{
|
|
|
|
return !logTB->document()->find(exp, logTB->textCursor()).isNull();
|
2007-09-05 20:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-24 01:01:34 -05:00
|
|
|
bool GuiLog::initialiseParams(string const & sdata)
|
2007-09-05 20:33:29 +00:00
|
|
|
{
|
2018-02-24 01:01:34 -05:00
|
|
|
istringstream is(sdata);
|
2008-04-02 23:06:22 +00:00
|
|
|
Lexer lex;
|
2007-10-06 11:45:53 +00:00
|
|
|
lex.setStream(is);
|
|
|
|
|
|
|
|
string logtype, logfile;
|
|
|
|
lex >> logtype;
|
|
|
|
if (lex) {
|
|
|
|
lex.next(true);
|
|
|
|
logfile = lex.getString();
|
|
|
|
}
|
|
|
|
if (!lex)
|
|
|
|
// Parsing of the data failed.
|
|
|
|
return false;
|
|
|
|
|
2009-11-29 17:15:22 +00:00
|
|
|
logTypeCO->setEnabled(logtype == "latex");
|
|
|
|
logTypeCO->clear();
|
2017-07-03 13:53:14 -04:00
|
|
|
|
2009-11-29 17:15:22 +00:00
|
|
|
FileName log(logfile);
|
2017-07-03 13:53:14 -04:00
|
|
|
|
2009-11-29 17:15:22 +00:00
|
|
|
if (logtype == "latex") {
|
2007-10-06 11:45:53 +00:00
|
|
|
type_ = LatexLog;
|
2009-11-29 17:15:22 +00:00
|
|
|
logTypeCO->addItem(qt_("LaTeX"), toqstr(logtype));
|
|
|
|
FileName tmp = log;
|
|
|
|
tmp.changeExtension("blg");
|
2017-01-02 12:00:10 +01:00
|
|
|
if (tmp.exists()) {
|
|
|
|
if (support::contains(tmp.fileContents("UTF-8"), from_ascii("This is Biber")))
|
|
|
|
logTypeCO->addItem(qt_("Biber"), QString("bibtex"));
|
|
|
|
else
|
|
|
|
logTypeCO->addItem(qt_("BibTeX"), QString("bibtex"));
|
|
|
|
}
|
2009-11-29 17:15:22 +00:00
|
|
|
tmp.changeExtension("ilg");
|
|
|
|
if (tmp.exists())
|
|
|
|
logTypeCO->addItem(qt_("Index"), QString("index"));
|
2009-05-28 08:59:25 +00:00
|
|
|
// FIXME: not sure "literate" still works.
|
2009-11-29 17:15:22 +00:00
|
|
|
} else if (logtype == "literate") {
|
2007-10-06 11:45:53 +00:00
|
|
|
type_ = LiterateLog;
|
2009-11-29 17:15:22 +00:00
|
|
|
logTypeCO->addItem(qt_("Literate"), toqstr(logtype));
|
|
|
|
} else if (logtype == "lyx2lyx") {
|
2007-10-06 11:45:53 +00:00
|
|
|
type_ = Lyx2lyxLog;
|
2009-11-29 17:15:22 +00:00
|
|
|
logTypeCO->addItem(qt_("LyX2LyX"), toqstr(logtype));
|
|
|
|
} else if (logtype == "vc") {
|
2007-10-06 11:45:53 +00:00
|
|
|
type_ = VCLog;
|
2009-11-29 17:15:22 +00:00
|
|
|
logTypeCO->addItem(qt_("Version Control"), toqstr(logtype));
|
|
|
|
} else
|
2007-10-06 11:45:53 +00:00
|
|
|
return false;
|
|
|
|
|
2009-11-29 17:15:22 +00:00
|
|
|
logfile_ = log;
|
2008-07-20 22:48:48 +00:00
|
|
|
|
|
|
|
updateContents();
|
|
|
|
|
2007-10-06 11:45:53 +00:00
|
|
|
return true;
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 11:45:53 +00:00
|
|
|
void GuiLog::clearParams()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-10-06 11:45:53 +00:00
|
|
|
logfile_.erase();
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
2007-10-06 11:45:53 +00:00
|
|
|
docstring GuiLog::title() const
|
|
|
|
{
|
|
|
|
switch (type_) {
|
|
|
|
case LatexLog:
|
|
|
|
return _("LaTeX Log");
|
|
|
|
case LiterateLog:
|
|
|
|
return _("Literate Programming Build Log");
|
|
|
|
case Lyx2lyxLog:
|
|
|
|
return _("lyx2lyx Error Log");
|
|
|
|
case VCLog:
|
|
|
|
return _("Version Control Log");
|
|
|
|
default:
|
|
|
|
return docstring();
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2007-10-06 11:45:53 +00:00
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
void GuiLog::getContents(ostream & ss) const
|
2007-10-06 11:45:53 +00:00
|
|
|
{
|
2007-12-12 19:28:07 +00:00
|
|
|
ifstream in(logfile_.toFilesystemEncoding().c_str());
|
2007-10-06 11:45:53 +00:00
|
|
|
|
|
|
|
bool success = false;
|
|
|
|
|
|
|
|
// FIXME UNICODE
|
|
|
|
// Our caller interprets the file contents as UTF8, but is that
|
|
|
|
// correct?
|
2017-07-23 12:06:58 +02:00
|
|
|
// spitz: No it isn't (generally). The log file encoding depends on the TeX
|
|
|
|
// _output_ encoding (T1 etc.). We should account for that. See #10728.
|
2007-10-06 11:45:53 +00:00
|
|
|
if (in) {
|
|
|
|
ss << in.rdbuf();
|
|
|
|
success = ss.good();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (type_) {
|
|
|
|
case LatexLog:
|
2009-11-29 17:15:22 +00:00
|
|
|
ss << to_utf8(_("Log file not found."));
|
2007-10-06 11:45:53 +00:00
|
|
|
break;
|
|
|
|
case LiterateLog:
|
|
|
|
ss << to_utf8(_("No literate programming build log file found."));
|
|
|
|
break;
|
|
|
|
case Lyx2lyxLog:
|
|
|
|
ss << to_utf8(_("No lyx2lyx error log file found."));
|
|
|
|
break;
|
|
|
|
case VCLog:
|
|
|
|
ss << to_utf8(_("No version control log file found."));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-11 18:15:30 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-03-26 04:25:49 +00:00
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiLog.cpp"
|