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
This commit is contained in:
Jürgen Vigna 2002-04-12 10:29:12 +00:00
parent ced212a684
commit 5a4fe1be41
3 changed files with 18 additions and 7 deletions

View File

@ -1,5 +1,11 @@
2002-04-12 Juergen Vigna <jug@sad.it> 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 * BufferView2.C (unlockInset): update the paragraph layout on inset
unlock as we changed paragraph in such a case. unlock as we changed paragraph in such a case.

View File

@ -884,7 +884,8 @@ void Paragraph::breakParagraph(BufferParams const & bparams,
tmp->setLabelWidthString(params().labelWidthString()); 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->layout(layout());
tmp->params().align(params().align()); tmp->params().align(params().align());
tmp->setLabelWidthString(params().labelWidthString()); tmp->setLabelWidthString(params().labelWidthString());
@ -915,7 +916,7 @@ void Paragraph::breakParagraph(BufferParams const & bparams,
} }
// just an idea of me // just an idea of me
if (!pos) { if (!isempty && !pos) {
tmp->params().lineTop(params().lineTop()); tmp->params().lineTop(params().lineTop());
tmp->params().pagebreakTop(params().pagebreakTop()); tmp->params().pagebreakTop(params().pagebreakTop());
tmp->params().spaceTop(params().spaceTop()); tmp->params().spaceTop(params().spaceTop());

View File

@ -1710,8 +1710,10 @@ void LyXText::breakParagraph(BufferView * bview, char keep_layout)
LyXLayout const & layout = tclass[cursor.par()->layout()]; LyXLayout const & layout = tclass[cursor.par()->layout()];
// this is only allowed, if the current paragraph is not empty or caption // 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) if ((cursor.par()->size() <= 0)
&& layout.labeltype!= LABEL_SENSITIVE) && layout.labeltype != LABEL_SENSITIVE
&& !layout.keepempty)
return; return;
setUndo(bview, Undo::FINISH, cursor.par(), cursor.par()->next()); 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 * This touches only the screen-update. Otherwise we would may have
* an empty row on the screen */ * an empty row on the screen */
if (cursor.pos() && !cursor.row()->par()->isNewline(cursor.row()->pos() - 1) if (cursor.pos() && !cursor.row()->par()->isNewline(cursor.row()->pos() - 1)
&& cursor.row()->pos() == cursor.pos()) { && cursor.row()->pos() == cursor.pos())
{
cursorLeft(bview); cursorLeft(bview);
} }
@ -1780,7 +1783,7 @@ void LyXText::breakParagraph(BufferView * bview, char keep_layout)
/* This check is necessary. Otherwise the new empty paragraph will /* This check is necessary. Otherwise the new empty paragraph will
* be deleted automatically. And it is more friendly for the user! */ * 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); setCursor(bview, cursor.par()->next(), 0);
else else
setCursor(bview, cursor.par(), 0); setCursor(bview, cursor.par(), 0);
@ -1907,13 +1910,14 @@ void LyXText::insertChar(BufferView * bview, char c)
} }
} else if (IsNewlineChar(c)) { } else if (IsNewlineChar(c)) {
if (cursor.pos() <= beginningOfMainBody(bview->buffer(), if (cursor.pos() <= beginningOfMainBody(bview->buffer(),
cursor.par())) { cursor.par()))
{
charInserted(); charInserted();
return; return;
} }
/* No newline at first position /* No newline at first position
* of a paragraph or behind labels. * of a paragraph or behind labels.
* TeX does not allow that. */ * TeX does not allow that */
if (cursor.pos() < cursor.par()->size() && if (cursor.pos() < cursor.par()->size() &&
cursor.par()->isLineSeparator(cursor.pos())) cursor.par()->isLineSeparator(cursor.pos()))