]> git.lyx.org Git - lyx.git/commitdiff
Fix cursor left/right navigation in overset, underset, and stackrel
authorEnrico Forestieri <forenr@lyx.org>
Mon, 12 Nov 2018 18:05:09 +0000 (19:05 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Mon, 12 Nov 2018 18:05:09 +0000 (19:05 +0100)
Before this commit, navigating with the cursor was visiting either
the nucleus or the script depending on the direction (left or right)
of the cursor movement. Now the 2.3.x behavior of always going through
the nucleus is restored (at least for overset and underset, as stackrel
seems to behave oddly also in 2.3.x).

src/mathed/InsetMathOverset.cpp
src/mathed/InsetMathOverset.h
src/mathed/InsetMathStackrel.cpp
src/mathed/InsetMathStackrel.h
src/mathed/InsetMathUnderset.cpp
src/mathed/InsetMathUnderset.h

index 9d835f0d9e3d60c8f0e190e08f1515dd0904abf8..3d36218d631eeabe09c99ea380aef70e4a5f4a35 100644 (file)
@@ -70,6 +70,24 @@ bool InsetMathOverset::idxUpDown(Cursor & cur, bool up) const
 }
 
 
+bool InsetMathOverset::idxFirst(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = 0;
+       return true;
+}
+
+
+bool InsetMathOverset::idxLast(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = cur.lastpos();
+       return true;
+}
+
+
 void InsetMathOverset::write(WriteStream & os) const
 {
        MathEnsurer ensurer(os);
index eb6b86b7988f34fcb49b8c45eacca467497ae8e7..213c96f5b3ef90915c8b7f9d19ed23749dd1811a 100644 (file)
@@ -30,6 +30,10 @@ public:
        ///
        bool idxUpDown(Cursor & cur, bool up) const;
        ///
+       bool idxFirst(Cursor &) const;
+       ///
+       bool idxLast(Cursor &) const;
+       ///
        void write(WriteStream & os) const;
        ///
        void normalize(NormalStream &) const;
index 9a9c66f24c3671009f213dd9888268c329bde9f1..430d8f1ad2e68923de318f130e7a5ce095017949 100644 (file)
@@ -19,6 +19,8 @@
 #include "LaTeXFeatures.h"
 #include "MetricsInfo.h"
 
+#include "support/lassert.h"
+
 using namespace std;
 
 namespace lyx {
@@ -54,6 +56,24 @@ bool InsetMathStackrel::idxUpDown(Cursor & cur, bool up) const
 }
 
 
+bool InsetMathStackrel::idxFirst(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = 0;
+       return true;
+}
+
+
+bool InsetMathStackrel::idxLast(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = cur.lastpos();
+       return true;
+}
+
+
 MathClass InsetMathStackrel::mathClass() const
 {
        // FIXME: update this when/if \stackbin is supported
index d6ac81518231201cc2608ea2c681b63d82e1f0d0..5740fb922b04136ad171e47fa728c7e365908388 100644 (file)
@@ -24,6 +24,10 @@ public:
        ///
        bool idxUpDown(Cursor &, bool up) const;
        ///
+       bool idxFirst(Cursor &) const;
+       ///
+       bool idxLast(Cursor &) const;
+       ///
        MathClass mathClass() const;
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
index 794427e2c2d7f9d312220bd4e3836246a38907f5..832631dfa3a8cdeb69f3c940428b80dd93398397 100644 (file)
@@ -19,6 +19,7 @@
 #include "LaTeXFeatures.h"
 #include "MetricsInfo.h"
 
+#include "support/lassert.h"
 
 using namespace std;
 
@@ -58,6 +59,24 @@ void InsetMathUnderset::draw(PainterInfo & pi, int x, int y) const
 }
 
 
+bool InsetMathUnderset::idxFirst(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = 0;
+       return true;
+}
+
+
+bool InsetMathUnderset::idxLast(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = cur.lastpos();
+       return true;
+}
+
+
 void InsetMathUnderset::write(WriteStream & os) const
 {
        MathEnsurer ensurer(os);
index fbc3e779deaf6f1553bb9bbecb8da628270fa44c..50143ae4d54446677e020af950f2df991fb78f43 100644 (file)
@@ -28,6 +28,10 @@ public:
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
+       bool idxFirst(Cursor &) const;
+       ///
+       bool idxLast(Cursor &) const;
+       ///
        void write(WriteStream & ws) const;
        ///
        void normalize(NormalStream & ns) const;