1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
* Copyright 1995-1999 The LyX Team.
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#ifndef UNDO_H
|
|
|
|
#define UNDO_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "lyxparagraph.h"
|
|
|
|
|
1999-12-13 07:33:00 +00:00
|
|
|
#include <list>
|
|
|
|
using std::list;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
class Undo {
|
|
|
|
public:
|
|
|
|
/// The undo kinds
|
|
|
|
enum undo_kind {
|
|
|
|
///
|
|
|
|
INSERT,
|
|
|
|
///
|
|
|
|
DELETE,
|
|
|
|
///
|
|
|
|
EDIT,
|
|
|
|
///
|
|
|
|
FINISH
|
|
|
|
};
|
|
|
|
///
|
|
|
|
undo_kind kind;
|
|
|
|
///
|
|
|
|
int number_of_before_par;
|
|
|
|
///
|
|
|
|
int number_of_behind_par;
|
|
|
|
///
|
|
|
|
int number_of_cursor_par;
|
|
|
|
///
|
|
|
|
int cursor_pos; // valid if >= 0
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
LyXParagraph * par;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
Undo(undo_kind kind_arg,
|
|
|
|
int number_before_arg, int number_behind_arg,
|
|
|
|
int cursor_par_arg, int cursor_pos_arg,
|
1999-11-15 12:01:38 +00:00
|
|
|
LyXParagraph * par_arg)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
kind = kind_arg;
|
|
|
|
number_of_before_par = number_before_arg;
|
|
|
|
number_of_behind_par = number_behind_arg;
|
|
|
|
number_of_cursor_par = cursor_par_arg;
|
|
|
|
cursor_pos = cursor_pos_arg;
|
|
|
|
par = par_arg;
|
|
|
|
}
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
~Undo() {
|
|
|
|
LyXParagraph * tmppar;
|
1999-09-27 18:44:28 +00:00
|
|
|
while (par) {
|
|
|
|
tmppar = par;
|
|
|
|
par = par->next;
|
|
|
|
delete tmppar;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
/// A limited Stack for the undo informations.
|
1999-09-27 18:44:28 +00:00
|
|
|
class UndoStack{
|
|
|
|
private:
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
typedef list<Undo*> Stakk;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
Stakk stakk;
|
|
|
|
/// the maximum number of undo steps stored.
|
|
|
|
Stakk::size_type limit;
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
UndoStack();
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
Undo * pop();
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
Undo * top();
|
|
|
|
///
|
|
|
|
bool empty() const { return stakk.empty(); }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
~UndoStack();
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
void clear();
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
void SetStackLimit(Stakk::size_type l);
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
void push(Undo * undo_arg);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|