* Licence details can be found in the file COPYING.
*
* \author Asger Alstrup
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
* \author John Levon
- * \author André Pönitz
- * \author Jürgen Vigna
+ * \author André Pönitz
+ * \author Jürgen Vigna
* \author Abdelrazak Younes
*
* Full author contact details are available in file CREDITS.
StableDocIterator const & cel,
pit_type fro, pit_type en, ParagraphList * pl,
MathData * ar, BufferParams const & bp,
- bool ifb, size_t gid) :
+ bool ifb, bool lc, size_t gid) :
kind(kin), cursor(cur), cell(cel), from(fro), end(en),
- pars(pl), array(ar), bparams(0), isFullBuffer(ifb), group_id(gid)
+ pars(pl), array(ar), bparams(0), isFullBuffer(ifb), lyx_clean(lc), group_id(gid)
{
if (isFullBuffer)
bparams = new BufferParams(bp);
bparams = ue.isFullBuffer
? new BufferParams(*ue.bparams) : ue.bparams;
isFullBuffer = ue.isFullBuffer;
+ lyx_clean = ue.lyx_clean;
group_id = ue.group_id;
}
///
BufferParams const * bparams;
/// Only used in case of full backups
bool isFullBuffer;
+ /// Was the buffer clean at this point?
+ bool lyx_clean;
/// the element's group id
size_t group_id;
private:
}
}
+ /// Mark all the elements of the stack as dirty
+ void markDirty() {
+ for (size_t i = 0; i != c_.size(); ++i)
+ c_[i].lyx_clean = false;
+ }
+
private:
/// Internal contents.
std::deque<UndoElement> c_;
}
-static bool samePar(StableDocIterator const & i1, StableDocIterator const & i2)
+void Undo::markDirty()
{
- StableDocIterator tmpi2 = i2;
- tmpi2.pos() = i1.pos();
- return i1 == tmpi2;
+ d->undo_finished_ = true;
+ d->undostack_.markDirty();
+ d->redostack_.markDirty();
}
//
///////////////////////////////////////////////////////////////////////
+static bool samePar(StableDocIterator const & i1, StableDocIterator const & i2)
+{
+ StableDocIterator tmpi2 = i2;
+ tmpi2.pos() = i1.pos();
+ return i1 == tmpi2;
+}
+
+
void Undo::Private::doRecordUndo(UndoKind kind,
DocIterator const & cell,
pit_type first_pit, pit_type last_pit,
&& stack.top().end == end)
return;
- LYXERR(Debug::UNDO, "Create undo element of group " << group_id);
+ if (isFullBuffer)
+ LYXERR(Debug::UNDO, "Create full buffer undo element of group " << group_id);
+ else
+ LYXERR(Debug::UNDO, "Create undo element of group " << group_id);
// create the position information of the Undo entry
UndoElement undo(kind, cur, cell, from, end, 0, 0,
- buffer_.params(), isFullBuffer, group_id);
+ buffer_.params(), isFullBuffer, buffer_.isClean(), group_id);
// fill in the real data to be saved
if (cell.inMathed()) {
// simply use the whole cell
- undo.array = new MathData(cell.cell());
+ MathData & ar = cell.cell();
+ undo.array = new MathData(ar.buffer(), ar.begin(), ar.end());
} else {
// some more effort needed here as 'the whole cell' of the
// main Text _is_ the whole document.
// try to return early.
// We will store in otherstack the part of the document under 'undo'
- DocIterator cell_dit = undo.cell.asDocIterator(&buffer_.inset());
+ DocIterator cell_dit = undo.cell.asDocIterator(&buffer_);
doRecordUndo(ATOMIC_UNDO, cell_dit,
undo.from, cell_dit.lastpit() - undo.end, cur,
// This does the actual undo/redo.
//LYXERR0("undo, performing: " << undo);
- DocIterator dit = undo.cell.asDocIterator(&buffer_.inset());
+ DocIterator dit = undo.cell.asDocIterator(&buffer_);
if (undo.isFullBuffer) {
LASSERT(undo.pars, /**/);
// This is a full document
LASSERT(undo.pars == 0, /**/);
LASSERT(undo.array == 0, /**/);
- cur = undo.cursor.asDocIterator(&buffer_.inset());
+ cur = undo.cursor.asDocIterator(&buffer_);
+ if (undo.lyx_clean)
+ buffer_.markClean();
+ else
+ buffer_.markDirty();
// Now that we're done with undo, we pop it off the stack.
stack.pop();
}
while (!stack.empty() && stack.top().group_id == gid)
doTextUndoOrRedo(cur, stack, otherstack);
- // Addapt the new material to current buffer.
- updateLabels(buffer_);
+ // Adapt the new material to current buffer.
+ buffer_.setBuffersForInsets(); // FIXME This shouldn't be here.
return true;
}
beginUndoGroup();
d->doRecordUndo(
ATOMIC_UNDO,
- doc_iterator_begin(d->buffer_.inset()),
+ doc_iterator_begin(&d->buffer_),
0, d->buffer_.paragraphs().size() - 1,
cur,
true,