Move leaveInset and isInside from CursorData to DocIterator

They only touch the slices of the main DocIterator.
This commit is contained in:
Jean-Marc Lasgouttes 2018-08-26 16:59:35 +02:00
parent 86398b5d91
commit 4727e2becf
4 changed files with 24 additions and 24 deletions

View File

@ -571,26 +571,6 @@ void CursorData::sanitize()
}
bool CursorData::isInside(Inset const * p) const
{
for (size_t i = 0; i != depth(); ++i)
if (&operator[](i).inset() == p)
return true;
return false;
}
void CursorData::leaveInset(Inset const & inset)
{
for (size_t i = 0; i != depth(); ++i) {
if (&operator[](i).inset() == &inset) {
resize(i);
return;
}
}
}
bool CursorData::undoAction()
{
if (!buffer()->undo().undoAction(*this))

View File

@ -171,10 +171,6 @@ public:
/// Repopulate the slices insets from bottom to top. Useful
/// for stable iterators or Undo data.
void sanitize();
///
bool isInside(Inset const *) const;
/// make sure we are outside of given inset
void leaveInset(Inset const & inset);
///
bool undoAction();

View File

@ -656,6 +656,26 @@ void DocIterator::sanitize()
}
bool DocIterator::isInside(Inset const * p) const
{
for (CursorSlice const & sl : slices_)
if (&sl.inset() == p)
return true;
return false;
}
void DocIterator::leaveInset(Inset const & inset)
{
for (size_t i = 0; i != slices_.size(); ++i) {
if (&slices_[i].inset() == &inset) {
resize(i);
return;
}
}
}
int DocIterator::find(MathData const & cell) const
{
for (size_t l = 0; l != slices_.size(); ++l) {

View File

@ -249,6 +249,10 @@ public:
/// Repopulate the slices insets from bottom to top. Useful
/// for stable iterators or Undo data.
void sanitize();
///
bool isInside(Inset const *) const;
/// make sure we are outside of given inset
void leaveInset(Inset const & inset);
/// find index of CursorSlice with &cell() == &cell (or -1 if not found)
int find(MathData const & cell) const;