#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
#include "math_data.h"
#include "math_inset.h"
+#include "math_cursor.h"
#include "math_deliminset.h"
-#include "math_charinset.h"
+#include "math_fontinset.h"
#include "math_scriptinset.h"
-#include "math_stringinset.h"
-#include "math_matrixinset.h"
#include "math_mathmlstream.h"
#include "math_support.h"
#include "math_replace.h"
void MathArray::insert(size_type pos, MathArray const & ar)
{
+ lyx::Assert(pos <= size());
base_type::insert(begin() + pos, ar.begin(), ar.end());
}
{
NormalStream ns(lyxerr);
for (const_iterator it = begin(); it != end(); ++it)
- ns << "<" << *it << ">";
+ ns << '<' << *it << '>';
}
drawn_ = false;
mathed_char_dim(mi.base.font, 'I', dim_);
- if (empty())
+ if (empty())
return dim_;
dim_.w = 0;
{
//if (drawn_ && x == xo_ && y == yo_)
// return;
- //lyxerr << "x: " << x << " y: " << y << " " << pain.workAreaHeight() << endl;
+ //lyxerr << "x: " << x << " y: " << y << ' ' << pain.workAreaHeight() << endl;
xo_ = x;
yo_ = y;
drawn_ = true;
y2 = yo_ + descent();
}
+
void MathArray::center(int & x, int & y) const
{
x = xo_ + width() / 2;
xo_ = x;
yo_ = y;
}
+
+
+void MathArray::notifyCursorLeaves()
+{
+ // do not recurse!
+
+ // remove base-only "scripts"
+ for (pos_type i = 0; i + 1 < size(); ++i) {
+ MathScriptInset * p = operator[](i).nucleus()->asScriptInset();
+ if (p && p->cell(0).empty() && p->cell(1).empty()) {
+ MathArray ar = p->nuc();
+ erase(i);
+ insert(i, ar);
+ mathcursor->adjust(i, ar.size() - 1);
+ }
+ }
+
+ // glue adjacent font insets of the same kind
+ for (pos_type i = 0; i + 1 < size(); ++i) {
+ MathFontInset * p = operator[](i).nucleus()->asFontInset();
+ MathFontInset const * q = operator[](i + 1)->asFontInset();
+ if (p && q && p->name() == q->name()) {
+ p->cell(0).append(q->cell(0));
+ erase(i + 1);
+ mathcursor->adjust(i, -1);
+ }
+ }
+
+}