]> git.lyx.org Git - lyx.git/blobdiff - src/CursorSlice.cpp
* src/frontends/qt4/qlkey.h: add AltGr as modifier key (fix bug 4026)
[lyx.git] / src / CursorSlice.cpp
index 09a9ca86e3bcbed78018c1e874e2b3b8ba84be56..47b518cbfd2e72c3eaf0ff2953f33ca1d31ca8d3 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"
 
 #include <boost/assert.hpp>
 
+using std::endl;
 
-namespace lyx {
 
-using std::endl;
+namespace lyx {
 
 
 CursorSlice::CursorSlice()
@@ -34,7 +37,7 @@ CursorSlice::CursorSlice()
 {}
 
 
-CursorSlice::CursorSlice(InsetBase & p)
+CursorSlice::CursorSlice(Inset & p)
        : inset_(&p), idx_(0), pit_(0), pos_(0)
 {
        BOOST_ASSERT(inset_);
@@ -66,6 +69,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 +93,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 +102,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();