1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file Undo.h
|
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-08-23 00:17:00 +00:00
|
|
|
|
* \author Asger Alstrup
|
|
|
|
|
* \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
|
1999-09-27 18:44:28 +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
|
|
|
|
|
|
|
|
|
#ifndef UNDO_H
|
|
|
|
|
#define UNDO_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-10-14 13:01:49 +00:00
|
|
|
|
#include "support/types.h"
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
class Buffer;
|
2005-07-14 22:09:22 +00:00
|
|
|
|
class BufferParams;
|
2006-12-30 15:05:15 +00:00
|
|
|
|
class DocIterator;
|
2007-04-26 16:06:39 +00:00
|
|
|
|
class MathData;
|
2007-04-26 08:30:11 +00:00
|
|
|
|
class ParagraphList;
|
2000-03-28 02:18:55 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
/// This is used to combine consecutive undo recordings of the same kind.
|
|
|
|
|
enum UndoKind {
|
|
|
|
|
/**
|
|
|
|
|
* Insert something - these will combine to one big chunk
|
|
|
|
|
* when many inserts come after each other.
|
|
|
|
|
*/
|
|
|
|
|
INSERT_UNDO,
|
|
|
|
|
/**
|
|
|
|
|
* Delete something - these will combine to one big chunk
|
|
|
|
|
* when many deletes come after each other.
|
|
|
|
|
*/
|
|
|
|
|
DELETE_UNDO,
|
|
|
|
|
/// Atomic - each of these will have its own entry in the stack
|
|
|
|
|
ATOMIC_UNDO
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2003-10-14 13:01:49 +00:00
|
|
|
|
/**
|
2004-02-03 08:56:28 +00:00
|
|
|
|
* Record undo information - call with the current cursor and the 'other
|
|
|
|
|
* end' of the range of changed paragraphs. So we give an inclusive range.
|
2003-10-14 13:01:49 +00:00
|
|
|
|
* 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.
|
2005-10-12 18:44:53 +00:00
|
|
|
|
*
|
|
|
|
|
* FIXME: We need something to record undo in partial grids for mathed.
|
|
|
|
|
* Right now we use recordUndoInset if more than one cell is changed,
|
|
|
|
|
* but that puts the cursor in front of the inset after undo. We would need
|
|
|
|
|
* something like
|
2007-10-18 11:51:17 +00:00
|
|
|
|
* recordUndoGrid(DocIterator & cur, UndoKind kind, idx_type from, idx_type to);
|
2005-10-12 18:44:53 +00:00
|
|
|
|
* and store the cell information in class Undo.
|
2003-10-14 13:01:49 +00:00
|
|
|
|
*/
|
2007-10-18 11:51:17 +00:00
|
|
|
|
class Undo
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
Undo(Buffer &);
|
|
|
|
|
|
|
|
|
|
~Undo();
|
|
|
|
|
|
|
|
|
|
/// this will undo the last action - returns false if no undo possible
|
|
|
|
|
bool textUndo(DocIterator &);
|
2003-10-14 13:01:49 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
/// this will redo the last undo - returns false if no redo possible
|
|
|
|
|
bool textRedo(DocIterator &);
|
2004-02-03 08:56:28 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
/// makes sure the next operation will be stored
|
|
|
|
|
void finishUndo();
|
2004-02-03 08:56:28 +00:00
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
///
|
|
|
|
|
bool hasUndoStack() const;
|
|
|
|
|
///
|
|
|
|
|
bool hasRedoStack() const;
|
|
|
|
|
|
|
|
|
|
/// The general case: prepare undo for an arbitrary range.
|
|
|
|
|
void recordUndo(DocIterator & cur, UndoKind kind,
|
|
|
|
|
pit_type from, pit_type to);
|
|
|
|
|
|
|
|
|
|
/// Convenience: prepare undo for the range between 'from' and cursor.
|
|
|
|
|
void recordUndo(DocIterator & cur, UndoKind kind, pit_type from);
|
|
|
|
|
|
|
|
|
|
/// Convenience: prepare undo for the single paragraph or cell
|
|
|
|
|
/// containing the cursor
|
|
|
|
|
void recordUndo(DocIterator & cur, UndoKind kind = ATOMIC_UNDO);
|
|
|
|
|
/// Convenience: prepare undo for the inset containing the cursor
|
|
|
|
|
void recordUndoInset(DocIterator & cur, UndoKind kind = ATOMIC_UNDO);
|
|
|
|
|
|
|
|
|
|
/// Convenience: prepare undo for the whole buffer
|
|
|
|
|
void recordUndoFullDocument(DocIterator & cur);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
struct Private;
|
|
|
|
|
Private * const d;
|
|
|
|
|
};
|
2003-10-14 13:01:49 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2007-10-18 11:51:17 +00:00
|
|
|
|
#endif // UNDO_H
|