From: Jean-Marc Lasgouttes Date: Thu, 28 Feb 2002 15:07:11 +0000 (+0000) Subject: new code for max depth; time to recompile your tree :) X-Git-Tag: 1.6.10~19785 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=cfffe1157179a78da9182c09fbe038d6e052f81f;p=features.git new code for max depth; time to recompile your tree :) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3611 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index cfac2e3c5c..1ea00e2700 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2002-02-28 Jean-Marc Lasgouttes + * paragraph.C (getMaxDepthAfter): new method. The maximal depth + that the paragraph following this one can have. + + * text2.C (incDepth): use Paragraph::getMaxDepthAfter + * vspace.C (asLatexCommand): fix bogus gcc warning * Makefile.am (lyx_SOURCES): remove vms_defines.h diff --git a/src/paragraph.C b/src/paragraph.C index 3f29163e4a..b82a9d0617 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1054,6 +1054,18 @@ Paragraph::depth_type Paragraph::getDepth() const } +Paragraph::depth_type Paragraph::getMaxDepthAfter(Buffer const * buffer) const +{ + const bool isenv = textclasslist.Style(buffer->params.textclass, + getLayout()).isEnvironment(); + + if (isenv) + return params().depth() + 1; + else + return params().depth(); + +} + char Paragraph::getAlign() const { return params().align(); diff --git a/src/paragraph.h b/src/paragraph.h index 29b201d380..accc89ef35 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -221,8 +221,10 @@ public: lyx::layout_type getLayout() const; /// char getAlign() const; - /// + /// The nesting depth of a paragraph depth_type getDepth() const; + /// The maximal possible depth of a paragraph after this one + depth_type getMaxDepthAfter(Buffer const *) const; /// void setLayout(lyx::layout_type new_layout); /// diff --git a/src/text2.C b/src/text2.C index 718e9af3a1..0cfe5f91fe 100644 --- a/src/text2.C +++ b/src/text2.C @@ -641,19 +641,10 @@ void LyXText::incDepth(BufferView * bview) cursor.par()->getLayout()).labeltype != LABEL_BIBLIO) { Paragraph * prev = cursor.par()->previous(); - if (prev) { - const int depth_diff - = prev->getDepth() - cursor.par()->getDepth(); - // go deeper only if - // (1) the previous para is already - // deeper (depth_diff > 0) - // (2) the previous para is a - // list-environment at the same - // depth as this para. - if (depth_diff > 0 || (depth_diff > -1 - && textclasslist.Style(bview->buffer()->params.textclass, - prev->getLayout()).isEnvironment())) { - cursor.par()->params().depth(cursor.par()->params().depth() + 1); + if (prev) { + if (cursor.par()->getDepth() + < prev->getMaxDepthAfter(bview->buffer())){ + cursor.par()->params().depth(cursor.par()->getDepth() + 1); anything_changed = true; } }