X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathBig.cpp;h=889f8d4f97842e2e926a43fca3e2272e15a0da96;hb=9296344b9a26191a2092d175a51e357ecc35145d;hp=76efc571dbf853dcc03a56e10cc2568a1346a8da;hpb=02e82157ec583c3900e359de86be79fac6512387;p=lyx.git diff --git a/src/mathed/InsetMathBig.cpp b/src/mathed/InsetMathBig.cpp index 76efc571db..889f8d4f97 100644 --- a/src/mathed/InsetMathBig.cpp +++ b/src/mathed/InsetMathBig.cpp @@ -39,6 +39,25 @@ docstring InsetMathBig::name() const } +MathClass InsetMathBig::mathClass() const +{ + /* The class of the delimiter depends on the type (l, m, r, nothing). + * For example, the definition of \bigl in LaTeX sources is + * \def\bigl{\mathopen\big} + */ + switch(name_.back()) { + case 'l': + return MC_OPEN; + case 'm': + return MC_REL; + case 'r': + return MC_CLOSE; + default: + return MC_ORD; + } +} + + Inset * InsetMathBig::clone() const { return new InsetMathBig(*this); @@ -49,9 +68,9 @@ InsetMathBig::size_type InsetMathBig::size() const { // order: big Big bigg Bigg biggg Biggg // 0 1 2 3 4 5 - char_type const c = name_[name_.size() - 1]; + char_type const c = name_.back(); int const base_size = (c == 'l' || c == 'm' || c == 'r') ? 4 : 3; - return name_[0] == 'B' ? + return name_.front() == 'B' ? 2 * (name_.size() - base_size) + 1: 2 * (name_.size() - base_size); } @@ -78,18 +97,26 @@ void InsetMathBig::metrics(MetricsInfo & mi, Dimension & dim) const } -void InsetMathBig::draw(PainterInfo & pi, int x, int y) const +docstring InsetMathBig::word() const { - Changer dummy = pi.base.changeEnsureMath(); - Dimension const dim = dimension(*pi.base.bv); // mathed_draw_deco does not use the leading backslash, so remove it // (but don't use ltrim if this is the backslash delimiter). // Replace \| by \Vert (equivalent in LaTeX), since mathed_draw_deco // would treat it as |. - docstring const delim = (delim_ == "\\|") ? from_ascii("Vert") : - (delim_ == "\\\\") ? from_ascii("\\") : support::ltrim(delim_, "\\"); + if (delim_ == "\\|") + return from_ascii("Vert"); + if (delim_ == "\\\\") + return from_ascii("\\"); + return support::ltrim(delim_, "\\"); +} + + +void InsetMathBig::draw(PainterInfo & pi, int x, int y) const +{ + Changer dummy = pi.base.changeEnsureMath(); + Dimension const dim = dimension(*pi.base.bv); mathed_draw_deco(pi, x + 1, y - dim.ascent(), 4, dim.height(), - delim); + word()); } @@ -146,6 +173,7 @@ bool InsetMathBig::isBigInsetDelim(docstring const & delim) "<", ">", "\\\\", "\\backslash", "\\langle", "\\lceil", "\\lfloor", "\\rangle", "\\rceil", "\\rfloor", + "\\llbracket", "\\rrbracket", "\\downarrow", "\\Downarrow", "\\uparrow", "\\Uparrow", "\\updownarrow", "\\Updownarrow", "" @@ -156,6 +184,7 @@ bool InsetMathBig::isBigInsetDelim(docstring const & delim) void InsetMathBig::validate(LaTeXFeatures & features) const { + validate_math_word(features, word()); if (features.runparams().math_flavor == OutputParams::MathAsHTML) features.addCSSSnippet( "span.bigsymbol{font-size: 150%;}\n"