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
}
+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();
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);
///
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;
}
}