]> git.lyx.org Git - lyx.git/blobdiff - src/cursor.C
make boundary property an iterator property instead of a CursorSlice property
[lyx.git] / src / cursor.C
index f0fb6577c928862d079112b58bd26220424de418..e72426f64753af016508c789645b98736ca49466 100644 (file)
@@ -97,9 +97,7 @@ namespace {
                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(), 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'
@@ -134,7 +132,7 @@ namespace {
                        // 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) {
@@ -167,7 +165,7 @@ namespace {
 // 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)
 {}
 
 
@@ -309,7 +307,7 @@ int LCursor::currentMode()
 
 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_;
 }
@@ -393,7 +391,7 @@ DocIterator LCursor::selectionEnd() const
 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
@@ -408,6 +406,9 @@ void LCursor::setSelection(DocIterator const & where, size_t n)
        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);
 }
 
 
@@ -507,7 +508,7 @@ std::ostream & operator<<(std::ostream & os, LCursor const & cur)
 
 bool LCursor::isInside(InsetBase const * p)
 {
-       for (size_t i = 0; i < depth(); ++i)
+       for (size_t i = 0; i != depth(); ++i)
                if (&operator[](i).inset() == p)
                        return true;
        return false;
@@ -1187,4 +1188,3 @@ void LCursor::fixIfBroken()
                lyxerr << "correcting cursor to level " << depth() << endl;
        }
 }
-