1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file undo.h
|
|
|
|
|
* 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
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
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-06-04 07:14:05 +00:00
|
|
|
|
#include "ParagraphList.h"
|
2000-03-28 02:18:55 +00:00
|
|
|
|
|
2003-07-25 19:18:43 +00:00
|
|
|
|
/**
|
|
|
|
|
* These are the elements put on the undo stack. Each object
|
|
|
|
|
* contains complete paragraphs and sufficient information
|
|
|
|
|
* to restore the state. The work is done in undo_funcs.C
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
class Undo {
|
|
|
|
|
public:
|
2003-07-25 19:18:43 +00:00
|
|
|
|
/**
|
|
|
|
|
* The undo kinds are used to combine consecutive undo recordings
|
|
|
|
|
* of the same kind.
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
enum undo_kind {
|
2003-07-25 19:18:43 +00:00
|
|
|
|
/**
|
|
|
|
|
* Insert something - these will combine to one big chunk
|
|
|
|
|
* when many inserts come after each other.
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
INSERT,
|
2003-07-25 19:18:43 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete something - these will combine to one big chunk
|
|
|
|
|
* when many deletes come after each other.
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
DELETE,
|
2003-07-25 19:18:43 +00:00
|
|
|
|
|
|
|
|
|
/// Atomic - each of these will have its own entry in the stack
|
|
|
|
|
ATOMIC
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
///
|
2003-07-25 19:18:43 +00:00
|
|
|
|
Undo(undo_kind kind, int inset_id,
|
|
|
|
|
int first, int last,
|
|
|
|
|
int cursor, int cursor_pos,
|
|
|
|
|
ParagraphList const & par_arg);
|
|
|
|
|
|
|
|
|
|
/// Which kind of operation are we recording for?
|
1999-09-27 18:44:28 +00:00
|
|
|
|
undo_kind kind;
|
2003-07-25 19:18:43 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ID of hosting inset if the cursor is in one.
|
|
|
|
|
* if -1, then the cursor is not in an inset.
|
|
|
|
|
* if >= 0, then the cursor is in inset with given id.
|
|
|
|
|
*/
|
|
|
|
|
int inset_id;
|
|
|
|
|
|
|
|
|
|
/// Offset to the first paragraph in the main document paragraph list
|
2003-06-04 12:45:26 +00:00
|
|
|
|
int first_par_offset;
|
2003-07-25 19:18:43 +00:00
|
|
|
|
|
|
|
|
|
/// Offset to the last paragraph from the end of the main par. list
|
2003-06-04 12:45:26 +00:00
|
|
|
|
int last_par_offset;
|
2003-07-25 19:18:43 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Offset from the start of the main document paragraph list,
|
|
|
|
|
* except if inside an inset, in which case it's the offset
|
|
|
|
|
* inside the hosting inset.
|
|
|
|
|
*/
|
2003-06-04 12:45:26 +00:00
|
|
|
|
int cursor_par_offset;
|
2003-06-04 07:14:05 +00:00
|
|
|
|
|
2003-07-25 19:18:43 +00:00
|
|
|
|
/// The position of the cursor in the hosting paragraph
|
|
|
|
|
int cursor_pos;
|
2003-06-04 07:14:05 +00:00
|
|
|
|
|
2003-07-25 19:18:43 +00:00
|
|
|
|
/// The contents of the paragraphs saved
|
|
|
|
|
ParagraphList pars;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|