}
+bool BufferView::checkDepm(LCursor & cur, LCursor & old)
+{
+ // Would be wrong to delete anything if we have a selection.
+ if (cur.selection())
+ return false;
+
+ bool need_anchor_change = false;
+ bool changed = cursor_.text()->deleteEmptyParagraphMechanism(cur, old,
+ need_anchor_change);
+
+ if (need_anchor_change)
+ cur.resetAnchor();
+
+ if (!changed)
+ return false;
+
+ updateMetrics(false);
+ buffer_->changed();
+ return true;
+}
+
+
bool BufferView::mouseSetCursor(LCursor & cur)
{
BOOST_ASSERT(&cur.bv() == this);
// FIXME: move this to InsetText::notifyCursorLeaves?
bool update = false;
if (!badcursor && cursor_.inTexted())
- update = cursor_.text()->deleteEmptyParagraphMechanism(cur, cursor_);
+ checkDepm(cur, cursor_);
cursor_ = cur;
cursor_.clearSelection();
class BufferParams;
class BufferView;
class CursorSlice;
+class DocIterator;
class ErrorList;
-class InsetBase;
-class InsetBase_code;
class FuncRequest;
class FuncStatus;
+class InsetBase;
class LColor_color;
class LCursor;
class LyXTextClass;
bool boundary) const;
/// delete double space or empty paragraphs around old cursor
- /// FIXME: replace LCursor with DocIterator.
- bool deleteEmptyParagraphMechanism(LCursor & cur, LCursor & old);
+ /// FIXME: replace LCursor with DocIterator. This is not possible right
+ /// now because recordUndo() is called which needs a LCursor.
+ bool deleteEmptyParagraphMechanism(LCursor & cur,
+ LCursor & old, bool & need_anchor_change);
/// sets row.end to the pos value *after* which a row should break.
/// for example, the pos after which isNewLine(pos) == true
{
LCursor old = cur;
setCursorIntern(cur, par, pos, setfont, boundary);
- return deleteEmptyParagraphMechanism(cur, old);
+ return cur.bv().checkDepm(cur, old);
}
if (dummy == old)
++dummy.pos();
- return deleteEmptyParagraphMechanism(dummy, old);
+ cur.bv().checkDepm(dummy, old);
}
bool updateNeeded = false;
LCursor dummy = cur;
if (dummy == old)
++dummy.pos();
-
- bool const changed = deleteEmptyParagraphMechanism(dummy, old);
+
+ bool const changed = cur.bv().checkDepm(dummy, old);
// Make sure that cur gets back whatever happened to dummy(Lgb)
if (changed)
cur = dummy;
- return changed;
+ return false;
}
bool updateNeeded = false;
}
-bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur, LCursor & old)
+bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur,
+ LCursor & old, bool & need_anchor_change)
{
- // Would be wrong to delete anything if we have a selection.
- if (cur.selection())
- return false;
-
//lyxerr[Debug::DEBUG] << "DEPM: cur:\n" << cur << "old:\n" << old << endl;
// old should point to us
BOOST_ASSERT(old.text() == this);
&& oldpar.isLineSeparator(old.pos() - 1)
&& !oldpar.isDeleted(old.pos() - 1)) {
oldpar.eraseChar(old.pos() - 1, false); // do not track changes in DEPM
- TextMetrics & tm = cur.bv().textMetrics(this);
- tm.redoParagraph(old.pit());
#ifdef WITH_WARNINGS
#warning This will not work anymore when we have multiple views of the same buffer
// In this case, we will have to correct also the cursors held by
// correct all cursor parts
if (same_par) {
fixCursorAfterDelete(cur.top(), old.top());
- cur.resetAnchor();
+ need_anchor_change = true;
}
return true;
}
// their address has changed. Therefore we
// need to `regenerate' cur. (JMarc)
cur.updateInsets(&(cur.bottom().inset()));
- cur.resetAnchor();
+ need_anchor_change = true;
}
}
- // There is a crash reported by Edwin Leuven (16/04/2006) because of:
- //ParIterator par_it(old);
- //updateLabels(old.buffer(), par_it);
- // So for now we do the full update:
- updateLabels(old.buffer());
return true;
}
if (oldpar.stripLeadingSpaces())
- cur.resetAnchor();
+ need_anchor_change = true;
return false;
}