]> git.lyx.org Git - features.git/commitdiff
new code for max depth; time to recompile your tree :)
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 28 Feb 2002 15:07:11 +0000 (15:07 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 28 Feb 2002 15:07:11 +0000 (15:07 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3611 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/paragraph.C
src/paragraph.h
src/text2.C

index cfac2e3c5c1eb10a755a90fadcb6a765b39bad00..1ea00e2700d79e7af3d685acbb8b550aa0cee064 100644 (file)
@@ -1,5 +1,10 @@
 2002-02-28  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
+       * 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
index 3f29163e4a8802b4dc08b9db33762b8dc4469ea5..b82a9d06175cb3b889b52a4cc9fb2d7756b196ab 100644 (file)
@@ -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();
index 29b201d3809a2eeb2c485d6d8f4613a316a0b64d..accc89ef35e1a30362cb58ad2d78be37fa420995 100644 (file)
@@ -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);
        ///
index 718e9af3a1290eb832c1c626082851c49e67f78c..0cfe5f91fe0e68b7277bc5e6216b03a8065a55fd 100644 (file)
@@ -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;
                                }
                        }