#include "Cursor.h"
#include "debug.h"
#include "BufferView.h"
-#include "LyXText.h"
+#include "Text.h"
#include "Paragraph.h"
#include "ParagraphList.h"
#include "mathed/MathSupport.h"
#include "mathed/MathData.h"
-#include "insets/InsetBase.h"
+#include "insets/Inset.h"
#include <algorithm>
undo.array = new MathData(cell.cell());
} else {
// some more effort needed here as 'the whole cell' of the
- // main LyXText _is_ the whole document.
+ // main Text _is_ the whole document.
// record the relevant paragraphs
- LyXText const * text = cell.text();
+ Text const * text = cell.text();
BOOST_ASSERT(text);
ParagraphList const & plist = text->paragraphs();
ParagraphList::const_iterator first = plist.begin();
BOOST_ASSERT(last_pit <= cur.lastpit());
doRecordUndo(kind, cur, first_pit, last_pit, cur,
- cur.bv().buffer()->params(), false, stack);
+ cur.bv().buffer().params(), false, stack);
}
stack.pop();
// We will store in otherstack the part of the document under 'undo'
- Buffer * buf = bv.buffer();
- DocIterator cell_dit = undo.cell.asDocIterator(&buf->inset());
+ Buffer & buf = bv.buffer();
+ DocIterator cell_dit = undo.cell.asDocIterator(&buf.inset());
doRecordUndo(Undo::ATOMIC, cell_dit,
undo.from, cell_dit.lastpit() - undo.end, bv.cursor(),
// This does the actual undo/redo.
//lyxerr << "undo, performing: " << undo << std::endl;
- DocIterator dit = undo.cell.asDocIterator(&buf->inset());
+ bool labelsUpdateNeeded = false;
+ DocIterator dit = undo.cell.asDocIterator(&buf.inset());
if (undo.isFullBuffer) {
BOOST_ASSERT(undo.pars);
// This is a full document
- otherstack.top().bparams = buf->params();
- buf->params() = undo.bparams;
- std::swap(buf->paragraphs(), *undo.pars);
+ otherstack.top().bparams = buf.params();
+ buf.params() = undo.bparams;
+ std::swap(buf.paragraphs(), *undo.pars);
delete undo.pars;
undo.pars = 0;
} else if (dit.inMathed()) {
undo.array = 0;
} else {
// Some finer machinery is needed here.
- LyXText * text = dit.text();
+ Text * text = dit.text();
BOOST_ASSERT(text);
BOOST_ASSERT(undo.pars);
ParagraphList & plist = text->paragraphs();
plist.insert(first, undo.pars->begin(), undo.pars->end());
delete undo.pars;
undo.pars = 0;
- updateLabels(*buf);
+ labelsUpdateNeeded = true;
}
BOOST_ASSERT(undo.pars == 0);
BOOST_ASSERT(undo.array == 0);
// Set cursor
Cursor & cur = bv.cursor();
- cur.setCursor(undo.cursor.asDocIterator(&buf->inset()));
+ cur.setCursor(undo.cursor.asDocIterator(&buf.inset()));
cur.selection() = false;
cur.resetAnchor();
cur.fixIfBroken();
+
+ if (labelsUpdateNeeded)
+ updateLabels(buf);
finishUndo();
-
return true;
}
bool textUndo(BufferView & bv)
{
- return textUndoOrRedo(bv, bv.buffer()->undostack(),
- bv.buffer()->redostack());
+ return textUndoOrRedo(bv, bv.buffer().undostack(),
+ bv.buffer().redostack());
}
bool textRedo(BufferView & bv)
{
- return textUndoOrRedo(bv, bv.buffer()->redostack(),
- bv.buffer()->undostack());
+ return textUndoOrRedo(bv, bv.buffer().redostack(),
+ bv.buffer().undostack());
}
void recordUndo(Undo::undo_kind kind,
Cursor & cur, pit_type first, pit_type last)
{
- Buffer * buf = cur.bv().buffer();
- recordUndo(kind, cur, first, last, buf->undostack());
- buf->redostack().clear();
+ Buffer & buf = cur.bv().buffer();
+ recordUndo(kind, cur, first, last, buf.undostack());
+ buf.redostack().clear();
//lyxerr << "undostack:\n";
- //for (size_t i = 0, n = buf->undostack().size(); i != n && i < 6; ++i)
- // lyxerr << " " << i << ": " << buf->undostack()[i] << std::endl;
+ //for (size_t i = 0, n = buf.undostack().size(); i != n && i < 6; ++i)
+ // lyxerr << " " << i << ": " << buf.undostack()[i] << std::endl;
}
{
Cursor c = cur;
c.pop();
- Buffer * buf = cur.bv().buffer();
+ Buffer & buf = cur.bv().buffer();
doRecordUndo(kind, c, c.pit(), c.pit(), cur,
- buf->params(), false, buf->undostack());
+ buf.params(), false, buf.undostack());
}
void recordUndoFullDocument(BufferView * bv)
{
- Buffer * buf = bv->buffer();
+ Buffer & buf = bv->buffer();
doRecordUndo(
Undo::ATOMIC,
- doc_iterator_begin(buf->inset()),
- 0, buf->paragraphs().size() - 1,
+ doc_iterator_begin(buf.inset()),
+ 0, buf.paragraphs().size() - 1,
bv->cursor(),
- buf->params(),
+ buf.params(),
true,
- buf->undostack()
+ buf.undostack()
);
undo_finished = false;
}