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
This commit is contained in:
Jean-Marc Lasgouttes 2002-02-28 15:07:11 +00:00
parent 3026a589b0
commit cfffe11571
4 changed files with 24 additions and 14 deletions

View 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

View 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();

View 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);
///

View File

@ -642,18 +642,9 @@ void LyXText::incDepth(BufferView * bview)
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 (cursor.par()->getDepth()
< prev->getMaxDepthAfter(bview->buffer())){
cursor.par()->params().depth(cursor.par()->getDepth() + 1);
anything_changed = true;
}
}