lyx_mirror/src/mathed/InsetMathStackrel.h
Jean-Marc Lasgouttes 503c7c1688 When inserting math inset, put cursor selection in the correct cell
The original use case for this bug is entering an overset inset when
there is a selection. The expected result was to have the selection
pasted in main text, but the result was to have it in the cell.

Insets already have idxFirst() that is able to set cursor to the
"entry" cell of an inset. This patch introduces firstIdx(), which is
the index of this cell and uses it in idxFirst() (idem for
lastIdx/idxLast).

As a consequence, several instances of idxFirst/idxLast can be removed.

Now for the real fix: the two places where the cell in which selection
is inserted seem to be:
* Cursor::macroModeClose
* Cursor::handleNest

These two methods are changed to insert material in the entry cell
instead of cell 0.

idxFirst/Last methods are added to InsetMathRoot and InsetMathStackrel
so that the natural entry point is the nucleus of those insets.

Finallly, a typo is fixed in InsetMathNest::edit() where enter_front
computation was incorrect.
2018-04-05 11:22:02 +02:00

55 lines
1.1 KiB
C++

// -*- C++ -*-
/**
* \file InsetMathStackrel.h
* 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.
*/
#ifndef MATH_STACKRELINSET_H
#define MATH_STACKRELINSET_H
#include "InsetMathFrac.h"
namespace lyx {
class InsetMathStackrel : public InsetMathFracBase {
public:
///
InsetMathStackrel(Buffer * buf, bool sub);
///
bool idxUpDown(Cursor &, bool up) const;
///
MathClass mathClass() const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///
idx_type firstIdx() const { return 1; }
///
idx_type lastIdx() const { return 1; }
///
void write(WriteStream & os) const;
///
void normalize(NormalStream &) const;
///
void mathmlize(MathStream &) const;
///
void htmlize(HtmlStream &) const;
///
void validate(LaTeXFeatures &) const;
///
InsetCode lyxCode() const { return MATH_STACKREL_CODE; }
private:
virtual Inset * clone() const;
};
} // namespace lyx
#endif