}
-void Cursor::recordUndo(UndoKind kind, pit_type from, pit_type to) const
+void Cursor::recordUndo(pit_type from, pit_type to) const
{
- buffer()->undo().recordUndo(*this, kind, from, to);
+ buffer()->undo().recordUndo(*this, from, to);
}
-void Cursor::recordUndo(UndoKind kind, pit_type from) const
+void Cursor::recordUndo(pit_type from) const
{
- buffer()->undo().recordUndo(*this, kind, from);
+ buffer()->undo().recordUndo(*this, from, pit());
}
}
-void Cursor::recordUndoInset(UndoKind kind, Inset const * inset) const
+void Cursor::recordUndoInset(Inset const * in) const
{
- buffer()->undo().recordUndoInset(*this, kind, inset);
+ if (!in || in == &inset()) {
+ CursorData c = *this;
+ c.pop_back();
+ buffer()->undo().recordUndo(c, c.pit(), c.pit());
+ } else if (in == nextInset())
+ recordUndo();
+ else
+ LYXERR0("Inset not found, no undo element added.");
}
else
recordUndo();
} else {
- buffer()->undo().recordUndo(*this, ATOMIC_UNDO,
+ buffer()->undo().recordUndo(*this,
selBegin().pit(), selEnd().pit());
}
}
void endUndoGroup() const;
/// The general case: prepare undo for an arbitrary range.
- void recordUndo(UndoKind kind, pit_type from, pit_type to) const;
+ void recordUndo(pit_type from, pit_type to) const;
/// Convenience: prepare undo for the range between 'from' and cursor.
- void recordUndo(UndoKind kind, pit_type from) const;
+ void recordUndo(pit_type from) const;
/// Convenience: prepare undo for the single paragraph or cell
/// containing the cursor
void recordUndo(UndoKind kind = ATOMIC_UNDO) const;
/// Convenience: prepare undo for the inset containing the cursor
- void recordUndoInset(UndoKind kind = ATOMIC_UNDO,
- Inset const * inset = 0) const;
+ void recordUndoInset(Inset const * inset = 0) const;
/// Convenience: prepare undo for the whole buffer
void recordUndoFullBuffer() const;
// if a bibitem is deleted, merge with previous paragraph
// if this is a bibliography item as well
if (cur.pit() > 0 && par.layout() == prevpar.layout()) {
- cur.recordUndo(ATOMIC_UNDO, prevcur.pit());
+ cur.recordUndo(prevcur.pit());
mergeParagraph(bufparams, cur.text()->paragraphs(),
prevcur.pit());
cur.forceBufferUpdate();
// is it an empty paragraph?
if (cur.lastpos() == 0
|| (cur.lastpos() == 1 && par.isSeparator(0))) {
- cur.recordUndo(ATOMIC_UNDO, prevcur.pit(), cur.pit());
+ cur.recordUndo(prevcur.pit());
plist.erase(boost::next(plist.begin(), cur.pit()));
needsUpdate = true;
}
// is previous par empty?
else if (prevcur.lastpos() == 0
|| (prevcur.lastpos() == 1 && prevpar.isSeparator(0))) {
- cur.recordUndo(ATOMIC_UNDO, prevcur.pit(), cur.pit());
+ cur.recordUndo(prevcur.pit());
plist.erase(boost::next(plist.begin(), prevcur.pit()));
needsUpdate = true;
}
else if (par.layout() == prevpar.layout()
|| tclass.isDefaultLayout(par.layout())
|| tclass.isPlainLayout(par.layout())) {
- cur.recordUndo(ATOMIC_UNDO, prevcur.pit());
+ cur.recordUndo(prevcur.pit());
mergeParagraph(bufparams, plist, prevcur.pit());
needsUpdate = true;
}
--prev_cur.pit();
if (!prev_cur.paragraph().isMergedOnEndOfParDeletion(cur.buffer()->params().track_changes)) {
- cur.recordUndo(ATOMIC_UNDO, prev_cur.pit(), prev_cur.pit());
+ cur.recordUndo(prev_cur.pit(), prev_cur.pit());
prev_cur.paragraph().setChange(prev_cur.lastpos(), Change(Change::DELETED));
setCursorIntern(cur, prev_cur.pit(), prev_cur.lastpos());
return true;
void setCursorIntern(Cursor & cur, pit_type par,
pos_type pos, bool setfont = true, bool boundary = false);
- ///
- void recUndo(Cursor & cur, pit_type first, pit_type last) const;
- ///
- void recUndo(Cursor & cur, pit_type first) const;
-
/// Move cursor one position backwards
/**
* Returns true if an update is needed after the move.
if (oldpar.empty() || (oldpar.size() == 1 && oldpar.isLineSeparator(0))) {
// Delete old par.
- old.recordUndo(ATOMIC_UNDO,
- max(old.pit() - 1, pit_type(0)),
- min(old.pit() + 1, old.lastpit()));
+ old.recordUndo(max(old.pit() - 1, pit_type(0)),
+ min(old.pit() + 1, old.lastpit()));
ParagraphList & plist = old.text()->paragraphs();
bool const soa = oldpar.params().startOfAppendix();
plist.erase(boost::next(plist.begin(), old.pit()));
}
-void Text::recUndo(Cursor & cur, pit_type first, pit_type last) const
-{
- cur.recordUndo(ATOMIC_UNDO, first, last);
-}
-
-
-void Text::recUndo(Cursor & cur, pit_type par) const
-{
- cur.recordUndo(ATOMIC_UNDO, par, par);
-}
-
} // namespace lyx
pit_type const newpit = distance(bgn, dest);
pit_type const len = distance(start, finish);
pit_type const deletepit = pit + len;
- buf.undo().recordUndo(cur, ATOMIC_UNDO, newpit, deletepit - 1);
+ buf.undo().recordUndo(cur, newpit, deletepit - 1);
pars.splice(dest, start, finish);
cur.pit() = newpit;
break;
}
// One such was found:
pit_type newpit = distance(bgn, dest);
- buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, newpit - 1);
+ buf.undo().recordUndo(cur, pit, newpit - 1);
pit_type const len = distance(start, finish);
pars.splice(dest, start, finish);
cur.pit() = newpit - len;
case OutlineIn:
case OutlineOut: {
pit_type const len = distance(start, finish);
- buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
+ buf.undo().recordUndo(cur, pit, pit + len - 1);
for (; start != finish; ++start) {
toclevel = buf.text().getTocLevel(distance(bgn, start));
if (toclevel == Layout::NOT_IN_TOC)
case LFUN_PARAGRAPH_MOVE_DOWN: {
pit_type const pit = cur.pit();
- recUndo(cur, pit, pit + 1);
+ cur.recordUndo(pit, pit + 1);
cur.finishUndo();
pars_.swap(pit, pit + 1);
needsUpdate = true;
case LFUN_PARAGRAPH_MOVE_UP: {
pit_type const pit = cur.pit();
- recUndo(cur, pit - 1, pit);
+ cur.recordUndo(pit - 1, pit);
cur.finishUndo();
pars_.swap(pit, pit - 1);
--cur.pit();
// FIXME: this don't work for multipart document!
for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
if (pars_[tmp].params().startOfAppendix()) {
- recUndo(cur, tmp);
+ cur.recordUndo(tmp, tmp);
pars_[tmp].params().startOfAppendix(false);
break;
}
Cursor & cur = const_cast<Cursor &>(bv_->cursor());
// In some cases, we do not know how to record undo
if (&cur.inset() == &text_->inset())
- cur.recordUndo(ATOMIC_UNDO, pit, pit);
+ cur.recordUndo(pit, pit);
int const moveCursor = par.fixBiblio(buffer);
}
-// FIXME: remove these convenience functions and make
-// Private::recordUndo public as sole interface. The code in the
-// convenience functions can move to Cursor.cpp.
-
void Undo::recordUndo(CursorData const & cur, UndoKind kind)
{
d->recordUndo(kind, cur, cur.pit(), cur.pit(), cur);
}
-void Undo::recordUndoInset(CursorData const & cur, UndoKind kind,
- Inset const * inset)
-{
- if (!inset || inset == &cur.inset()) {
- DocIterator c = cur;
- c.pop_back();
- d->recordUndo(kind, c, c.pit(), c.pit(), cur);
- } else if (inset == cur.nextInset())
- recordUndo(cur, kind);
- else
- LYXERR0("Inset not found, no undo stack added.");
-}
-
-
-void Undo::recordUndo(CursorData const & cur, UndoKind kind, pit_type from)
-{
- d->recordUndo(kind, cur, cur.pit(), from, cur);
-}
-
-
-void Undo::recordUndo(CursorData const & cur, UndoKind kind,
- pit_type from, pit_type to)
+void Undo::recordUndo(CursorData const & cur, pit_type from, pit_type to)
{
- d->recordUndo(kind, cur, from, to, cur);
+ d->recordUndo(ATOMIC_UNDO, cur, from, to, cur);
}
* give an inclusive range. This is called before you make the
* changes to the paragraph, and it will record the original
* information of the paragraphs in the undo stack.
+ * Kind of undo is always ATOMIC_UNDO.
*/
- void recordUndo(CursorData const & cur, UndoKind kind,
- pit_type from, pit_type to);
-
- /// Convenience: record undo information for the range between
- /// 'from' and cursor.
- void recordUndo(CursorData const & cur, UndoKind kind, pit_type from);
+ void recordUndo(CursorData const & cur, pit_type from, pit_type to);
/// Convenience: record undo information for the single
/// paragraph or cell containing the cursor.
void recordUndo(CursorData const & cur, UndoKind kind = ATOMIC_UNDO);
- /// Convenience: record undo information for the inset
- /// containing the cursor.
- void recordUndoInset(CursorData const & cur,
- UndoKind kind = ATOMIC_UNDO,
- Inset const * inset = 0);
-
/// Convenience: record undo for buffer parameters
void recordUndoBufferParams(CursorData const & cur);
cur.undispatched();
return;
}
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
name_ = cmd.getArg(1);
cur.forceBufferUpdate();
break;
cur.undispatched();
return;
}
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
if (change_type)
params_.type = cmd.getArg(1);
else // if (for_box)
InsetBranchParams params;
InsetBranch::string2params(to_utf8(cmd.argument()), params);
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
params_.branch = params.branch;
// what we really want here is a TOC update, but that means
// a full buffer update
case LFUN_INSET_MODIFY: {
if (cmd.getArg(0) == "changetype") {
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
type_ = cmd.getArg(1);
cur.forceBufferUpdate();
break;
switch (cmd.action()) {
case LFUN_INSET_MODIFY:
if (cmd.getArg(0) == "ert") {
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
setStatus(cur, string2params(to_utf8(cmd.argument())));
break;
}
case LFUN_INSET_MODIFY: {
InsetFloatParams params;
string2params(to_utf8(cmd.argument()), params);
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
// placement, wide and sideways are not used for subfloats
if (!params_.subfloat) {
case LFUN_INSET_MODIFY: {
if (cmd.getArg(0) == "changetype") {
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
params_.index = from_utf8(cmd.getArg(1));
break;
}
InsetIndexParams params;
InsetIndex::string2params(to_utf8(cmd.argument()), params);
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
params_.index = params.index;
// what we really want here is a TOC update, but that means
// a full buffer update
switch (cmd.action()) {
case LFUN_INSET_MODIFY: {
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
InsetListings::string2params(to_utf8(cmd.argument()), params());
break;
}
if (params_.type == params.type)
break;
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
string2params(to_utf8(cmd.argument()), params_);
setButtonLabel();
// what we really want here is a TOC update, but that means
switch (cmd.action()) {
case LFUN_INSET_MODIFY:
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
string2params(to_utf8(cmd.argument()), params_);
setButtonLabel();
cur.forceBufferUpdate();
{
switch (cmd.action()) {
case LFUN_INSET_MODIFY:
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
string2params(to_utf8(cmd.argument()), params_);
break;
default:
break;
}
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
getSelection(cur, sel_row_start, sel_row_end, sel_col_start, sel_col_end);
row_type const row = tabular.cellRow(cur.idx());
{
switch (cmd.action()) {
case LFUN_INSET_MODIFY: {
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
InsetWrapParams params;
InsetWrap::string2params(to_utf8(cmd.argument()), params);
params_.lines = params.lines;