]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_fracbase.C
Fix to bug 2362: Deleting superscript also deletes subscript.
[lyx.git] / src / mathed / math_fracbase.C
index 0cb0086bb2fb93e0403091b9df4853d6a0062a7b..f55f7fe8d402f212a06fe5c3b0b664607ea7b744 100644 (file)
@@ -1,8 +1,18 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
+/**
+ * \file math_fracbase.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
 
 #include "math_fracbase.h"
+#include "math_data.h"
+#include "cursor.h"
 
 
 MathFracbaseInset::MathFracbaseInset()
@@ -10,37 +20,24 @@ MathFracbaseInset::MathFracbaseInset()
 {}
 
 
-bool MathFracbaseInset::idxRight(MathInset::idx_type &,
-                                MathInset::pos_type &) const
+bool MathFracbaseInset::idxRight(LCursor &) const
 {
        return false;
 }
 
 
-bool MathFracbaseInset::idxLeft(MathInset::idx_type &,
-                               MathInset::pos_type &) const
+bool MathFracbaseInset::idxLeft(LCursor &) const
 {
        return false;
 }
 
 
-bool MathFracbaseInset::idxUp(MathInset::idx_type & idx,
-                             MathInset::pos_type & pos) const
+bool MathFracbaseInset::idxUpDown(LCursor & cur, bool up) const
 {
-       if (idx == 0)
+       MathInset::idx_type target = !up; // up ? 0 : 1, since upper cell has idx 0
+       if (cur.idx() == target)
                return false;
-       idx = 0;
-       pos = std::min(pos, cell(idx).size());
-       return true;
-}
-
-
-bool MathFracbaseInset::idxDown(MathInset::idx_type & idx,
-                               MathInset::pos_type & pos) const
-{
-       if (idx == 1)
-               return false;
-       idx = 1;
-       pos = std::min(pos, cell(idx).size());
+       cur.idx() = target;
+       cur.pos() = cell(target).x2pos(cur.x_target());
        return true;
 }