]> git.lyx.org Git - lyx.git/blobdiff - src/CursorSlice.cpp
Account for old versions of Pygments
[lyx.git] / src / CursorSlice.cpp
index e7ef90e8f37c3040e32aead6e0e595344f7a1d84..573ca9d4fe71b653bd2b3e1e02401c11171891b8 100644 (file)
@@ -80,19 +80,37 @@ pit_type CursorSlice::lastpit() const
 
 CursorSlice::row_type CursorSlice::row() const
 {
-       // LASSERT: This should only ever be called from an InsetMath.
-       // Should we crash in release mode, though, or try to continue?
-       LASSERT(asInsetMath(), /**/);
-       return asInsetMath()->row(idx_);
+       LASSERT(inset_, return 0);
+       return inset_->row(idx_);
 }
 
 
 CursorSlice::col_type CursorSlice::col() const
 {
-       // LASSERT: This should only ever be called from an InsetMath.
-       // Should we crash in release mode, though, or try to continue?
-       LASSERT(asInsetMath(), /**/);
-       return asInsetMath()->col(idx_);
+       LASSERT(inset_, return 0);
+       return inset_->col(idx_);
+}
+
+
+void CursorSlice::setPitPos(pit_type pit, pos_type pos)
+{
+       LASSERT(pit != int(text()->paragraphs().size()), return);
+       pit_ = pit;
+       pos_ = pos;
+
+       // Now some strict checking. None of these should happen, but
+       // we're scaredy-cats
+       if (pos < 0) {
+               LYXERR0("Don't like -1!");
+               LATTEST(false);
+       }
+
+       if (pos > paragraph().size()) {
+               LYXERR0("Don't like 1, pos: " << pos
+                               << " size: " << paragraph().size()
+                      << " par: " << pit);
+               LATTEST(false);
+       }
 }