- better translatable error message for uncodable chars, now also
displaying the code point value.
* src/Paragraph.cpp:
- do not throw in View Source mode, but mark up uncodable chars (fix bug 4437).
* src/frontends/qt4/LaTeXHighlighter.{cpp,h}:
- highlight LyX warnings.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22294
a592a061-630c-0410-9148-
cb99ea01b6c8
runparams, output_preamble, output_body);
}
catch (EncodingException & e) {
- docstring msg = _("Could not find LaTeX command for character '%'");
- msg[msg.size() - 2] = e.failed_char;
+ odocstringstream ods;
+ ods.put(e.failed_char);
+ ostringstream oss;
+ oss << "0x" << hex << e.failed_char << dec;
+ docstring msg = bformat(_("Could not find LaTeX command for character '%1$s'"
+ " (code point %2$s)"),
+ ods.str(), from_utf8(oss.str()));
errorList.push_back(ErrorItem(msg, _("Some characters of your document are probably not "
"representable in the chosen encoding.\n"
"Changing the document encoding to utf8 could help."),
d->latexSpecialChar(os, rp, running_font, runningChange,
*style, i, column);
} 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);
+ }
}
}
#include <config.h>
#include "LaTeXHighlighter.h"
+#include "qt_helpers.h"
#include <QString>
#include <QTextDocument>
keywordFormat.setFontWeight(QFont::Bold);
commentFormat.setForeground(Qt::darkGray);
mathFormat.setForeground(Qt::red);
+ warningFormat.setForeground(Qt::red);
+ warningFormat.setFontWeight(QFont::Bold);
}
// * 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);
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);
+ }
}
} // namespace frontend
QTextCharFormat commentFormat;
QTextCharFormat keywordFormat;
QTextCharFormat mathFormat;
+ QTextCharFormat warningFormat;
};
} // namespace frontend