Jürgen Spitzmüller wrote:
> I think the character code point should rather be displayed in the error
> dialog.

I did this (see attached) and also changed the error message to something 
really translatable, using bformat.

Jürgen
Index: src/frontends/qt4/QViewSource.cpp
===================================================================
--- src/frontends/qt4/QViewSource.cpp	(Revision 22279)
+++ 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 22279)
+++ 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 22279)
+++ 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
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp	(Revision 22279)
+++ src/Buffer.cpp	(Arbeitskopie)
@@ -954,8 +954,13 @@
 		      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" << std::hex << e.failed_char << std::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."),

Reply via email to