}
-/** Check if the current paragraph is the last paragraph in a
- proof environment */
-static int getEndLabel(pit_type p, Text const & text)
-{
- ParagraphList const & pars = text.paragraphs();
- pit_type pit = p;
- depth_type par_depth = pars[p].getDepth();
- while (pit != pit_type(pars.size())) {
- Layout const & layout = pars[pit].layout();
- int const endlabeltype = layout.endlabeltype;
-
- if (endlabeltype != END_LABEL_NO_LABEL) {
- if (p + 1 == pit_type(pars.size()))
- return endlabeltype;
-
- depth_type const next_depth =
- pars[p + 1].getDepth();
- if (par_depth > next_depth ||
- (par_depth == next_depth && layout != pars[p + 1].layout()))
- return endlabeltype;
- break;
- }
- if (par_depth == 0)
- break;
- pit = text.outerHook(pit);
- if (pit != pit_type(pars.size()))
- par_depth = pars[pit].getDepth();
- }
- return END_LABEL_NO_LABEL;
-}
-
-
void RowPainter::paintLast() const
{
- int const endlabel = getEndLabel(row_.pit(), text_);
+ int const endlabel = text_.getEndLabel(row_.pit());
switch (endlabel) {
case END_LABEL_BOX:
case END_LABEL_FILLED_BOX: {
}
+int Text::getEndLabel(pit_type p) const
+{
+ pit_type pit = p;
+ depth_type par_depth = pars_[p].getDepth();
+ while (pit != pit_type(pars_.size())) {
+ Layout const & layout = pars_[pit].layout();
+ int const endlabeltype = layout.endlabeltype;
+
+ if (endlabeltype != END_LABEL_NO_LABEL) {
+ if (p + 1 == pit_type(pars_.size()))
+ return endlabeltype;
+
+ depth_type const next_depth =
+ pars_[p + 1].getDepth();
+ if (par_depth > next_depth ||
+ (par_depth == next_depth && layout != pars_[p + 1].layout()))
+ return endlabeltype;
+ break;
+ }
+ if (par_depth == 0)
+ break;
+ pit = outerHook(pit);
+ if (pit != pit_type(pars_.size()))
+ par_depth = pars_[pit].getDepth();
+ }
+ return END_LABEL_NO_LABEL;
+}
+
+
static void acceptOrRejectChanges(ParagraphList & pars,
BufferParams const & bparams, Text::ChangeOp op)
{
/// Get the font of the "environment" of paragraph \p par_offset in \p pars.
/// All font changes of the paragraph are relative to this font.
Font const outerFont(pit_type pit_offset) const;
+ /// Return the label type at the end of paragraph \c pit.
+ int getEndLabel(pit_type pit) const;
private:
/// The InsetText owner shall have access to everything.
Inset const * inset = 0;
if (par.isNewline(i) || par.isEnvSeparator(i)
|| (i + 1 < end && (inset = par.getInset(i + 1))
- && inset->display())
+ && inset->display())
|| (!row.empty() && row.back().inset
- && row.back().inset->display())) {
+ && row.back().inset->display())) {
row.flushed(true);
- need_new_row = par.isNewline(i);
+ // We will force a row creation after either
+ // - a newline;
+ // - a display inset followed by a end label.
+ need_new_row =
+ par.isNewline(i)
+ || (inset->display() && i + 1 == end
+ && text_->getEndLabel(row.pit()) != END_LABEL_NO_LABEL);
++i;
break;
}