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
|
2000-03-16 04:29:22 +00:00
|
|
|
* Copyright 1995-2000 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>
|
2000-03-28 02:18:55 +00:00
|
|
|
|
1999-12-13 07:33:00 +00:00
|
|
|
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,
|
2000-01-06 02:44:26 +00:00
|
|
|
LyXParagraph * par_arg);
|
|
|
|
///
|
|
|
|
~Undo();
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
///
|
2000-01-06 02:44:26 +00:00
|
|
|
bool empty() const;
|
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
|