/// Whether the inset allows \(no)limits
bool allowsLimitsChange() const { return mathClass() == MC_OP; }
- /// The default limits value
- virtual Limits defaultLimits() const { return NO_LIMITS; }
+ /// The default limits value depending on whether display mode is on
+ virtual Limits defaultLimits(bool /* display */) const { return NO_LIMITS; }
/// whether the inset has limit-like sub/superscript
virtual Limits limits() const { return AUTO_LIMITS; }
/// sets types of sub/superscripts
}
+Limits InsetMathClass::defaultLimits(bool display) const
+{
+ if (allowsLimitsChange() && display)
+ return LIMITS;
+ else
+ return NO_LIMITS;
+}
+
+
void InsetMathClass::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(0).metrics(mi, dim);
}
+void InsetMathClass::write(WriteStream & os) const
+{
+ InsetMathNest::write(os);
+ writeLimits(os);
+}
+
+
docstring InsetMathClass::name() const
{
return class_to_string(math_class_);
docstring name() const override;
///
MathClass mathClass() const override { return math_class_; }
+ /// The default limits value in \c display style
+ Limits defaultLimits(bool display) const override;
+ /// whether the inset has limit-like sub/superscript
+ Limits limits() const override { return limits_; }
+ /// sets types of sub/superscripts
+ void limits(Limits lim) override { limits_ = lim; }
///
void metrics(MetricsInfo & mi, Dimension & dim) const override;
///
void draw(PainterInfo & pi, int x, int y) const override;
///
+ void write(WriteStream & os) const override;
+ ///
void infoize(odocstream & os) const override;
///
InsetCode lyxCode() const override { return MATH_CLASS_CODE; }
Inset * clone() const override;
///
MathClass math_class_;
+ ///
+ Limits limits_ = AUTO_LIMITS;
};
}
+Limits InsetMathDecoration::defaultLimits(bool display) const
+{
+ if (allowsLimitsChange() && display)
+ return LIMITS;
+ else
+ return NO_LIMITS;
+}
+
+
bool InsetMathDecoration::protect() const
{
return
void infoize(odocstream & os) const override;
///
MathClass mathClass() const override;
- /// The default limits value
- Limits defaultLimits() const override { return allowsLimitsChange() ? LIMITS : NO_LIMITS; }
+ /// The default limits value in \c display style
+ Limits defaultLimits(bool display) const override;
/// whether the inset has limit-like sub/superscript
Limits limits() const override { return limits_; }
/// sets types of sub/superscripts
}
-Limits InsetMathMacro::defaultLimits() const
+Limits InsetMathMacro::defaultLimits(bool display) const
{
if (d->expanded_.empty())
return NO_LIMITS;
// Guess from the expanded macro
InsetMath const * in = d->expanded_.back().nucleus();
Limits const lim = in->limits() == AUTO_LIMITS
- ? in->defaultLimits() : in->limits();
+ ? in->defaultLimits(display) : in->limits();
LATTEST(lim != AUTO_LIMITS);
return lim;
}
/// Whether the inset allows \(no)limits
bool allowsLimitsChange() const;
/// The default limits value
- Limits defaultLimits() const override;
+ Limits defaultLimits(bool display) const override;
/// whether the inset has limit-like sub/superscript
Limits limits() const override;
/// sets types of sub/superscripts
in->limits(NO_LIMITS);
else
in->limits(AUTO_LIMITS);
- } else if (in->limits() == AUTO_LIMITS)
- in->limits(in->defaultLimits() == LIMITS ? NO_LIMITS : LIMITS);
- else
+ } else if (in->limits() != AUTO_LIMITS)
in->limits(AUTO_LIMITS);
+ else if (in->defaultLimits(cur.cell().displayStyle()) == LIMITS)
+ in->limits(NO_LIMITS);
+ else
+ in->limits(LIMITS);
return;
}
}
+Limits InsetMathScript::limits() const
+{
+ if (nuc().empty())
+ return AUTO_LIMITS;
+ else
+ // only the limits status of the last element counts
+ return nuc().back()->limits();
+}
+
+
+void InsetMathScript::limits(Limits lim)
+{
+ if (!nuc().empty())
+ nuc().back()->limits(lim);
+}
+
+
MathClass InsetMathScript::mathClass() const
{
// FIXME: this is a hack, since the class will not be correct if
bool InsetMathScript::hasLimits(FontInfo const & font) const
{
- if (font.style() != DISPLAY_STYLE)
- return false;
if (nuc().empty())
return false;
Limits const lim = nuc().back()->limits() == AUTO_LIMITS
- ? nuc().back()->defaultLimits() : nuc().back()->limits();
+ ? nuc().back()->defaultLimits(font.style() == DISPLAY_STYLE)
+ : nuc().back()->limits();
LASSERT(lim != AUTO_LIMITS, return false);
return lim == LIMITS;
}
InsetMathScript(Buffer * buf, MathAtom const & at, bool up);
///
mode_type currentMode() const override { return MATH_MODE; }
+ /// whether the inset has limit-like sub/superscript
+ Limits limits() const override;
+ /// sets types of sub/superscripts
+ void limits(Limits lim) override;
///
MathClass mathClass() const override;
///
/// The default limits value
-Limits InsetMathSymbol::defaultLimits() const
+Limits InsetMathSymbol::defaultLimits(bool display) const
{
- return (allowsLimitsChange() && sym_->extra != "func")
- ? LIMITS : NO_LIMITS;
+ if (allowsLimitsChange() && sym_->extra != "func" && display)
+ return LIMITS;
+ else
+ return NO_LIMITS;
}
///
bool isOrdAlpha() const;
/// The default limits value
- Limits defaultLimits() const override;
+ Limits defaultLimits(bool display) const override;
/// whether the inset has limit-like sub/superscript
Limits limits() const override { return limits_; }
/// sets types of sub/superscripts
{
bool has_contents = false;
BufferView * bv = mi.base.bv;
+ display_style_ = mi.base.font.style() == DISPLAY_STYLE;
MathData * ar = const_cast<MathData*>(this);
ar->updateMacros(&bv->cursor(), mi.macrocontext,
InternalUpdate, mi.base.macro_nesting);
MathClass mathClass() const;
/// math class of last interesting element
MathClass lastMathClass() const;
+ /// is the cell in display style
+ bool displayStyle() const { return display_style_; }
/// access to cached x coordinate of last drawing
int xo(BufferView const & bv) const;
mutable int mindes_ = 0;
mutable int slevel_ = 0;
mutable int sshift_ = 0;
+ /// cached value for display style
+ mutable bool display_style_ = false;
Buffer * buffer_ = nullptr;
private: