]> git.lyx.org Git - features.git/commitdiff
Do BreakParagraph on an empty paragraph if it's flagged keepempty (fix #313).
authorJürgen Vigna <jug@sad.it>
Fri, 12 Apr 2002 10:29:12 +0000 (10:29 +0000)
committerJürgen Vigna <jug@sad.it>
Fri, 12 Apr 2002 10:29:12 +0000 (10:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3983 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/paragraph.C
src/text.C

index 3e514a02d5a1fbb96e00e016d8bdc0a7108afbac..3ae0942835b5d49ad76a3d72f06137b2c9b81e24 100644 (file)
@@ -1,5 +1,11 @@
 2002-04-12  Juergen Vigna  <jug@sad.it>
 
+       * 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.
 
index c702876d1debc9dc5319aeccea3bce0ef5f7ec30..055f0d435982d8b0aa3515d5475e76aa1b3f6e18 100644 (file)
@@ -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());
index 73690c491e7a7bf3e53a28f6891544f17b5f07f5..b53d26db66c9fd801b6d355a323187001c182e8c 100644 (file)
@@ -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()))