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).
This commit is contained in:
Enrico Forestieri 2018-11-12 19:05:09 +01:00
parent 636bb6c2d9
commit 1bdba953a5
6 changed files with 69 additions and 0 deletions

View 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);

View 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;

View 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

View 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;

View 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);

View 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;