]> git.lyx.org Git - features.git/blobdiff - src/mathed/array.C
write \mathrm{x}\mathrm{y} as \mathrm{xy} again
[features.git] / src / mathed / array.C
index c91d52ed84626a27048c3b5d9d349d68ed60425c..48deaf73ab7066e3b125c9b91b8cb0d7bb11a3bb 100644 (file)
@@ -5,6 +5,7 @@
 #include "math_inset.h"
 #include "math_charinset.h"
 #include "math_scriptinset.h"
+#include "math_stringinset.h"
 #include "debug.h"
 #include "array.h"
 #include "mathed/support.h"
@@ -96,7 +97,7 @@ bool MathArray::empty() const
 {
        return bf_.empty();
 }
-   
+
 
 MathArray::size_type MathArray::size() const
 {
@@ -171,29 +172,42 @@ string charSequence(MathArray::const_iterator it, MathArray::const_iterator end)
 }
 
 
-void MathArray::write(ostream & os, bool fragile) const
+MathArray MathArray::glueChars() const
+{
+       MathArray ar;
+       const_iterator it = begin();
+       while (it != end()) {
+               if (it->nucleus() && it->nucleus()->asCharInset()) {
+                       string s = charSequence(it, end());
+                       MathTextCodes c = it->nucleus()->asCharInset()->code();
+                       ar.push_back(MathAtom(new MathStringInset(s, c)));
+                       it += s.size();
+               } else {
+                       ar.push_back(*it);
+                       ++it;
+               }
+       }
+       return ar;
+}
+
+
+void MathArray::write(MathWriteInfo & wi) const
+{
+       glueChars().write1(wi);
+}
+
+
+void MathArray::write1(MathWriteInfo & wi) const
 {
        for (const_iterator it = begin(); it != end(); ++it) {  
                MathInset * p = it->nucleus();
                if (!p)
                        continue;
-
-/*
-               if (p->asCharInset()) {
-                       MathCharInset const * c = p->asCharInset();
-                       // special handling for character sequences with the same code
-                       string s = charSequence(it, end());
-                       c->writeHeader(os);
-                       os << s;
-                       c->writeTrailer(os);
-                       it += s.size() - 1;
-               } else
-*/
                if (MathScriptInset const * q = asScript(it)) {
-                       q->write(p, os, fragile);
+                       q->write(p, wi);
                        ++it;
                } else {
-                       p->write(os, fragile);
+                       p->write(wi);
                }
        }
 }
@@ -201,10 +215,17 @@ void MathArray::write(ostream & os, bool fragile) const
 
 void MathArray::writeNormal(ostream & os) const
 {
-       os << "[par ";
-       for (const_iterator it = begin(); it != end(); ++it)
-               (*it)->writeNormal(os);
-       os << "]";
+       for (const_iterator it = begin(); it != end(); ++it) {  
+               MathInset * p = it->nucleus();
+               if (!p)
+                       continue;
+               if (MathScriptInset const * q = asScript(it)) {
+                       q->writeNormal(p, os);
+                       ++it;
+               } else {
+                       p->writeNormal(os);
+               }
+       }
 }