X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCursorSlice.cpp;h=47b518cbfd2e72c3eaf0ff2953f33ca1d31ca8d3;hb=52e5755c84ceb65d935764da467c7b948672e77e;hp=09a9ca86e3bcbed78018c1e874e2b3b8ba84be56;hpb=76dec26fec47df5b828973554b85dc91f3b564d1;p=lyx.git diff --git a/src/CursorSlice.cpp b/src/CursorSlice.cpp index 09a9ca86e3..47b518cbfd 100644 --- a/src/CursorSlice.cpp +++ b/src/CursorSlice.cpp @@ -14,19 +14,22 @@ #include #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 +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();