2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file Undo.cpp
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-10-14 13:01:49 +00:00
|
|
|
|
* \author Asger Alstrup
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-10-14 13:01:49 +00:00
|
|
|
|
* \author John Levon
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
2003-10-14 13:01:49 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
2007-10-18 11:51:17 +00:00
|
|
|
|
* \author Abdelrazak Younes
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
1999-11-15 12:01:38 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Undo.h"
|
2003-10-14 13:01:49 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Buffer.h"
|
2007-10-18 11:51:17 +00:00
|
|
|
|
#include "BufferParams.h"
|
2007-01-31 14:36:15 +00:00
|
|
|
|
#include "buffer_funcs.h"
|
2007-11-29 07:04:28 +00:00
|
|
|
|
#include "support/debug.h"
|
2007-10-18 11:51:17 +00:00
|
|
|
|
#include "DocIterator.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Paragraph.h"
|
2006-03-23 20:11:06 +00:00
|
|
|
|
#include "ParagraphList.h"
|
2007-10-18 11:51:17 +00:00
|
|
|
|
#include "Text.h"
|
2001-05-08 13:28:44 +00:00
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "mathed/MathSupport.h"
|
2007-04-26 16:06:39 +00:00
|
|
|
|
#include "mathed/MathData.h"
|
2007-03-27 14:33:19 +00:00
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
#include "insets/Inset.h"
|
2004-03-08 21:14:45 +00:00
|
|
|
|
|
2007-10-19 14:23:32 +00:00
|
|
|
|
#include "support/limited_stack.h"
|
|
|
|
|
|
2004-03-08 21:14:45 +00:00
|
|
|
|
#include <algorithm>
|
2007-11-28 22:12:03 +00:00
|
|
|
|
#include <ostream>
|
2004-03-08 21:14:45 +00:00
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
|
using namespace lyx::support;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2003-10-14 13:01:49 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
These are the elements put on the undo stack. Each object contains complete
|
|
|
|
|
paragraphs from some cell and sufficient information to restore the cursor
|
|
|
|
|
state.
|
|
|
|
|
|
|
|
|
|
The cell is given by a DocIterator pointing to this cell, the 'interesting'
|
|
|
|
|
range of paragraphs by counting them from begin and end of cell,
|
|
|
|
|
respectively.
|
|
|
|
|
|
|
|
|
|
The cursor is also given as DocIterator and should point to some place in
|
|
|
|
|
the stored paragraph range. In case of math, we simply store the whole
|
|
|
|
|
cell, as there usually is just a simple paragraph in a cell.
|
|
|
|
|
|
|
|
|
|
The idea is to store the contents of 'interesting' paragraphs in some
|
|
|
|
|
structure ('Undo') _before_ it is changed in some edit operation.
|
|
|
|
|
Obviously, the stored ranged should be as small as possible. However, it
|
|
|
|
|
there is a lower limit: The StableDocIterator pointing stored in the undo
|
|
|
|
|
class must be valid after the changes, too, as it will used as a pointer
|
|
|
|
|
where to insert the stored bits when performining undo.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
struct UndoElement
|
|
|
|
|
{
|
|
|
|
|
/// Which kind of operation are we recording for?
|
|
|
|
|
UndoKind kind;
|
|
|
|
|
/// the position of the cursor
|
|
|
|
|
StableDocIterator cursor;
|
|
|
|
|
/// the position of the cell described
|
|
|
|
|
StableDocIterator cell;
|
|
|
|
|
/// counted from begin of cell
|
|
|
|
|
pit_type from;
|
|
|
|
|
/// complement to end of this cell
|
|
|
|
|
pit_type end;
|
|
|
|
|
/// the contents of the saved Paragraphs (for texted)
|
|
|
|
|
ParagraphList * pars;
|
|
|
|
|
/// the contents of the saved MathData (for mathed)
|
|
|
|
|
MathData * array;
|
|
|
|
|
/// Only used in case of full backups
|
|
|
|
|
BufferParams bparams;
|
|
|
|
|
/// Only used in case of full backups
|
|
|
|
|
bool isFullBuffer;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Undo::Private
|
|
|
|
|
{
|
|
|
|
|
Private(Buffer & buffer): buffer_(buffer) {}
|
|
|
|
|
|
|
|
|
|
// Returns false if no undo possible.
|
|
|
|
|
bool textUndoOrRedo(DocIterator & cur, bool isUndoOperation);
|
|
|
|
|
///
|
|
|
|
|
void doRecordUndo(UndoKind kind,
|
|
|
|
|
DocIterator const & cell,
|
|
|
|
|
pit_type first_pit,
|
|
|
|
|
pit_type last_pit,
|
|
|
|
|
DocIterator const & cur,
|
|
|
|
|
bool isFullBuffer,
|
|
|
|
|
bool isUndoOperation);
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
void recordUndo(UndoKind kind,
|
|
|
|
|
DocIterator & cur,
|
|
|
|
|
pit_type first_pit,
|
|
|
|
|
pit_type last_pit);
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
Buffer & buffer_;
|
|
|
|
|
/// Undo stack.
|
|
|
|
|
limited_stack<UndoElement> undostack;
|
|
|
|
|
/// Redo stack.
|
|
|
|
|
limited_stack<UndoElement> redostack;
|
|
|
|
|
|
|
|
|
|
/// The flag used by Undo::finishUndo().
|
|
|
|
|
bool undo_finished;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Undo::Undo(Buffer & buffer): d(new Undo::Private(buffer))
|
|
|
|
|
{
|
|
|
|
|
}
|
2004-03-27 12:46:30 +00:00
|
|
|
|
|
2003-10-14 13:01:49 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
Undo::~Undo()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Undo::hasUndoStack() const
|
|
|
|
|
{
|
|
|
|
|
return !d->undostack.empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Undo::hasRedoStack() const
|
|
|
|
|
{
|
|
|
|
|
return !d->redostack.empty();
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-14 13:01:49 +00:00
|
|
|
|
|
|
|
|
|
|
2003-10-15 08:49:44 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
|
ostream & operator<<(ostream & os, UndoElement const & undo)
|
2003-10-14 13:01:49 +00:00
|
|
|
|
{
|
2004-10-23 11:04:41 +00:00
|
|
|
|
return os << " from: " << undo.from << " end: " << undo.end
|
2004-11-05 06:12:21 +00:00
|
|
|
|
<< " cell:\n" << undo.cell
|
2004-03-08 21:14:45 +00:00
|
|
|
|
<< " cursor:\n" << undo.cursor;
|
2003-10-15 08:49:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-10-13 17:20:30 +00:00
|
|
|
|
bool samePar(StableDocIterator const & i1, StableDocIterator const & i2)
|
|
|
|
|
{
|
|
|
|
|
StableDocIterator tmpi2 = i2;
|
|
|
|
|
tmpi2.pos() = i1.pos();
|
|
|
|
|
return i1 == tmpi2;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
2005-10-13 17:20:30 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
void Undo::Private::doRecordUndo(UndoKind kind,
|
2005-07-14 22:09:22 +00:00
|
|
|
|
DocIterator const & cell,
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type first_pit, pit_type last_pit,
|
2005-07-14 22:09:22 +00:00
|
|
|
|
DocIterator const & cur,
|
|
|
|
|
bool isFullBuffer,
|
2007-10-18 11:51:17 +00:00
|
|
|
|
bool isUndoOperation)
|
2003-10-14 13:01:49 +00:00
|
|
|
|
{
|
2004-11-24 21:53:46 +00:00
|
|
|
|
if (first_pit > last_pit)
|
2007-12-12 19:28:07 +00:00
|
|
|
|
swap(first_pit, last_pit);
|
2004-03-08 21:14:45 +00:00
|
|
|
|
// create the position information of the Undo entry
|
2007-10-18 11:51:17 +00:00
|
|
|
|
UndoElement undo;
|
2007-03-27 14:33:19 +00:00
|
|
|
|
undo.array = 0;
|
|
|
|
|
undo.pars = 0;
|
2004-03-08 21:14:45 +00:00
|
|
|
|
undo.kind = kind;
|
2004-11-05 06:12:21 +00:00
|
|
|
|
undo.cell = cell;
|
|
|
|
|
undo.cursor = cur;
|
2007-10-18 11:51:17 +00:00
|
|
|
|
undo.bparams = buffer_.params();
|
2005-07-14 22:09:22 +00:00
|
|
|
|
undo.isFullBuffer = isFullBuffer;
|
2005-07-15 00:39:44 +00:00
|
|
|
|
//lyxerr << "recordUndo: cur: " << cur << endl;
|
|
|
|
|
//lyxerr << "recordUndo: pos: " << cur.pos() << endl;
|
2004-11-05 06:12:21 +00:00
|
|
|
|
//lyxerr << "recordUndo: cell: " << cell << endl;
|
2004-11-24 21:53:46 +00:00
|
|
|
|
undo.from = first_pit;
|
|
|
|
|
undo.end = cell.lastpit() - last_pit;
|
2003-10-14 13:01:49 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
limited_stack<UndoElement> & stack = isUndoOperation ?
|
|
|
|
|
undostack : redostack;
|
|
|
|
|
|
2004-03-08 21:14:45 +00:00
|
|
|
|
// Undo::ATOMIC are always recorded (no overlapping there).
|
|
|
|
|
// As nobody wants all removed character appear one by one when undoing,
|
|
|
|
|
// we want combine 'similar' non-ATOMIC undo recordings to one.
|
|
|
|
|
if (!undo_finished
|
2007-10-18 11:51:17 +00:00
|
|
|
|
&& kind != ATOMIC_UNDO
|
2004-03-08 21:14:45 +00:00
|
|
|
|
&& !stack.empty()
|
2005-10-13 17:20:30 +00:00
|
|
|
|
&& samePar(stack.top().cell, undo.cell)
|
|
|
|
|
&& stack.top().kind == undo.kind
|
|
|
|
|
&& stack.top().from == undo.from
|
|
|
|
|
&& stack.top().end == undo.end)
|
2004-03-08 21:14:45 +00:00
|
|
|
|
return;
|
2004-03-01 17:12:09 +00:00
|
|
|
|
|
2004-03-08 21:14:45 +00:00
|
|
|
|
// fill in the real data to be saved
|
2004-11-05 06:12:21 +00:00
|
|
|
|
if (cell.inMathed()) {
|
2004-03-08 21:14:45 +00:00
|
|
|
|
// simply use the whole cell
|
2007-04-26 16:06:39 +00:00
|
|
|
|
undo.array = new MathData(cell.cell());
|
2004-03-08 21:14:45 +00:00
|
|
|
|
} else {
|
|
|
|
|
// some more effort needed here as 'the whole cell' of the
|
2007-04-29 23:33:02 +00:00
|
|
|
|
// main Text _is_ the whole document.
|
2004-03-01 17:12:09 +00:00
|
|
|
|
// record the relevant paragraphs
|
2007-04-29 23:33:02 +00:00
|
|
|
|
Text const * text = cell.text();
|
2004-03-08 21:14:45 +00:00
|
|
|
|
BOOST_ASSERT(text);
|
2005-07-18 11:00:15 +00:00
|
|
|
|
ParagraphList const & plist = text->paragraphs();
|
|
|
|
|
ParagraphList::const_iterator first = plist.begin();
|
2004-11-24 21:53:46 +00:00
|
|
|
|
advance(first, first_pit);
|
2005-07-18 11:00:15 +00:00
|
|
|
|
ParagraphList::const_iterator last = plist.begin();
|
2004-11-24 21:53:46 +00:00
|
|
|
|
advance(last, last_pit + 1);
|
2007-03-27 14:33:19 +00:00
|
|
|
|
undo.pars = new ParagraphList(first, last);
|
2004-03-01 17:12:09 +00:00
|
|
|
|
}
|
2003-10-14 13:01:49 +00:00
|
|
|
|
|
2004-04-03 08:37:12 +00:00
|
|
|
|
// push the undo entry to undo stack
|
2004-03-08 21:14:45 +00:00
|
|
|
|
stack.push(undo);
|
2007-12-12 19:28:07 +00:00
|
|
|
|
//lyxerr << "undo record: " << stack.top() << endl;
|
2004-03-08 21:14:45 +00:00
|
|
|
|
|
|
|
|
|
// next time we'll try again to combine entries if possible
|
2003-10-14 13:01:49 +00:00
|
|
|
|
undo_finished = false;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
void Undo::Private::recordUndo(UndoKind kind, DocIterator & cur,
|
|
|
|
|
pit_type first_pit, pit_type last_pit)
|
2004-11-05 06:12:21 +00:00
|
|
|
|
{
|
2004-11-24 21:53:46 +00:00
|
|
|
|
BOOST_ASSERT(first_pit <= cur.lastpit());
|
|
|
|
|
BOOST_ASSERT(last_pit <= cur.lastpit());
|
2004-11-05 06:12:21 +00:00
|
|
|
|
|
2005-07-14 22:09:22 +00:00
|
|
|
|
doRecordUndo(kind, cur, first_pit, last_pit, cur,
|
2007-10-18 11:51:17 +00:00
|
|
|
|
false, true);
|
2004-11-05 06:12:21 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
undo_finished = false;
|
|
|
|
|
redostack.clear();
|
|
|
|
|
//lyxerr << "undostack:\n";
|
|
|
|
|
//for (size_t i = 0, n = buf.undostack().size(); i != n && i < 6; ++i)
|
2007-12-12 19:28:07 +00:00
|
|
|
|
// lyxerr << " " << i << ": " << buf.undostack()[i] << endl;
|
2007-10-18 11:51:17 +00:00
|
|
|
|
}
|
2003-10-14 13:01:49 +00:00
|
|
|
|
|
2005-07-14 22:09:22 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
bool Undo::Private::textUndoOrRedo(DocIterator & cur, bool isUndoOperation)
|
2003-10-14 13:01:49 +00:00
|
|
|
|
{
|
2007-10-18 11:51:17 +00:00
|
|
|
|
undo_finished = true;
|
2005-07-14 22:09:22 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
limited_stack<UndoElement> & stack = isUndoOperation ?
|
|
|
|
|
undostack : redostack;
|
|
|
|
|
|
|
|
|
|
if (stack.empty())
|
2005-07-14 22:09:22 +00:00
|
|
|
|
// Nothing to do.
|
|
|
|
|
return false;
|
2007-10-18 11:51:17 +00:00
|
|
|
|
|
|
|
|
|
limited_stack<UndoElement> & otherstack = isUndoOperation ?
|
|
|
|
|
redostack : undostack;
|
2005-07-14 22:09:22 +00:00
|
|
|
|
|
|
|
|
|
// Adjust undo stack and get hold of current undo data.
|
2007-10-18 11:51:17 +00:00
|
|
|
|
UndoElement undo = stack.top();
|
2005-07-14 22:09:22 +00:00
|
|
|
|
stack.pop();
|
|
|
|
|
|
|
|
|
|
// We will store in otherstack the part of the document under 'undo'
|
2007-10-18 11:51:17 +00:00
|
|
|
|
DocIterator cell_dit = undo.cell.asDocIterator(&buffer_.inset());
|
2005-07-14 22:09:22 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
doRecordUndo(ATOMIC_UNDO, cell_dit,
|
|
|
|
|
undo.from, cell_dit.lastpit() - undo.end, cur,
|
|
|
|
|
undo.isFullBuffer, !isUndoOperation);
|
2005-07-14 22:09:22 +00:00
|
|
|
|
|
|
|
|
|
// This does the actual undo/redo.
|
2007-11-28 22:12:03 +00:00
|
|
|
|
//LYXERR0("undo, performing: " << undo);
|
2007-06-13 07:43:34 +00:00
|
|
|
|
bool labelsUpdateNeeded = false;
|
2007-10-18 11:51:17 +00:00
|
|
|
|
DocIterator dit = undo.cell.asDocIterator(&buffer_.inset());
|
2005-07-14 22:09:22 +00:00
|
|
|
|
if (undo.isFullBuffer) {
|
2007-03-27 14:33:19 +00:00
|
|
|
|
BOOST_ASSERT(undo.pars);
|
2005-07-14 22:09:22 +00:00
|
|
|
|
// This is a full document
|
2007-10-18 11:51:17 +00:00
|
|
|
|
otherstack.top().bparams = buffer_.params();
|
|
|
|
|
buffer_.params() = undo.bparams;
|
2007-12-12 19:28:07 +00:00
|
|
|
|
swap(buffer_.paragraphs(), *undo.pars);
|
2007-03-27 14:33:19 +00:00
|
|
|
|
delete undo.pars;
|
|
|
|
|
undo.pars = 0;
|
2005-07-14 22:09:22 +00:00
|
|
|
|
} else if (dit.inMathed()) {
|
2004-03-08 21:14:45 +00:00
|
|
|
|
// We stored the full cell here as there is not much to be
|
|
|
|
|
// gained by storing just 'a few' paragraphs (most if not
|
|
|
|
|
// all math inset cells have just one paragraph!)
|
2007-11-28 22:12:03 +00:00
|
|
|
|
//LYXERR0("undo.array: " << *undo.array);
|
2007-03-27 14:33:19 +00:00
|
|
|
|
BOOST_ASSERT(undo.array);
|
|
|
|
|
dit.cell().swap(*undo.array);
|
|
|
|
|
delete undo.array;
|
|
|
|
|
undo.array = 0;
|
2004-03-08 21:14:45 +00:00
|
|
|
|
} else {
|
|
|
|
|
// Some finer machinery is needed here.
|
2007-04-29 23:33:02 +00:00
|
|
|
|
Text * text = dit.text();
|
2004-03-08 21:14:45 +00:00
|
|
|
|
BOOST_ASSERT(text);
|
2007-03-27 14:33:19 +00:00
|
|
|
|
BOOST_ASSERT(undo.pars);
|
2004-03-08 21:14:45 +00:00
|
|
|
|
ParagraphList & plist = text->paragraphs();
|
|
|
|
|
|
|
|
|
|
// remove new stuff between first and last
|
2003-10-14 13:01:49 +00:00
|
|
|
|
ParagraphList::iterator first = plist.begin();
|
2004-03-08 21:14:45 +00:00
|
|
|
|
advance(first, undo.from);
|
2003-10-14 13:01:49 +00:00
|
|
|
|
ParagraphList::iterator last = plist.begin();
|
2004-03-08 21:14:45 +00:00
|
|
|
|
advance(last, plist.size() - undo.end);
|
|
|
|
|
plist.erase(first, last);
|
2003-10-14 13:01:49 +00:00
|
|
|
|
|
2004-03-08 21:14:45 +00:00
|
|
|
|
// re-insert old stuff instead
|
|
|
|
|
first = plist.begin();
|
|
|
|
|
advance(first, undo.from);
|
2004-12-06 13:06:13 +00:00
|
|
|
|
|
|
|
|
|
// this ugly stuff is needed until we get rid of the
|
|
|
|
|
// inset_owner backpointer
|
2007-03-27 14:33:19 +00:00
|
|
|
|
ParagraphList::iterator pit = undo.pars->begin();
|
|
|
|
|
ParagraphList::iterator const end = undo.pars->end();
|
2004-12-06 13:06:13 +00:00
|
|
|
|
for (; pit != end; ++pit)
|
2005-11-24 16:22:39 +00:00
|
|
|
|
pit->setInsetOwner(dit.realInset());
|
2007-03-27 14:33:19 +00:00
|
|
|
|
plist.insert(first, undo.pars->begin(), undo.pars->end());
|
|
|
|
|
delete undo.pars;
|
|
|
|
|
undo.pars = 0;
|
2007-06-13 07:43:34 +00:00
|
|
|
|
labelsUpdateNeeded = true;
|
2003-10-14 13:01:49 +00:00
|
|
|
|
}
|
2007-03-27 14:33:19 +00:00
|
|
|
|
BOOST_ASSERT(undo.pars == 0);
|
|
|
|
|
BOOST_ASSERT(undo.array == 0);
|
2003-10-14 13:01:49 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
cur = undo.cursor.asDocIterator(&buffer_.inset());
|
2007-06-13 07:43:34 +00:00
|
|
|
|
|
|
|
|
|
if (labelsUpdateNeeded)
|
2007-10-18 11:51:17 +00:00
|
|
|
|
updateLabels(buffer_);
|
|
|
|
|
undo_finished = true;
|
2004-03-08 21:14:45 +00:00
|
|
|
|
return true;
|
2003-10-14 13:01:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
void Undo::finishUndo()
|
2003-10-14 13:01:49 +00:00
|
|
|
|
{
|
2004-10-23 11:04:41 +00:00
|
|
|
|
// Make sure the next operation will be stored.
|
2007-10-18 11:51:17 +00:00
|
|
|
|
d->undo_finished = true;
|
2003-10-14 13:01:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
bool Undo::textUndo(DocIterator & cur)
|
2003-10-14 13:01:49 +00:00
|
|
|
|
{
|
2007-10-18 11:51:17 +00:00
|
|
|
|
return d->textUndoOrRedo(cur, true);
|
2003-10-14 13:01:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
bool Undo::textRedo(DocIterator & cur)
|
2003-10-14 13:01:49 +00:00
|
|
|
|
{
|
2007-10-18 11:51:17 +00:00
|
|
|
|
return d->textUndoOrRedo(cur, false);
|
2003-10-14 13:01:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
void Undo::recordUndo(DocIterator & cur, UndoKind kind)
|
2004-04-18 19:41:40 +00:00
|
|
|
|
{
|
2007-10-18 11:51:17 +00:00
|
|
|
|
d->recordUndo(kind, cur, cur.pit(), cur.pit());
|
2004-04-18 19:41:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
void Undo::recordUndoInset(DocIterator & cur, UndoKind kind)
|
2004-02-13 07:30:59 +00:00
|
|
|
|
{
|
2007-10-18 11:51:17 +00:00
|
|
|
|
DocIterator c = cur;
|
|
|
|
|
c.pop_back();
|
|
|
|
|
d->doRecordUndo(kind, c, c.pit(), c.pit(), cur, false, true);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
void Undo::recordUndo(DocIterator & cur, UndoKind kind, pit_type from)
|
2003-10-14 13:01:49 +00:00
|
|
|
|
{
|
2007-10-18 11:51:17 +00:00
|
|
|
|
d->recordUndo(kind, cur, cur.pit(), from);
|
2004-01-15 17:34:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
void Undo::recordUndo(DocIterator & cur, UndoKind kind,
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type from, pit_type to)
|
2004-02-03 08:56:28 +00:00
|
|
|
|
{
|
2007-10-18 11:51:17 +00:00
|
|
|
|
d->recordUndo(kind, cur, from, to);
|
2004-02-03 08:56:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
void Undo::recordUndoFullDocument(DocIterator & cur)
|
2004-01-15 17:34:44 +00:00
|
|
|
|
{
|
2007-10-18 11:51:17 +00:00
|
|
|
|
d->doRecordUndo(
|
|
|
|
|
ATOMIC_UNDO,
|
|
|
|
|
doc_iterator_begin(d->buffer_.inset()),
|
|
|
|
|
0, d->buffer_.paragraphs().size() - 1,
|
|
|
|
|
cur,
|
2005-07-14 22:09:22 +00:00
|
|
|
|
true,
|
2007-10-18 11:51:17 +00:00
|
|
|
|
true
|
2005-07-14 22:09:22 +00:00
|
|
|
|
);
|
2003-10-14 13:01:49 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|