From 2b27114a4ef84ab2657a3df4c80ceacd38e5fdd3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Tue, 15 Apr 2003 19:31:45 +0000 Subject: [PATCH] one more use ParagraphList::iterator git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6820 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 ++++ src/text_funcs.C | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index f746d4350c..ffd15422d4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2003-04-15 Lars Gullik Bjønnes + + * text_funcs.C (transposeChars): use ParagraphList::iterator here. + 2003-04-15 Lars Gullik Bjønnes * ParagraphList.C: prepare for NO_NEXT diff --git a/src/text_funcs.C b/src/text_funcs.C index 01f4d089db..c8d28597ed 100644 --- a/src/text_funcs.C +++ b/src/text_funcs.C @@ -19,38 +19,40 @@ #include "lyxcursor.h" #include "undo_funcs.h" +#include + using lyx::pos_type; void transposeChars(LyXText & text, LyXCursor const & cursor) { - Paragraph * tmppar = &*cursor.par(); + ParagraphList::iterator tmppit = cursor.par(); - setUndo(text.bv(), Undo::FINISH, tmppar, tmppar->next()); + setUndo(text.bv(), Undo::FINISH, &*tmppit, &*boost::next(tmppit)); pos_type tmppos = cursor.pos(); // First decide if it is possible to transpose at all - if (tmppos == 0 || tmppos == tmppar->size()) + if (tmppos == 0 || tmppos == tmppit->size()) return; - if (isDeletedText(*tmppar, tmppos - 1) - || isDeletedText(*tmppar, tmppos)) + if (isDeletedText(*tmppit, tmppos - 1) + || isDeletedText(*tmppit, tmppos)) return; - unsigned char c1 = tmppar->getChar(tmppos); - unsigned char c2 = tmppar->getChar(tmppos - 1); + unsigned char c1 = tmppit->getChar(tmppos); + unsigned char c2 = tmppit->getChar(tmppos - 1); // We should have an implementation that handles insets // as well, but that will have to come later. (Lgb) if (c1 == Paragraph::META_INSET || c2 == Paragraph::META_INSET) return; - bool const erased = tmppar->erase(tmppos - 1, tmppos + 1); + bool const erased = tmppit->erase(tmppos - 1, tmppos + 1); pos_type const ipos(erased ? tmppos - 1 : tmppos + 1); - tmppar->insertChar(ipos, c1); - tmppar->insertChar(ipos + 1, c2); + tmppit->insertChar(ipos, c1); + tmppit->insertChar(ipos + 1, c2); - text.checkParagraph(tmppar, tmppos); + text.checkParagraph(tmppit, tmppos); } -- 2.39.5