]> git.lyx.org Git - lyx.git/blobdiff - src/CursorSlice.cpp
* Only enter inset which return true on isActive(). This is the behavior in the curso...
[lyx.git] / src / CursorSlice.cpp
index 09a9ca86e3bcbed78018c1e874e2b3b8ba84be56..710f65c80419c0e2623700c66b8ce7c0feebb961 100644 (file)
 #include <config.h>
 
 #include "CursorSlice.h"
+
 #include "debug.h"
-#include "LyXText.h"
+#include "Text.h"
 #include "Paragraph.h"
 
+#include "insets/Inset.h"
+
 #include "mathed/InsetMath.h"
 #include "mathed/MathData.h"
 
@@ -34,13 +37,25 @@ CursorSlice::CursorSlice()
 {}
 
 
-CursorSlice::CursorSlice(InsetBase & p)
+CursorSlice::CursorSlice(Inset & p)
        : inset_(&p), idx_(0), pit_(0), pos_(0)
 {
        BOOST_ASSERT(inset_);
 }
 
 
+void CursorSlice::invalidate()
+{
+       inset_ = 0;
+}
+
+
+bool CursorSlice::isValid() const
+{
+       return inset_ != 0;
+}
+
+
 MathData & CursorSlice::cell() const
 {
        return inset_->asInsetMath()->cell(idx_);
@@ -66,6 +81,14 @@ pos_type CursorSlice::lastpos() const
 }
 
 
+pit_type CursorSlice::lastpit() const
+{
+       if (inset().inMathed())
+               return 0;
+       return text()->paragraphs().size() - 1;
+}
+
+
 CursorSlice::row_type CursorSlice::row() const
 {
        BOOST_ASSERT(asInsetMath());
@@ -82,7 +105,7 @@ CursorSlice::col_type CursorSlice::col() const
 
 bool operator==(CursorSlice const & p, CursorSlice const & q)
 {
-       return p.inset_ == q.inset_
+       return &p.inset() == &q.inset()
               && p.idx() == q.idx()
               && p.pit() == q.pit()
               && p.pos() == q.pos();
@@ -91,7 +114,7 @@ bool operator==(CursorSlice const & p, CursorSlice const & q)
 
 bool operator!=(CursorSlice const & p, CursorSlice const & q)
 {
-       return p.inset_ != q.inset_
+       return &p.inset() != &q.inset()
               || p.idx() != q.idx()
               || p.pit() != q.pit()
               || p.pos() != q.pos();