Jürgen Spitzmüller wrote:
> we could use the LaTeX highlighter in QViewSource to make this warning red
> and bold (which should even work with translated strings, right?).
Like this.
Jürgen
Index: src/frontends/qt4/QViewSource.cpp
===================================================================
--- src/frontends/qt4/QViewSource.cpp (Revision 22260)
+++ src/frontends/qt4/QViewSource.cpp (Arbeitskopie)
@@ -78,6 +78,8 @@
keywordFormat.setForeground(Qt::darkBlue);
keywordFormat.setFontWeight(QFont::Bold);
commentFormat.setForeground(Qt::darkGray);
+ warningFormat.setForeground(Qt::red);
+ warningFormat.setFontWeight(QFont::Bold);
mathFormat.setForeground(Qt::red);
}
@@ -144,7 +146,7 @@
// * that is the first character in a line
// * that is preceded by
// ** an even number of backslashes
- // ** any character other than a backslash
+ // ** any character other than a backslash
QRegExp exprComment("(?:^|[^\\\\])(?:\\\\\\\\)*(%).*$");
text.indexOf(exprComment);
index = exprComment.pos(1);
@@ -155,6 +157,16 @@
text.indexOf(exprComment, index + length);
index = exprComment.pos(1);
}
+ // <LyX Warning: ...> ... </LyX Warning>
+ QString opening = QRegExp::escape(qt_("<LyX Warning:"));
+ QString closing = QRegExp::escape(qt_("</LyX Warning>"));
+ QRegExp exprWarning(opening + "[^<]*" + closing);
+ index = text.indexOf(exprWarning);
+ while (index >= 0) {
+ int length = exprWarning.matchedLength();
+ setFormat(index, length, warningFormat);
+ index = text.indexOf(exprWarning, index + length);
+ }
}
Index: src/frontends/qt4/QViewSource.h
===================================================================
--- src/frontends/qt4/QViewSource.h (Revision 22260)
+++ src/frontends/qt4/QViewSource.h (Arbeitskopie)
@@ -40,6 +40,7 @@
QTextCharFormat commentFormat;
QTextCharFormat keywordFormat;
QTextCharFormat mathFormat;
+ QTextCharFormat warningFormat;
};
Index: src/Paragraph.cpp
===================================================================
--- src/Paragraph.cpp (Revision 22260)
+++ src/Paragraph.cpp (Arbeitskopie)
@@ -2236,10 +2236,16 @@
basefont, outerfont, open_font,
runningChange, *style, i, column, c);
} catch (EncodingException & e) {
- // add location information and throw again.
- e.par_id = id();
- e.pos = i;
- throw(e);
+ if (runparams.dryrun) {
+ os << _("<LyX Warning: uncodable character>");
+ os.put(c);
+ os << _("</LyX Warning>");
+ } else {
+ // add location information and throw again.
+ e.par_id = id();
+ e.pos = i;
+ throw(e);
+ }
}
// Set the encoding to that returned from simpleTeXSpecialChars (see