* math_parser.C: new "lexxer"
+ * array.C: write sequences of chars with same code as a unit
+
2001-08-13 André Pönitz <poenitz@gmx.net>
* math_factory.[Ch]: new files for the creation of math insets
#endif
#include "math_inset.h"
+#include "math_charinset.h"
#include "debug.h"
#include "array.h"
#include "mathed/support.h"
return os;
}
+// returns sequence of char with same code starting at it up to end
+// it might be less, though...
+string charSequence(MathArray::const_iterator it, MathArray::const_iterator end)
+{
+ string s;
+ MathCharInset const * p = (*it)->asCharInset();
+ if (!p)
+ return s;
+
+ MathTextCodes c = p->code();
+ while (it != end && (p = (*it)->asCharInset()) && p->code() == c) {
+ s += p->getChar();
+ ++it;
+ }
+ return s;
+}
+
void MathArray::write(ostream & os, bool fragile) const
{
- for (const_iterator it = begin(); it != end(); ++it)
- (*it)->write(os, fragile);
+ for (const_iterator it = begin(); it != end(); ) {
+ MathCharInset const * p = (*it)->asCharInset();
+ if (p) {
+ // special handling for character sequences with the same code
+ string s = charSequence(it, end());
+ p->writeHeader(os);
+ os << s;
+ p->writeTrailer(os);
+ it += s.size();
+ } else {
+ (*it)->write(os, fragile);
+ ++it;
+ }
+ }
}
}
-void MathCharInset::write(std::ostream & os, bool) const
+void MathCharInset::writeHeader(std::ostream & os) const
{
if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
os << '\\' << math_font_name[code_ - LM_TC_RM] << '{';
+}
- if (code_ == LM_TC_TEX || code_ == LM_TC_SPECIAL)
- os << '\\';
-
- os << char_;
+void MathCharInset::writeTrailer(std::ostream & os) const
+{
if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
os << '}';
}
+void MathCharInset::writeRaw(std::ostream & os) const
+{
+ os << char_;
+}
+
+
+void MathCharInset::write(std::ostream & os, bool) const
+{
+ writeHeader(os);
+ writeRaw(os);
+ writeTrailer(os);
+}
+
+
void MathCharInset::writeNormal(std::ostream & os) const
{
os << char_;
///
void write(std::ostream &, bool fragile) const;
///
+ void writeHeader(std::ostream &) const;
+ ///
+ void writeTrailer(std::ostream &) const;
+ ///
+ void writeRaw(std::ostream &) const;
+ ///
void writeNormal(std::ostream &) const;
///
int ascent() const;
///
int width() const;
/// identifies Charinsets
- bool isCharInset() const { return true; }
+ MathCharInset const * asCharInset() const { return this; }
///
char getChar() const { return char_; }
///
class LaTeXFeatures;
+class MathCharInset;
class MathInset {
public:
/// identifies ArrayInsets
virtual bool isArray() const { return false; }
/// identifies Charinsets
- virtual bool isCharInset() const { return false; }
+ virtual MathCharInset const * asCharInset() const { return 0; }
///
virtual bool isActive() const { return nargs() > 0; }
///