From 3677e0f57bf03b0b03d5102422f8b07d58669a90 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 13 Dec 2001 17:19:53 +0000 Subject: [PATCH] minor cleanup git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3206 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 ++++++ src/undo_funcs.C | 14 +++++++++----- src/undostack.C | 18 ++++++++++-------- src/undostack.h | 8 ++++---- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 3558d8cac6..fd5a065a91 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ + +2001-12-13 André Pönitz + + * undostack.[Ch]: + * undo_func.C: minor cleanup + 2001-12-12 Jean-Marc Lasgouttes * FontLoader.C (getFontinfo): only use symbol fonts with encoding diff --git a/src/undo_funcs.C b/src/undo_funcs.C index 37041317f4..175003ac25 100644 --- a/src/undo_funcs.C +++ b/src/undo_funcs.C @@ -26,10 +26,12 @@ bool undo_finished; /// a flag bool undo_frozen; + bool textUndo(BufferView * bv) { // returns false if no undo possible - Undo * undo = bv->buffer()->undostack.pop(); + Undo * undo = bv->buffer()->undostack.top(); + bv->buffer()->undostack.pop(); if (undo) { finishUndo(); if (!undo_frozen) { @@ -50,7 +52,8 @@ bool textUndo(BufferView * bv) bool textRedo(BufferView * bv) { // returns false if no redo possible - Undo * undo = bv->buffer()->redostack.pop(); + Undo * undo = bv->buffer()->redostack.top(); + bv->buffer()->redostack.pop(); if (undo) { finishUndo(); if (!undo_frozen) { @@ -247,7 +250,6 @@ void setRedo(BufferView * bv, Undo::undo_kind kind, bv->buffer()->redostack.push(createUndo(bv, kind, first, behind)); } -using lyx::pos_type; Undo * createUndo(BufferView * bv, Undo::undo_kind kind, Paragraph const * first, Paragraph const * behind) @@ -276,8 +278,8 @@ Undo * createUndo(BufferView * bv, Undo::undo_kind kind, // check wether storing is needed if (!bv->buffer()->undostack.empty() && bv->buffer()->undostack.top()->kind == kind && - bv->buffer()->undostack.top()->number_of_before_par == before_number && - bv->buffer()->undostack.top()->number_of_behind_par == behind_number ){ + bv->buffer()->undostack.top()->number_of_before_par == before_number && + bv->buffer()->undostack.top()->number_of_behind_par == behind_number) { // no undo needed return 0; } @@ -345,6 +347,7 @@ void setCursorParUndo(BufferView * bv) bv->text->cursor.par()->next()); } + Paragraph * firstUndoParagraph(BufferView * bv, int inset_id) { Inset * inset = bv->buffer()->getInsetFromID(inset_id); @@ -356,6 +359,7 @@ Paragraph * firstUndoParagraph(BufferView * bv, int inset_id) return bv->text->ownerParagraph(); } + LyXCursor const & undoCursor(BufferView * bv) { if (bv->theLockingInset()) diff --git a/src/undostack.C b/src/undostack.C index 8ca17bfd47..5b7ec58569 100644 --- a/src/undostack.C +++ b/src/undostack.C @@ -23,18 +23,18 @@ UndoStack::UndoStack() : limit(100) {} -Undo * UndoStack::pop() +void UndoStack::pop() { - if (stakk.empty()) return 0; - Undo * result = stakk.front(); + if (stakk.empty()) + return; 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(); } @@ -63,7 +63,8 @@ void UndoStack::SetStackLimit(Stakk::size_type l) void UndoStack::push(Undo * undo_arg) { - if (!undo_arg) return; + if (!undo_arg) + return; stakk.push_front(undo_arg); 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(); } diff --git a/src/undostack.h b/src/undostack.h index e611e3a065..35632d54bd 100644 --- a/src/undostack.h +++ b/src/undostack.h @@ -33,13 +33,13 @@ public: /// UndoStack(); /// - Undo * pop(); + ~UndoStack(); /// - Undo * top(); + void pop(); /// - bool empty() const; + Undo * top() const; /// - ~UndoStack(); + bool empty() const; /// void clear(); /// -- 2.39.5