}
+int CursorData::countInsetsInSelection(InsetCode const & inset_code)
+{
+ if (!selection_)
+ return 0;
+
+ DocIterator from, to;
+ from = selectionBegin();
+ to = selectionEnd();
+
+ int count = 0;
+
+ if (!from.nextInset()) //move to closest inset
+ from.forwardInset();
+
+ while (!from.empty() && from < to) {
+ Inset * inset = from.nextInset();
+ if (!inset)
+ break;
+ if (inset->lyxCode() == inset_code)
+ count ++;
+ from.forwardInset();
+ }
+ return count;
+}
+
+
+bool CursorData::insetInSelection(InsetCode const & inset_code)
+{
+ if (!selection_)
+ return false;
+
+ DocIterator from, to;
+ from = selectionBegin();
+ to = selectionEnd();
+
+ if (!from.nextInset()) //move to closest inset
+ from.forwardInset();
+
+ while (!from.empty() && from < to) {
+ Inset * inset = from.nextInset();
+ if (!inset)
+ break;
+ if (inset->lyxCode() == inset_code)
+ return true;
+ from.forwardInset();
+ }
+ return false;
+}
+
+
bool CursorData::fixIfBroken()
{
bool const broken_cursor = DocIterator::fixIfBroken();
}
-bool CursorData::isInside(Inset const * p) const
+bool CursorData::undoAction()
{
- 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::textUndo()
-{
- if (!buffer()->undo().textUndo(*this))
+ if (!buffer()->undo().undoAction(*this))
return false;
sanitize();
return true;
}
-bool CursorData::textRedo()
+bool CursorData::redoAction()
{
- if (!buffer()->undo().textRedo(*this))
+ if (!buffer()->undo().redoAction(*this))
return false;
sanitize();
return true;
}
+void Cursor::noScreenUpdate() const
+{
+ disp_.screenUpdate(Update::None);
+}
+
+
void Cursor::forceBufferUpdate() const
{
disp_.forceBufferUpdate();
}
-void Cursor::noScreenUpdate() const
-{
- disp_.screenUpdate(Update::None);
-}
-
-
Font Cursor::getFont() const
{
// The logic here should more or less match to the