minor cleanup

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3206 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-12-13 17:19:53 +00:00
parent 06fbab0b77
commit 3677e0f57b
4 changed files with 29 additions and 17 deletions

View File

@ -1,3 +1,9 @@
2001-12-13 André Pönitz <poenitz@gmx.net>
* undostack.[Ch]:
* undo_func.C: minor cleanup
2001-12-12 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr> 2001-12-12 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* FontLoader.C (getFontinfo): only use symbol fonts with encoding * FontLoader.C (getFontinfo): only use symbol fonts with encoding

View File

@ -26,10 +26,12 @@ bool undo_finished;
/// a flag /// a flag
bool undo_frozen; bool undo_frozen;
bool textUndo(BufferView * bv) bool textUndo(BufferView * bv)
{ {
// returns false if no undo possible // returns false if no undo possible
Undo * undo = bv->buffer()->undostack.pop(); Undo * undo = bv->buffer()->undostack.top();
bv->buffer()->undostack.pop();
if (undo) { if (undo) {
finishUndo(); finishUndo();
if (!undo_frozen) { if (!undo_frozen) {
@ -50,7 +52,8 @@ bool textUndo(BufferView * bv)
bool textRedo(BufferView * bv) bool textRedo(BufferView * bv)
{ {
// returns false if no redo possible // returns false if no redo possible
Undo * undo = bv->buffer()->redostack.pop(); Undo * undo = bv->buffer()->redostack.top();
bv->buffer()->redostack.pop();
if (undo) { if (undo) {
finishUndo(); finishUndo();
if (!undo_frozen) { if (!undo_frozen) {
@ -247,7 +250,6 @@ void setRedo(BufferView * bv, Undo::undo_kind kind,
bv->buffer()->redostack.push(createUndo(bv, kind, first, behind)); bv->buffer()->redostack.push(createUndo(bv, kind, first, behind));
} }
using lyx::pos_type;
Undo * createUndo(BufferView * bv, Undo::undo_kind kind, Undo * createUndo(BufferView * bv, Undo::undo_kind kind,
Paragraph const * first, Paragraph const * behind) Paragraph const * first, Paragraph const * behind)
@ -345,6 +347,7 @@ void setCursorParUndo(BufferView * bv)
bv->text->cursor.par()->next()); bv->text->cursor.par()->next());
} }
Paragraph * firstUndoParagraph(BufferView * bv, int inset_id) Paragraph * firstUndoParagraph(BufferView * bv, int inset_id)
{ {
Inset * inset = bv->buffer()->getInsetFromID(inset_id); Inset * inset = bv->buffer()->getInsetFromID(inset_id);
@ -356,6 +359,7 @@ Paragraph * firstUndoParagraph(BufferView * bv, int inset_id)
return bv->text->ownerParagraph(); return bv->text->ownerParagraph();
} }
LyXCursor const & undoCursor(BufferView * bv) LyXCursor const & undoCursor(BufferView * bv)
{ {
if (bv->theLockingInset()) if (bv->theLockingInset())

View File

@ -23,18 +23,18 @@ UndoStack::UndoStack()
: limit(100) {} : limit(100) {}
Undo * UndoStack::pop() void UndoStack::pop()
{ {
if (stakk.empty()) return 0; if (stakk.empty())
Undo * result = stakk.front(); return;
stakk.pop_front(); stakk.pop_front();
return result;
} }
Undo * UndoStack::top() Undo * UndoStack::top() const
{ {
if (stakk.empty()) return 0; if (stakk.empty())
return 0;
return stakk.front(); return stakk.front();
} }
@ -63,7 +63,8 @@ void UndoStack::SetStackLimit(Stakk::size_type l)
void UndoStack::push(Undo * undo_arg) void UndoStack::push(Undo * undo_arg)
{ {
if (!undo_arg) return; if (!undo_arg)
return;
stakk.push_front(undo_arg); stakk.push_front(undo_arg);
if (stakk.size() > limit) { if (stakk.size() > limit) {
@ -74,6 +75,7 @@ void UndoStack::push(Undo * undo_arg)
} }
bool UndoStack::empty() const { bool UndoStack::empty() const
{
return stakk.empty(); return stakk.empty();
} }

View File

@ -33,14 +33,14 @@ public:
/// ///
UndoStack(); UndoStack();
/// ///
Undo * pop(); ~UndoStack();
/// ///
Undo * top(); void pop();
///
Undo * top() const;
/// ///
bool empty() const; bool empty() const;
/// ///
~UndoStack();
///
void clear(); void clear();
/// ///
void SetStackLimit(Stakk::size_type l); void SetStackLimit(Stakk::size_type l);