]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_scriptinset.C
bug + spped fixes + small stuff
[lyx.git] / src / mathed / math_scriptinset.C
index 5b6c4a2e7f72f478006edcf370cf0112c33866b8..6e6f75514109c6cfb71e642ab773f3c46b4f61aa 100644 (file)
 #include "math_support.h"
 #include "math_symbolinset.h"
 #include "dispatchresult.h"
+#include "cursor.h"
 #include "debug.h"
 #include "funcrequest.h"
 
 #include <boost/assert.hpp>
 
-
 using std::string;
 using std::max;
 using std::auto_ptr;
 using std::endl;
 
 
+
 MathScriptInset::MathScriptInset()
        : MathNestInset(3), limits_(0)
 {
@@ -72,18 +73,16 @@ MathScriptInset * MathScriptInset::asScriptInset()
 }
 
 
-bool MathScriptInset::idxFirst(BufferView & bv) const
+bool MathScriptInset::idxFirst(LCursor & cur) const
 {
-       CursorSlice & cur = cursorTip(bv);
        cur.idx() = 2;
        cur.pos() = 0;
        return true;
 }
 
 
-bool MathScriptInset::idxLast(BufferView & bv) const
+bool MathScriptInset::idxLast(LCursor & cur) const
 {
-       CursorSlice & cur = cursorTip(bv);
        cur.idx() = 2;
        cur.pos() = nuc().size();
        return true;
@@ -205,24 +204,24 @@ void MathScriptInset::metrics(MetricsInfo & mi, Dimension & dim) const
        ScriptChanger dummy(mi.base);
        cell(0).metrics(mi);
        cell(1).metrics(mi);
-       dim_.wid = 0;
+       dim.wid = 0;
        if (hasLimits()) {
-               dim_.wid = nwid();
+               dim.wid = nwid();
                if (hasUp())
-                       dim_.wid = max(dim_.wid, up().width());
+                       dim.wid = max(dim.wid, up().width());
                if (hasDown())
-                       dim_.wid = max(dim_.wid, down().width());
+                       dim.wid = max(dim.wid, down().width());
        } else {
                if (hasUp())
-                       dim_.wid = max(dim_.wid, up().width());
+                       dim.wid = max(dim.wid, up().width());
                if (hasDown())
-                       dim_.wid = max(dim_.wid, down().width());
-               dim_.wid += nwid();
+                       dim.wid = max(dim.wid, down().width());
+               dim.wid += nwid();
        }
-       dim_.asc = dy1() + (hasUp() ? up().ascent() : 0);
-       dim_.des = dy0() + (hasDown() ? down().descent() : 0);
-       metricsMarkers();
-       dim = dim_;
+       dim.asc = dy1() + (hasUp() ? up().ascent() : 0);
+       dim.des = dy0() + (hasDown() ? down().descent() : 0);
+       metricsMarkers(dim);
+       dim_ = dim;
 }
 
 
@@ -232,7 +231,7 @@ void MathScriptInset::draw(PainterInfo & pi, int x, int y) const
                nuc().draw(pi, x + dxx(), y);
        else {
                nuc().setXY(x + dxx(), y);
-               if (editing())
+               if (editing(pi.base.bv))
                        drawStr(pi, pi.base.font, x + dxx(), y, ".");
        }
        ScriptChanger dummy(pi.base);
@@ -315,21 +314,20 @@ bool MathScriptInset::hasDown() const
 }
 
 
-bool MathScriptInset::idxRight(BufferView &) const
+bool MathScriptInset::idxRight(LCursor &) const
 {
        return false;
 }
 
 
-bool MathScriptInset::idxLeft(BufferView &) const
+bool MathScriptInset::idxLeft(LCursor &) const
 {
        return false;
 }
 
 
-bool MathScriptInset::idxUpDown(BufferView & bv, bool up, int) const
+bool MathScriptInset::idxUpDown(LCursor & cur, bool up) const
 {
-       CursorSlice & cur = cursorTip(bv);
        if (cur.idx() == 1) {
                // if we are 'up' we can't go further up
                if (up)
@@ -446,13 +444,14 @@ void MathScriptInset::mathematica(MathematicaStream & os) const
        if (u)
                os << "^(" << up() << ')';
 
-       if (nuc().size())
+       if (nuc().size()) {
                if (d)
                        os << ',' << down() << ']';
+       }
 }
 
 
-void MathScriptInset::mathmlize( MathMLStream & os) const
+void MathScriptInset::mathmlize(MathMLStream & os) const
 {
        bool d = hasDown() && down().size();
        bool u = hasUp() && up().size();
@@ -515,8 +514,10 @@ void MathScriptInset::notifyCursorLeaves(idx_type idx)
 
 
 DispatchResult
-MathScriptInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
+MathScriptInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
+       lyxerr << "MathScriptInset: request: " << cmd << std::endl;
+
        if (cmd.action == LFUN_MATH_LIMITS) {
                if (!cmd.argument.empty()) {
                        if (cmd.argument == "limits")
@@ -532,5 +533,5 @@ MathScriptInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
                return DispatchResult(true, true);
        }
 
-       return MathNestInset::priv_dispatch(bv, cmd);
+       return MathNestInset::priv_dispatch(cur, cmd);
 }