From 5a4fe1be418507f0fa63e4712bdfb61c035d48a4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Fri, 12 Apr 2002 10:29:12 +0000 Subject: [PATCH] Do BreakParagraph on an empty paragraph if it's flagged keepempty (fix #313). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3983 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 ++++++ src/paragraph.C | 5 +++-- src/text.C | 14 +++++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 3e514a02d5..3ae0942835 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2002-04-12 Juergen Vigna + * text.C (breakParagraph): honor keepempty flag and break the paragraph + also with no chars on this paragraph. + + * paragraph.C (breakParagraph): honor keepempty flag and break the + paragraph always below not above. + * BufferView2.C (unlockInset): update the paragraph layout on inset unlock as we changed paragraph in such a case. diff --git a/src/paragraph.C b/src/paragraph.C index c702876d1d..055f0d4359 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -884,7 +884,8 @@ void Paragraph::breakParagraph(BufferParams const & bparams, tmp->setLabelWidthString(params().labelWidthString()); } - if (size() > pos || !size() || flag == 2) { + bool isempty = textclasslist[bparams.textclass][layout()].keepempty; + if (!isempty && (size() > pos || !size() || flag == 2)) { tmp->layout(layout()); tmp->params().align(params().align()); tmp->setLabelWidthString(params().labelWidthString()); @@ -915,7 +916,7 @@ void Paragraph::breakParagraph(BufferParams const & bparams, } // just an idea of me - if (!pos) { + if (!isempty && !pos) { tmp->params().lineTop(params().lineTop()); tmp->params().pagebreakTop(params().pagebreakTop()); tmp->params().spaceTop(params().spaceTop()); diff --git a/src/text.C b/src/text.C index 73690c491e..b53d26db66 100644 --- a/src/text.C +++ b/src/text.C @@ -1710,8 +1710,10 @@ void LyXText::breakParagraph(BufferView * bview, char keep_layout) LyXLayout const & layout = tclass[cursor.par()->layout()]; // this is only allowed, if the current paragraph is not empty or caption + // and if it has not the keepempty flag aktive if ((cursor.par()->size() <= 0) - && layout.labeltype!= LABEL_SENSITIVE) + && layout.labeltype != LABEL_SENSITIVE + && !layout.keepempty) return; setUndo(bview, Undo::FINISH, cursor.par(), cursor.par()->next()); @@ -1747,7 +1749,8 @@ void LyXText::breakParagraph(BufferView * bview, char keep_layout) * This touches only the screen-update. Otherwise we would may have * an empty row on the screen */ if (cursor.pos() && !cursor.row()->par()->isNewline(cursor.row()->pos() - 1) - && cursor.row()->pos() == cursor.pos()) { + && cursor.row()->pos() == cursor.pos()) + { cursorLeft(bview); } @@ -1780,7 +1783,7 @@ void LyXText::breakParagraph(BufferView * bview, char keep_layout) /* This check is necessary. Otherwise the new empty paragraph will * be deleted automatically. And it is more friendly for the user! */ - if (cursor.pos()) + if (cursor.pos() || layout.keepempty) setCursor(bview, cursor.par()->next(), 0); else setCursor(bview, cursor.par(), 0); @@ -1907,13 +1910,14 @@ void LyXText::insertChar(BufferView * bview, char c) } } else if (IsNewlineChar(c)) { if (cursor.pos() <= beginningOfMainBody(bview->buffer(), - cursor.par())) { + cursor.par())) + { charInserted(); return; } /* No newline at first position * of a paragraph or behind labels. - * TeX does not allow that. */ + * TeX does not allow that */ if (cursor.pos() < cursor.par()->size() && cursor.par()->isLineSeparator(cursor.pos())) -- 2.39.2