From 8ca5f50bf787a69c58a13cd96038c122f90c857a Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Mon, 12 Nov 2018 19:05:09 +0100 Subject: [PATCH] Fix cursor left/right navigation in overset, underset, and stackrel 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 | 18 ++++++++++++++++++ src/mathed/InsetMathOverset.h | 4 ++++ src/mathed/InsetMathStackrel.cpp | 20 ++++++++++++++++++++ src/mathed/InsetMathStackrel.h | 4 ++++ src/mathed/InsetMathUnderset.cpp | 19 +++++++++++++++++++ src/mathed/InsetMathUnderset.h | 4 ++++ 6 files changed, 69 insertions(+) diff --git a/src/mathed/InsetMathOverset.cpp b/src/mathed/InsetMathOverset.cpp index 9d835f0d9e..3d36218d63 100644 --- a/src/mathed/InsetMathOverset.cpp +++ b/src/mathed/InsetMathOverset.cpp @@ -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); diff --git a/src/mathed/InsetMathOverset.h b/src/mathed/InsetMathOverset.h index eb6b86b798..213c96f5b3 100644 --- a/src/mathed/InsetMathOverset.h +++ b/src/mathed/InsetMathOverset.h @@ -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; diff --git a/src/mathed/InsetMathStackrel.cpp b/src/mathed/InsetMathStackrel.cpp index 9a9c66f24c..430d8f1ad2 100644 --- a/src/mathed/InsetMathStackrel.cpp +++ b/src/mathed/InsetMathStackrel.cpp @@ -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 diff --git a/src/mathed/InsetMathStackrel.h b/src/mathed/InsetMathStackrel.h index d6ac815182..5740fb922b 100644 --- a/src/mathed/InsetMathStackrel.h +++ b/src/mathed/InsetMathStackrel.h @@ -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; diff --git a/src/mathed/InsetMathUnderset.cpp b/src/mathed/InsetMathUnderset.cpp index 794427e2c2..832631dfa3 100644 --- a/src/mathed/InsetMathUnderset.cpp +++ b/src/mathed/InsetMathUnderset.cpp @@ -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); diff --git a/src/mathed/InsetMathUnderset.h b/src/mathed/InsetMathUnderset.h index fbc3e779de..50143ae4d5 100644 --- a/src/mathed/InsetMathUnderset.h +++ b/src/mathed/InsetMathUnderset.h @@ -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; -- 2.39.5