2001-07-06 15:57:54 +00:00
|
|
|
/* This file is part of
|
2002-03-21 17:27:08 +00:00
|
|
|
* ======================================================
|
|
|
|
*
|
2001-07-06 15:57:54 +00:00
|
|
|
* LyX, The Document Processor
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2001-07-06 15:57:54 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team.
|
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "undo_funcs.h"
|
|
|
|
#include "lyxtext.h"
|
2003-05-16 07:44:00 +00:00
|
|
|
#include "funcrequest.h"
|
2001-07-06 15:57:54 +00:00
|
|
|
#include "BufferView.h"
|
|
|
|
#include "buffer.h"
|
2003-02-20 17:39:48 +00:00
|
|
|
#include "insets/updatableinset.h"
|
2003-04-16 00:02:38 +00:00
|
|
|
#include "insets/insettext.h"
|
2001-07-06 15:57:54 +00:00
|
|
|
#include "debug.h"
|
2001-07-29 15:34:18 +00:00
|
|
|
#include "support/LAssert.h"
|
2001-12-19 08:59:15 +00:00
|
|
|
#include "iterators.h"
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
2003-05-01 23:24:30 +00:00
|
|
|
/// The flag used by FinishUndo().
|
2001-07-06 15:57:54 +00:00
|
|
|
bool undo_finished;
|
2003-05-01 23:24:30 +00:00
|
|
|
/// Whether actions are not added to the undo stacks.
|
2001-07-06 15:57:54 +00:00
|
|
|
bool undo_frozen;
|
|
|
|
|
2002-05-26 19:40:17 +00:00
|
|
|
namespace {
|
2001-12-13 17:19:53 +00:00
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
|
2002-05-26 19:40:17 +00:00
|
|
|
/**
|
|
|
|
* Finish the undo operation in the case there was no entry
|
|
|
|
* on the stack to perform.
|
|
|
|
*/
|
|
|
|
void finishNoUndo(BufferView * bv)
|
2001-07-06 15:57:54 +00:00
|
|
|
{
|
2001-12-14 11:55:58 +00:00
|
|
|
freezeUndo();
|
|
|
|
bv->unlockInset(bv->theLockingInset());
|
2002-05-26 19:40:17 +00:00
|
|
|
finishUndo();
|
2003-03-17 16:25:00 +00:00
|
|
|
bv->text->postPaint(0);
|
2001-12-14 11:55:58 +00:00
|
|
|
unFreezeUndo();
|
2001-07-06 15:57:54 +00:00
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
|
|
|
2003-05-01 23:24:30 +00:00
|
|
|
// Returns false if no undo possible.
|
2002-05-26 19:40:17 +00:00
|
|
|
bool textHandleUndo(BufferView * bv, Undo & undo)
|
2001-07-06 15:57:54 +00:00
|
|
|
{
|
2003-06-04 07:14:05 +00:00
|
|
|
Buffer * buf = bv->buffer();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
ParagraphList * plist = &buf->paragraphs;
|
|
|
|
/*
|
|
|
|
ParIterator null = buf->par_iterator_end();
|
2003-05-23 13:35:36 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
for (ParIterator it = buf->par_iterator_begin(); it != null; ++it)
|
|
|
|
if (it.plist().id() == undo.plist_id) {
|
|
|
|
plist = &it.plist();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*/
|
2001-07-06 15:57:54 +00:00
|
|
|
|
2003-05-22 16:10:34 +00:00
|
|
|
// Set the right(new) inset-owner of the paragraph if there is any.
|
2003-06-04 16:14:36 +00:00
|
|
|
UpdatableInset * inset =
|
|
|
|
static_cast<UpdatableInset *>(buf->getInsetFromID(undo.inset_id));
|
|
|
|
|
2003-06-04 07:14:05 +00:00
|
|
|
ParagraphList::iterator pit = undo.pars.begin();
|
|
|
|
ParagraphList::iterator end = undo.pars.end();
|
|
|
|
for ( ; pit != end; ++pit)
|
2003-06-04 12:45:26 +00:00
|
|
|
pit->setInsetOwner(inset);
|
|
|
|
|
2003-06-05 12:16:06 +00:00
|
|
|
//lyxerr << "\nhandle: inset_id: " << undo.inset_id << "\n";
|
|
|
|
//lyxerr << "handle: inset: " << inset << "\n";
|
2003-06-04 16:14:36 +00:00
|
|
|
//lyxerr << "handle: plist_id: " << undo.plist_id << "\n";
|
2003-06-04 12:45:26 +00:00
|
|
|
lyxerr << "handle: undo.pars.size(): " << undo.pars.size() << "\n";
|
2003-06-04 16:14:36 +00:00
|
|
|
lyxerr << "handle: first_offset: " << undo.first_par_offset << "\n";
|
|
|
|
lyxerr << "handle: last_offset: " << undo.last_par_offset << "\n";
|
2003-06-04 07:14:05 +00:00
|
|
|
|
|
|
|
// remove stuff between first and behind
|
2003-06-04 12:45:26 +00:00
|
|
|
{
|
|
|
|
ParagraphList::iterator first = plist->begin();
|
|
|
|
advance(first, undo.first_par_offset);
|
|
|
|
ParagraphList::iterator last = plist->begin();
|
|
|
|
advance(last, plist->size() - undo.last_par_offset);
|
|
|
|
lyxerr << "handle: first_id: " << first->id() << "\n";
|
|
|
|
lyxerr << "handle: last_id: " << last->id() << "\n";
|
2003-06-04 16:14:36 +00:00
|
|
|
lyxerr << "handle: remove: " << distance(first, last) + 1 << " pars\n";
|
2003-06-04 12:45:26 +00:00
|
|
|
plist->erase(first, ++last);
|
2003-06-04 16:14:36 +00:00
|
|
|
lyxerr << "handle: after remove\n";
|
2003-05-23 13:35:36 +00:00
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
// re-insert old stuff
|
|
|
|
{
|
|
|
|
ParagraphList::iterator first = plist->begin();
|
|
|
|
advance(first, undo.first_par_offset);
|
2003-06-04 16:14:36 +00:00
|
|
|
lyxerr << "handle: plist->size: " << plist->size() << "\n";
|
|
|
|
lyxerr << "handle: offset: " << undo.first_par_offset << "\n";
|
2003-06-04 12:45:26 +00:00
|
|
|
plist->insert(first, undo.pars.begin(), undo.pars.end());
|
2003-06-04 16:14:36 +00:00
|
|
|
lyxerr << "handle: after insert\n";
|
2003-06-04 12:45:26 +00:00
|
|
|
}
|
2003-05-23 13:35:36 +00:00
|
|
|
|
2003-06-04 07:14:05 +00:00
|
|
|
/*
|
|
|
|
// A memory optimization for edit:
|
|
|
|
// Only layout information
|
|
|
|
// is stored in the undo. So restore
|
|
|
|
// the text informations.
|
|
|
|
if (undo.kind == Undo::EDIT) {
|
|
|
|
undo.pars[par]->setContentsFromPar(*deletelist.back());
|
|
|
|
++par;
|
|
|
|
}
|
|
|
|
*/
|
2003-05-24 11:54:10 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
// redo Paragraphs (should be handled outside undo...)
|
|
|
|
{
|
2003-06-04 16:14:36 +00:00
|
|
|
//LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
|
|
|
|
LyXText * text = bv->text;
|
|
|
|
lyxerr << "handle: text: " << text << "\n";
|
2003-06-04 12:45:26 +00:00
|
|
|
if (undo.first_par_offset) {
|
|
|
|
ParagraphList::iterator redo = plist->begin();
|
2003-06-04 16:14:36 +00:00
|
|
|
lyxerr << "handle: 1\n";
|
2003-06-04 12:45:26 +00:00
|
|
|
advance(redo, undo.first_par_offset);
|
2003-06-04 16:14:36 +00:00
|
|
|
lyxerr << "handle: 2\n";
|
2003-06-04 12:45:26 +00:00
|
|
|
text->setCursorIntern(plist->begin(), 0);
|
|
|
|
}
|
2003-06-04 16:14:36 +00:00
|
|
|
lyxerr << "handle: 3\n";
|
2003-06-04 12:45:26 +00:00
|
|
|
text->redoParagraphs(text->cursor, plist->end());
|
2003-06-04 16:14:36 +00:00
|
|
|
lyxerr << "handle: after redo\n";
|
2003-05-01 23:24:30 +00:00
|
|
|
|
2003-06-04 16:14:36 +00:00
|
|
|
if (inset) {
|
|
|
|
FuncRequest cmd(bv, LFUN_INSET_EDIT, "left");
|
|
|
|
inset->localDispatch(cmd);
|
|
|
|
}
|
2003-05-22 15:16:58 +00:00
|
|
|
}
|
2003-06-04 16:14:36 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
if (inset) {
|
2003-06-04 07:14:05 +00:00
|
|
|
lyxerr << "fit cursor...\n";
|
2003-05-22 15:16:58 +00:00
|
|
|
bv->fitCursor();
|
2003-06-04 12:45:26 +00:00
|
|
|
bv->updateInset(inset);
|
2002-05-26 19:40:17 +00:00
|
|
|
}
|
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
// set cursor
|
|
|
|
{
|
2003-06-04 16:14:36 +00:00
|
|
|
LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
|
|
|
|
ParagraphList::iterator cursor = text->ownerParagraphs().begin();
|
2003-06-04 12:45:26 +00:00
|
|
|
advance(cursor, undo.cursor_par_offset);
|
2003-06-04 16:14:36 +00:00
|
|
|
text->setCursorIntern(cursor, undo.cursor_pos);
|
|
|
|
// Clear any selection and set the selection
|
|
|
|
// cursor for an evt. new selection.
|
|
|
|
text->clearSelection();
|
|
|
|
text->selection.cursor = text->cursor;
|
|
|
|
text->updateCounters();
|
2003-06-04 12:45:26 +00:00
|
|
|
lyxerr << "after setCursor\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
finishUndo();
|
2003-03-17 16:25:00 +00:00
|
|
|
bv->text->postPaint(0);
|
2003-05-23 13:35:36 +00:00
|
|
|
|
2003-06-04 07:14:05 +00:00
|
|
|
lyxerr << "finished textHandleUndo...\n";
|
2002-05-26 19:40:17 +00:00
|
|
|
return true;
|
2001-07-06 15:57:54 +00:00
|
|
|
}
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2003-06-04 07:14:05 +00:00
|
|
|
void createUndo(BufferView * bv, Undo::undo_kind kind,
|
2003-06-04 12:45:26 +00:00
|
|
|
ParagraphList::iterator first, ParagraphList::iterator last,
|
2003-06-04 07:14:05 +00:00
|
|
|
limited_stack<Undo> & stack)
|
2001-07-06 15:57:54 +00:00
|
|
|
{
|
2003-06-04 07:14:05 +00:00
|
|
|
Buffer * buf = bv->buffer();
|
2001-07-06 15:57:54 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
ParagraphList * plist = 0;
|
|
|
|
ParIterator null = buf->par_iterator_end();
|
2003-05-23 10:33:40 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
lyxerr << "\n";
|
|
|
|
|
2003-06-04 16:14:36 +00:00
|
|
|
UpdatableInset * inset = first->inInset();
|
|
|
|
LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
|
|
|
|
int const inset_id = inset ? inset->id() : -1;
|
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
#if 0
|
|
|
|
// this is what we'd like to have in the end for small grained undo
|
2003-06-04 07:14:05 +00:00
|
|
|
for (ParIterator it = buf->par_iterator_begin(); it != null; ++it) {
|
2003-06-04 12:45:26 +00:00
|
|
|
if (it->id() == first->id()) {
|
|
|
|
plist = &it.plist();
|
|
|
|
break;
|
2003-05-23 11:07:23 +00:00
|
|
|
}
|
2003-06-04 12:45:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
// and that's the big stick we wield now
|
|
|
|
lyxerr << "create: first_id orig: " << first->id() << "\n";
|
|
|
|
lyxerr << "create: last_id orig: " << last->id() << "\n";
|
|
|
|
plist = &buf->paragraphs;
|
|
|
|
// this is what we'd like to have in the end for small grained undo
|
|
|
|
for (ParIterator it = buf->par_iterator_begin(); it != null; ++it) {
|
2003-06-05 12:16:06 +00:00
|
|
|
if (it->id() == first->id())
|
2003-06-04 12:45:26 +00:00
|
|
|
first = it.outerPar();
|
2003-06-05 12:16:06 +00:00
|
|
|
if (it->id() == last->id())
|
2003-06-04 12:45:26 +00:00
|
|
|
last = it.outerPar();
|
2003-05-23 10:33:40 +00:00
|
|
|
}
|
2001-07-06 15:57:54 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
#endif
|
2003-05-23 10:33:40 +00:00
|
|
|
|
2003-06-05 12:16:06 +00:00
|
|
|
int const first_offset = std::distance(plist->begin(), first);
|
|
|
|
int const last_offset = std::distance(last, plist->end());
|
2003-05-23 10:33:40 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
if (last == plist->end()) {
|
2003-06-04 16:14:36 +00:00
|
|
|
lyxerr << "*** createUndo: last == end should not happen\n";
|
2003-05-23 10:33:40 +00:00
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
|
2003-05-23 10:33:40 +00:00
|
|
|
// Undo::EDIT and Undo::FINISH are
|
2001-07-06 15:57:54 +00:00
|
|
|
// always finished. (no overlapping there)
|
2002-03-21 17:27:08 +00:00
|
|
|
// overlapping only with insert and delete inside one paragraph:
|
2001-07-06 15:57:54 +00:00
|
|
|
// Nobody wants all removed character
|
2002-03-21 17:27:08 +00:00
|
|
|
// appear one by one when undoing.
|
2001-07-06 15:57:54 +00:00
|
|
|
// EDIT is special since only layout information, not the
|
|
|
|
// contents of a paragaph are stored.
|
2003-06-04 07:14:05 +00:00
|
|
|
if (!undo_finished && kind != Undo::EDIT && kind != Undo::FINISH) {
|
2003-05-01 23:24:30 +00:00
|
|
|
// Check whether storing is needed.
|
2003-06-04 07:14:05 +00:00
|
|
|
if (!buf->undostack.empty() &&
|
|
|
|
buf->undostack.top().kind == kind &&
|
2003-06-04 12:45:26 +00:00
|
|
|
buf->undostack.top().first_par_offset == first_offset &&
|
|
|
|
buf->undostack.top().last_par_offset == last_offset) {
|
2003-05-01 23:24:30 +00:00
|
|
|
// No undo needed.
|
2003-06-04 07:14:05 +00:00
|
|
|
return;
|
2001-07-06 15:57:54 +00:00
|
|
|
}
|
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2003-05-01 23:24:30 +00:00
|
|
|
// Create a new Undo.
|
2003-06-04 16:14:36 +00:00
|
|
|
int const cursor_offset = std::distance
|
|
|
|
(text->ownerParagraphs().begin(), text->cursor.par());
|
|
|
|
|
|
|
|
//lyxerr << "create: plist_id: " << plist->id() << "\n";
|
2003-06-05 12:16:06 +00:00
|
|
|
//lyxerr << "create: inset_id: " << inset_id << "\n";
|
2003-06-04 16:14:36 +00:00
|
|
|
lyxerr << "create: first_id: " << first->id() << "\n";
|
|
|
|
lyxerr << "create: last_id: " << last->id() << "\n";
|
|
|
|
lyxerr << "create: first_offset: " << first_offset << "\n";
|
|
|
|
lyxerr << "create: last_offset: " << last_offset << "\n";
|
|
|
|
lyxerr << "create: cursor_offset: " << cursor_offset << "\n";
|
|
|
|
lyxerr << "create: cursor_pos: " << text->cursor.pos() << "\n";
|
2003-06-04 07:14:05 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
stack.push(Undo(kind, inset_id, 0, //plist->id(),
|
2003-06-04 16:14:36 +00:00
|
|
|
first_offset, last_offset,
|
|
|
|
cursor_offset, text->cursor.pos(),
|
|
|
|
ParagraphList()));
|
2003-06-04 07:14:05 +00:00
|
|
|
|
|
|
|
ParagraphList & undo_pars = stack.top().pars;
|
2001-07-06 15:57:54 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
for (ParagraphList::iterator it = first; it != last; ++it) {
|
2003-06-04 07:14:05 +00:00
|
|
|
undo_pars.push_back(*it);
|
|
|
|
undo_pars.back().id(it->id());
|
2003-05-25 08:49:48 +00:00
|
|
|
}
|
2003-06-04 12:45:26 +00:00
|
|
|
undo_pars.push_back(*last);
|
2003-06-04 07:14:05 +00:00
|
|
|
undo_pars.back().id(last->id());
|
2001-07-06 15:57:54 +00:00
|
|
|
|
2003-05-02 13:38:53 +00:00
|
|
|
// A memory optimization: Just store the layout
|
|
|
|
// information when only edit.
|
2003-05-23 13:35:36 +00:00
|
|
|
#warning Waste...
|
|
|
|
//if (kind == Undo::EDIT)
|
|
|
|
// for (size_t i = 0, n = undo_pars.size(); i < n; ++i)
|
|
|
|
// undo_pars[i]->clearContents();
|
2003-05-02 13:38:53 +00:00
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
undo_finished = false;
|
|
|
|
}
|
|
|
|
|
2002-05-26 19:40:17 +00:00
|
|
|
|
2003-05-01 23:24:30 +00:00
|
|
|
// Returns false if no undo possible.
|
2003-04-29 14:50:11 +00:00
|
|
|
bool textUndoOrRedo(BufferView * bv,
|
2003-06-04 07:14:05 +00:00
|
|
|
limited_stack<Undo> & stack,
|
2003-06-04 12:45:26 +00:00
|
|
|
limited_stack<Undo> & otherstack)
|
2002-05-26 19:40:17 +00:00
|
|
|
{
|
2003-04-29 14:50:11 +00:00
|
|
|
if (stack.empty()) {
|
2002-05-26 19:40:17 +00:00
|
|
|
finishNoUndo(bv);
|
|
|
|
return false;
|
2001-07-06 15:57:54 +00:00
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2003-06-04 07:14:05 +00:00
|
|
|
Undo undo = stack.top();
|
2003-04-29 14:50:11 +00:00
|
|
|
stack.pop();
|
2002-05-26 19:40:17 +00:00
|
|
|
finishUndo();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2003-05-27 13:55:03 +00:00
|
|
|
if (!undo_frozen) {
|
2003-06-04 12:45:26 +00:00
|
|
|
otherstack.push(undo);
|
|
|
|
otherstack.top().pars.clear();
|
2003-05-27 13:55:03 +00:00
|
|
|
Buffer * buf = bv->buffer();
|
2003-06-04 12:45:26 +00:00
|
|
|
ParagraphList & plist = buf->paragraphs;
|
|
|
|
lyxerr << "\nredo: first: " << undo.first_par_offset << "\n";
|
|
|
|
lyxerr << "redo: last: " << undo.last_par_offset << "\n";
|
|
|
|
lyxerr << "redo: size: " << plist.size() << "\n";
|
|
|
|
if (undo.first_par_offset + undo.last_par_offset <= int(plist.size())) {
|
|
|
|
ParagraphList::iterator first = plist.begin();
|
|
|
|
advance(first, undo.first_par_offset);
|
|
|
|
ParagraphList::iterator last = plist.begin();
|
|
|
|
advance(last, plist.size() - undo.last_par_offset + 1);
|
|
|
|
otherstack.top().pars.insert(otherstack.top().pars.begin(), first, last);
|
2002-05-26 19:40:17 +00:00
|
|
|
}
|
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2003-06-04 12:45:26 +00:00
|
|
|
// Now we can unlock the inset for safety because the inset
|
2003-05-01 23:24:30 +00:00
|
|
|
// pointer could be changed during the undo-function. Anyway
|
|
|
|
// if needed we have to lock the right inset/position if this
|
|
|
|
// is requested.
|
2002-05-26 19:40:17 +00:00
|
|
|
freezeUndo();
|
|
|
|
bv->unlockInset(bv->theLockingInset());
|
2003-06-04 07:14:05 +00:00
|
|
|
bool const ret = textHandleUndo(bv, undo);
|
2002-05-26 19:40:17 +00:00
|
|
|
unFreezeUndo();
|
|
|
|
return ret;
|
2001-07-06 15:57:54 +00:00
|
|
|
}
|
|
|
|
|
2003-04-29 14:50:11 +00:00
|
|
|
} // namespace anon
|
2001-12-13 17:19:53 +00:00
|
|
|
|
2003-05-01 23:24:30 +00:00
|
|
|
|
2003-04-29 14:50:11 +00:00
|
|
|
void finishUndo()
|
2001-07-06 15:57:54 +00:00
|
|
|
{
|
2003-05-01 23:24:30 +00:00
|
|
|
// Makes sure the next operation will be stored.
|
2003-04-29 14:50:11 +00:00
|
|
|
undo_finished = true;
|
|
|
|
}
|
2002-05-26 19:40:17 +00:00
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2003-04-29 14:50:11 +00:00
|
|
|
void freezeUndo()
|
|
|
|
{
|
2003-05-01 23:24:30 +00:00
|
|
|
// This is dangerous and for internal use only.
|
2003-04-29 14:50:11 +00:00
|
|
|
undo_frozen = true;
|
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
|
|
|
2003-04-29 14:50:11 +00:00
|
|
|
void unFreezeUndo()
|
|
|
|
{
|
2003-05-01 23:24:30 +00:00
|
|
|
// This is dangerous and for internal use only.
|
2003-04-29 14:50:11 +00:00
|
|
|
undo_frozen = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool textUndo(BufferView * bv)
|
|
|
|
{
|
2003-05-01 23:24:30 +00:00
|
|
|
return textUndoOrRedo(bv, bv->buffer()->undostack,
|
|
|
|
bv->buffer()->redostack);
|
2003-04-29 14:50:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool textRedo(BufferView * bv)
|
|
|
|
{
|
2003-05-01 23:24:30 +00:00
|
|
|
return textUndoOrRedo(bv, bv->buffer()->redostack,
|
|
|
|
bv->buffer()->undostack);
|
2002-05-26 19:40:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-27 11:53:41 +00:00
|
|
|
void setUndo(BufferView * bv, Undo::undo_kind kind)
|
|
|
|
{
|
|
|
|
setUndo(bv, kind, bv->text->cursor.par());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-26 19:40:17 +00:00
|
|
|
void setUndo(BufferView * bv, Undo::undo_kind kind,
|
2003-05-23 10:33:40 +00:00
|
|
|
ParagraphList::iterator first)
|
2002-05-26 19:40:17 +00:00
|
|
|
{
|
2003-05-23 10:33:40 +00:00
|
|
|
setUndo(bv, kind, first, first);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void setUndo(BufferView * bv, Undo::undo_kind kind,
|
|
|
|
ParagraphList::iterator first, ParagraphList::iterator last)
|
|
|
|
{
|
2002-05-26 19:40:17 +00:00
|
|
|
if (!undo_frozen) {
|
2003-06-04 12:45:26 +00:00
|
|
|
createUndo(bv, kind, first, last, bv->buffer()->undostack);
|
2002-05-26 19:40:17 +00:00
|
|
|
bv->buffer()->redostack.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void setCursorParUndo(BufferView * bv)
|
|
|
|
{
|
2003-05-23 10:33:40 +00:00
|
|
|
setUndo(bv, Undo::FINISH, bv->text->cursor.par());
|
2001-07-06 15:57:54 +00:00
|
|
|
}
|