]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_scriptinset.C
fix #1073
[lyx.git] / src / mathed / math_scriptinset.C
index 61bfd9fe01da7eeda8f383a4b513a8ccddbaf247..c118f4be3c59bda1e7979cf7b28012a40811c16f 100644 (file)
@@ -1,6 +1,3 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include "math_scriptinset.h"
 #include "math_support.h"
@@ -183,10 +180,10 @@ int MathScriptInset::ndes() const
 }
 
 
-void MathScriptInset::metrics(MathMetricsInfo & mi) const
+void MathScriptInset::metrics(MetricsInfo & mi) const
 {
        cell(2).metrics(mi);
-       MathScriptChanger dummy(mi.base);
+       ScriptChanger dummy(mi.base);
        cell(0).metrics(mi);
        cell(1).metrics(mi);
        dim_.w = 0;
@@ -209,7 +206,7 @@ void MathScriptInset::metrics(MathMetricsInfo & mi) const
 }
 
 
-void MathScriptInset::draw(MathPainterInfo & pi, int x, int y) const
+void MathScriptInset::draw(PainterInfo & pi, int x, int y) const
 {
        if (nuc().size())
                nuc().draw(pi, x + dxx(), y);
@@ -218,7 +215,7 @@ void MathScriptInset::draw(MathPainterInfo & pi, int x, int y) const
                if (editing())
                        drawStr(pi, pi.base.font, x + dxx(), y, ".");
        }
-       MathScriptChanger dummy(pi.base);
+       ScriptChanger dummy(pi.base);
        if (hasUp())
                up().draw(pi, x + dx1(), y - dy1());
        if (hasDown())
@@ -319,7 +316,7 @@ bool MathScriptInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
                        return false;
                // otherwise go to last base position
                idx = 2;
-               pos = cell(2).size();   
+               pos = cell(2).size();
        }
 
        else if (idx == 0) {
@@ -327,20 +324,22 @@ bool MathScriptInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
                if (!up)
                        return false;
                idx = 2;
-               pos = cell(2).size();   
+               pos = cell(2).size();
        }
-       
+
        else {
                // in nucleus
-               // don't go up/down unless in last position
-               if (pos != cell(2).size())
-                       return false;   
                // don't go up/down if there is no cell.
                if (!has(up))
                        return false;
-               // otherwise move into the first position
-               idx = up;
-               pos = 0;
+               // go up/down only if in the last position
+               // or in the first position of something with displayed limits
+               if (pos == cell(2).size() || (pos == 0 && hasLimits())) {
+                       idx = up;
+                       pos = 0;
+                       return true;
+               }
+               return false;
        }
        return true;
 }
@@ -400,7 +399,7 @@ void MathScriptInset::normalize(NormalStream & os) const
 }
 
 
-void MathScriptInset::maplize(MapleStream & os) const
+void MathScriptInset::maple(MapleStream & os) const
 {
        if (nuc().size())
                os << nuc();
@@ -411,24 +410,24 @@ void MathScriptInset::maplize(MapleStream & os) const
 }
 
 
-void MathScriptInset::mathematicize(MathematicaStream & os) const
+void MathScriptInset::mathematica(MathematicaStream & os) const
 {
        bool d = hasDown() && down().size();
        bool u = hasUp() && up().size();
 
        if (nuc().size()) {
-               if (d) 
+               if (d)
                        os << "Subscript[" << nuc();
                else
                        os << nuc();
        }
 
        if (u)
-               os << "^(" << up() << ")";
+               os << "^(" << up() << ')';
 
        if (nuc().size())
                if (d)
-                       os << "," << down() << "]"; 
+                       os << ',' << down() << ']';
 }
 
 
@@ -458,7 +457,7 @@ void MathScriptInset::mathmlize( MathMLStream & os) const
 }
 
 
-void MathScriptInset::octavize(OctaveStream & os) const
+void MathScriptInset::octave(OctaveStream & os) const
 {
        if (nuc().size())
                os << nuc();
@@ -472,6 +471,11 @@ void MathScriptInset::octavize(OctaveStream & os) const
 void MathScriptInset::infoize(std::ostream & os) const
 {
        os << "Scripts";
+}
+
+
+void MathScriptInset::infoize2(std::ostream & os) const
+{
        if (limits_)
                os << (limits_ == 1 ? ", Displayed limits" : ", Inlined limits");
 }
@@ -489,7 +493,7 @@ void MathScriptInset::notifyCursorLeaves(idx_type idx)
 }
 
 
-MathInset::result_type MathScriptInset::dispatch
+dispatch_result MathScriptInset::dispatch
        (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
 {
        if (cmd.action == LFUN_MATH_LIMITS) {