]> git.lyx.org Git - features.git/commitdiff
* src/Buffer.cpp:
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 24 Dec 2007 13:55:01 +0000 (13:55 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 24 Dec 2007 13:55:01 +0000 (13:55 +0000)
- 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

src/Buffer.cpp
src/Paragraph.cpp
src/frontends/qt4/LaTeXHighlighter.cpp
src/frontends/qt4/LaTeXHighlighter.h

index 62451eadccbfee55408df8349a23618471644cf0..a740c6ddab6e2344b72d754339db6911d503cfd3 100644 (file)
@@ -1024,8 +1024,13 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
                      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."),
index 61fe11117bf5f64e1b75cf7c0d05729cce1dbb6b..8686f24db0b7e7bcc93c473a372dd514c1af053d 100644 (file)
@@ -2024,10 +2024,16 @@ bool Paragraph::latex(Buffer const & buf,
                                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);
+                               }
                        }
                }
 
index 30a50f8123dc487b8b853833fa660420e32bd0aa..ed3dd45142a899c23d5d25294cb916f904eb867b 100644 (file)
@@ -11,6 +11,7 @@
 #include <config.h>
 
 #include "LaTeXHighlighter.h"
+#include "qt_helpers.h"
 
 #include <QString>
 #include <QTextDocument>
@@ -25,6 +26,8 @@ LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent)
        keywordFormat.setFontWeight(QFont::Bold);
        commentFormat.setForeground(Qt::darkGray);
        mathFormat.setForeground(Qt::red);
+       warningFormat.setForeground(Qt::red);
+       warningFormat.setFontWeight(QFont::Bold);
 }
 
 
@@ -90,7 +93,7 @@ void LaTeXHighlighter::highlightBlock(QString const & text)
        // * 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);
@@ -101,6 +104,16 @@ void LaTeXHighlighter::highlightBlock(QString const & text)
                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
index 31afe323248b69eb1781a7b3d4da9248cd624b78..51da3672c1899a757ef1ca805b9c42190d297ac1 100644 (file)
@@ -34,6 +34,7 @@ private:
        QTextCharFormat commentFormat;
        QTextCharFormat keywordFormat;
        QTextCharFormat mathFormat;
+       QTextCharFormat warningFormat;
 };
 
 } // namespace frontend