#include "paragraph_funcs.h"
#include "pariterator.h"
-#include "insets/updatableinset.h"
#include "insets/insettabular.h"
#include "insets/insettext.h"
#include "mathed/math_data.h"
#include "mathed/math_inset.h"
+#include "mathed/math_scriptinset.h"
#include "mathed/math_macrotable.h"
#include "support/limited_stack.h"
for (int i = 0; ; ++i) {
int xo;
int yo;
- LCursor cur = c;
- cur.setCursor(it);
- cur.inset().getCursorPos(cur.top(), xo, yo);
+ it.inset().cursorPos(it.top(), c.boundary() && ((i+1) == it.depth()), xo, yo);
double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
// '<=' in order to take the last possible position
// this is important for clicking behind \sum in e.g. '\sum_i a'
{
BOOST_ASSERT(!cursor.empty());
CursorSlice bottom = cursor[0];
- LyXText * text = bottom.text();
- BOOST_ASSERT(text);
DocIterator it = doc_iterator_begin(bottom.inset());
DocIterator const et = doc_iterator_end(bottom.inset());
// avoid invalid nesting when selecting
if (bv_funcs::status(&cursor.bv(), it) == bv_funcs::CUR_INSIDE
&& (!cursor.selection() || positionable(it, cursor.anchor_))) {
- Point p = bv_funcs::getPos(it);
+ Point p = bv_funcs::getPos(it, false);
int xo = p.x_;
int yo = p.y_;
if (xlow <= xo && xo <= xhigh && ylow <= yo && yo <= yhigh) {
// bv functions are not yet available!
LCursor::LCursor(BufferView & bv)
: DocIterator(), bv_(&bv), anchor_(), x_target_(-1),
- selection_(false), mark_(false)
+ selection_(false), mark_(false), logicalpos_(false)
{}
void LCursor::getPos(int & x, int & y) const
{
- Point p = bv_funcs::getPos(*this);
+ Point p = bv_funcs::getPos(*this, boundary());
x = p.x_;
y = p.y_;
}
void LCursor::setSelection()
{
selection() = true;
- // a selection with no contents is not a selection
+ // A selection with no contents is not a selection
#ifdef WITH_WARNINGS
#warning doesnt look ok
#endif
selection() = true;
anchor_ = where;
pos() += n;
+ // Open all collapsed insets
+ for (int i = depth() - 1; i >= 0; --i)
+ operator[](i).inset().setStatus(*this, InsetBase::Open);
}
bool LCursor::isInside(InsetBase const * p)
{
- for (unsigned i = 0; i < depth(); ++i)
+ for (size_t i = 0; i != depth(); ++i)
if (&operator[](i).inset() == p)
return true;
return false;
}
+void LCursor::leaveInset(InsetBase const & inset)
+{
+ for (size_t i = 0; i != depth(); ++i) {
+ if (&operator[](i).inset() == &inset) {
+ resize(i);
+ return;
+ }
+ }
+}
+
+
bool LCursor::openable(MathAtom const & t) const
{
if (!t->isActive())
MathScriptInset const * p = prevAtom()->asScriptInset();
if (p && p->has(up)) {
--pos();
- push(inset());
- idx() = up; // the superscript has index 1
+ push(*const_cast<MathScriptInset*>(p));
+ idx() = p->idxOfScript(up);
pos() = lastpos();
- //lyxerr << "updown: handled by scriptinset to the left" << endl;
return true;
}
}
if (pos() != lastpos()) {
MathScriptInset const * p = nextAtom()->asScriptInset();
if (p && p->has(up)) {
- push(inset());
- idx() = up;
+ push(*const_cast<MathScriptInset*>(p));
+ idx() = p->idxOfScript(up);
pos() = 0;
- //lyxerr << "updown: handled by scriptinset to the right" << endl;
return true;
}
}
<< ". Trying to correct this." << endl;
newdepth = copy.depth() - 1;
}
- copy.pop();
+ copy.pop();
}
// shrink cursor to a size where everything is valid, possibly
// leaving insets