]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathData.cpp
We only support gcc >= 4.9.
[lyx.git] / src / mathed / MathData.cpp
index 868321b086d5419eedd3891b6bac6ac2323adfa3..d3ce3a31c877ec03843005424a0351b3d044ac7d 100644 (file)
 
 #include "InsetMathBrace.h"
 #include "InsetMathFont.h"
+#include "InsetMathMacro.h"
 #include "InsetMathScript.h"
 #include "MacroTable.h"
-#include "InsetMathMacro.h"
+#include "MathRow.h"
 #include "MathStream.h"
 #include "MathSupport.h"
 #include "MetricsInfo.h"
@@ -27,6 +28,7 @@
 #include "BufferView.h"
 #include "CoordCache.h"
 #include "Cursor.h"
+#include "Dimension.h"
 
 #include "mathed/InsetMathUnknown.h"
 
@@ -37,7 +39,6 @@
 #include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
-#include "support/lyxalgo.h"
 
 #include <cstdlib>
 
@@ -47,8 +48,7 @@ namespace lyx {
 
 
 MathData::MathData(Buffer * buf, const_iterator from, const_iterator to)
-       : base_type(from, to), minasc_(0), mindes_(0), slevel_(0),
-         sshift_(0), buffer_(buf)
+       : base_type(from, to), buffer_(buf)
 {}
 
 
@@ -224,6 +224,7 @@ bool MathData::addToMathRow(MathRow & mrow, MetricsInfo & mi) const
 {
        bool has_contents = false;
        BufferView * bv = mi.base.bv;
+       display_style_ = mi.base.font.style() == DISPLAY_STYLE;
        MathData * ar = const_cast<MathData*>(this);
        ar->updateMacros(&bv->cursor(), mi.macrocontext,
                         InternalUpdate, mi.base.macro_nesting);
@@ -295,10 +296,12 @@ void MathData::metrics(MetricsInfo & mi, Dimension & dim, bool tight) const
 
        // This is one of the the few points where the drawing font is known,
        // so that we can set the caret vertical dimensions.
-       mrow.caret_ascent = min(dim.asc, fm.maxAscent());
-       mrow.caret_descent = min(dim.des, fm.maxDescent());
+       mrow.caret_dim.asc = min(dim.asc, fm.maxAscent());
+       mrow.caret_dim.des = min(dim.des, fm.maxDescent());
+       mrow.caret_dim.wid = fm.lineWidth();
+
        /// do the same for math cells linearized in the row
-       MathRow caret_row = MathRow(mrow.caret_ascent, mrow.caret_descent);
+       MathRow caret_row = MathRow(mrow.caret_dim);
        for (auto const & e : mrow)
                if (e.type == MathRow::BEGIN && e.ar)
                        bv->setMathRow(e.ar, caret_row);
@@ -966,6 +969,17 @@ MathClass MathData::mathClass() const
 }
 
 
+MathClass MathData::firstMathClass() const
+{
+       for (MathAtom const & at : *this) {
+               MathClass mc = at->mathClass();
+               if (mc != MC_UNKNOWN)
+                       return mc;
+       }
+       return MC_ORD;
+}
+
+
 MathClass MathData::lastMathClass() const
 {
        MathClass res = MC_ORD;