commit 4cea47d1eb082ed2e957cfe381fe4cdfd951453e
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Thu Jan 12 10:27:41 2017 +0100

    Implement mathClass() for \big and friends
    
    The information here is obtained by reading LaTeX sources.
---
 src/mathed/InsetMathBig.cpp |   23 +++++++++++++++++++++--
 src/mathed/InsetMathBig.h   |    2 ++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathBig.cpp b/src/mathed/InsetMathBig.cpp
index eeaf965..889f8d4 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);
 }
diff --git a/src/mathed/InsetMathBig.h b/src/mathed/InsetMathBig.h
index 996a30a..83010a9 100644
--- a/src/mathed/InsetMathBig.h
+++ b/src/mathed/InsetMathBig.h
@@ -24,6 +24,8 @@ public:
        InsetMathBig(docstring const & name, docstring const & delim);
        ///
        docstring name() const;
+       /// class is different for l(eft), r(ight) and m(iddle)
+       MathClass mathClass() const;
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///

Reply via email to