]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathStream.cpp
Make undo action no-ops when the buffer is read-only
[lyx.git] / src / mathed / MathStream.cpp
index 6f4da39bf71b097f80089e87e565317462cce925..a05e54aacd80b2e8fc0bb6250128d1491e259bba 100644 (file)
@@ -26,6 +26,7 @@
 #include <algorithm>
 #include <cstring>
 #include <ostream>
+#include <FontInfo.h>
 
 using namespace std;
 
@@ -111,6 +112,10 @@ TeXMathStream & operator<<(TeXMathStream & ws, docstring const & s)
                else if (s[first] == ' ' && ws.textMode())
                        ws.os() << '\\';
                ws.pendingSpace(false);
+       } else if (ws.useBraces()) {
+               if (s[first] == '\'')
+                       ws.os() << "{}";
+               ws.useBraces(false);
        }
        ws.os() << s.substr(first);
        int lf = 0;
@@ -241,6 +246,10 @@ TeXMathStream & operator<<(TeXMathStream & ws, char c)
                else if (c == ' ' && ws.textMode())
                        ws.os() << '\\';
                ws.pendingSpace(false);
+       } else if (ws.useBraces()) {
+               if (c == '\'')
+                       ws.os() << "{}";
+               ws.useBraces(false);
        }
        ws.os() << c;
        if (c == '\n')
@@ -281,7 +290,12 @@ TeXMathStream & operator<<(TeXMathStream & ws, unsigned int i)
 
 MathMLStream::MathMLStream(odocstream & os, std::string const & xmlns, bool xmlMode)
        : os_(os), tab_(0), line_(0), in_text_(false), xmlns_(xmlns), xml_mode_(xmlMode)
-{}
+{
+       if (in_text_)
+               font_math_style_ = TEXT_STYLE;
+       else
+               font_math_style_ = DISPLAY_STYLE;
+}
 
 
 void MathMLStream::cr()
@@ -347,7 +361,18 @@ MathMLStream & operator<<(MathMLStream & ms, char_type c)
 
 MathMLStream & operator<<(MathMLStream & ms, MTag const & t)
 {
+       ms.cr();
        ++ms.tab();
+       ms.os() << '<' << from_ascii(ms.namespacedTag(t.tag_));
+       if (!t.attr_.empty())
+               ms.os() << " " << from_ascii(t.attr_);
+       ms << ">";
+       return ms;
+}
+
+
+MathMLStream & operator<<(MathMLStream & ms, MTagInline const & t)
+{
        ms.cr();
        ms.os() << '<' << from_ascii(ms.namespacedTag(t.tag_));
        if (!t.attr_.empty())
@@ -359,9 +384,16 @@ MathMLStream & operator<<(MathMLStream & ms, MTag const & t)
 
 MathMLStream & operator<<(MathMLStream & ms, ETag const & t)
 {
-       ms.cr();
        if (ms.tab() > 0)
                --ms.tab();
+       ms.cr();
+       ms.os() << "</" << from_ascii(ms.namespacedTag(t.tag_)) << ">";
+       return ms;
+}
+
+
+MathMLStream & operator<<(MathMLStream & ms, ETagInline const & t)
+{
        ms.os() << "</" << from_ascii(ms.namespacedTag(t.tag_)) << ">";
        return ms;
 }