The branch, betterspacing, has been updated.

- Log -----------------------------------------------------------------

commit 6f64cdbb07af94480c44b5f93fc660c502b38d1c
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Wed Oct 5 00:25:38 2016 +0200

    Add support for \mathbin and friends
    
    All they do is change the class of the elements that they contain.

diff --git a/src/Makefile.am b/src/Makefile.am
index 44f92db..43037e2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -401,6 +401,7 @@ SOURCEFILESMATHED = \
        mathed/InsetMath.cpp \
        mathed/InsetMathCases.cpp \
        mathed/InsetMathChar.cpp \
+       mathed/InsetMathClass.cpp \
        mathed/InsetMathColor.cpp \
        mathed/InsetMathComment.cpp \
        mathed/InsetMathDecoration.cpp \
@@ -475,6 +476,7 @@ HEADERFILESMATHED = \
        mathed/InsetMathCancelto.h \
        mathed/InsetMathCases.h \
        mathed/InsetMathChar.h \
+       mathed/InsetMathClass.h \
        mathed/InsetMathColor.h \
        mathed/InsetMathComment.h \
        mathed/InsetMathDelim.h \
diff --git a/src/insets/InsetCode.h b/src/insets/InsetCode.h
index 1df6800..7d4632c 100644
--- a/src/insets/InsetCode.h
+++ b/src/insets/InsetCode.h
@@ -235,6 +235,8 @@ enum InsetCode {
        ///
        IPADECO_CODE,
        ///
+       MATH_CLASS_CODE,
+       ///
        INSET_CODE_SIZE
 };
 
diff --git a/src/mathed/InsetMathClass.cpp b/src/mathed/InsetMathClass.cpp
new file mode 100644
index 0000000..10a9600
--- /dev/null
+++ b/src/mathed/InsetMathClass.cpp
@@ -0,0 +1,57 @@
+/**
+ * \file InsetMathClass.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "InsetMathClass.h"
+
+#include "support/docstream.h"
+
+
+namespace lyx {
+
+InsetMathClass::InsetMathClass(Buffer * buf, MathClass mc)
+       : InsetMathNest(buf, 1), math_class_(mc)
+{}
+
+
+Inset * InsetMathClass::clone() const
+{
+       return new InsetMathClass(*this);
+}
+
+
+void InsetMathClass::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       cell(0).metrics(mi, dim);
+       metricsMarkers(dim);
+}
+
+
+void InsetMathClass::draw(PainterInfo & pi, int x, int y) const
+{
+       cell(0).draw(pi, x + 2, y);
+       drawMarkers(pi, x, y);
+}
+
+
+docstring InsetMathClass::name() const
+{
+       return class_to_string(math_class_);
+}
+
+
+void InsetMathClass::infoize(odocstream & os) const
+{
+       os << name() << " ";
+}
+
+
+} // namespace lyx
diff --git a/src/mathed/InsetMathClass.h b/src/mathed/InsetMathClass.h
new file mode 100644
index 0000000..f50040d
--- /dev/null
+++ b/src/mathed/InsetMathClass.h
@@ -0,0 +1,50 @@
+// -*- C++ -*-
+/**
+ * \file InsetMathClass.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef MATH_CLASSINSET_H
+#define MATH_CLASSINSET_H
+
+#include "MathClass.h"
+
+#include "InsetMathNest.h"
+
+
+namespace lyx {
+
+
+/// Support for LaTeX's \\mathxxx class-changing commands
+
+class InsetMathClass : public InsetMathNest {
+public:
+       ///
+       InsetMathClass(Buffer * buf, MathClass);
+       ///
+       docstring name() const;
+       ///
+       MathClass mathClass() const { return math_class_; }
+       ///
+       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       ///
+       void draw(PainterInfo & pi, int x, int y) const;
+       ///
+       void infoize(odocstream & os) const;
+       ///
+       InsetCode lyxCode() const { return MATH_CLASS_CODE; }
+
+private:
+       virtual Inset * clone() const;
+       ///
+       MathClass math_class_;
+};
+
+
+} // namespace lyx
+#endif
diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp
index bb7be8b..f000937 100644
--- a/src/mathed/MathFactory.cpp
+++ b/src/mathed/MathFactory.cpp
@@ -19,6 +19,7 @@
 #include "InsetMathCancel.h"
 #include "InsetMathCancelto.h"
 #include "InsetMathCases.h"
+#include "InsetMathClass.h"
 #include "InsetMathColor.h"
 #include "InsetMathDecoration.h"
 #include "InsetMathDots.h"
@@ -662,10 +663,13 @@ MathAtom createInsetMath(docstring const & s, Buffer * 
buf)
                return MathAtom(new InsetMathSpecialChar(s));
        if (s == " ")
                return MathAtom(new InsetMathSpace(" ", ""));
-
        if (s == "regexp")
                return MathAtom(new InsetMathHull(buf, hullRegexp));
 
+       MathClass const mc = string_to_class(s);
+       if (mc != MC_UNKNOWN)
+               return MathAtom(new InsetMathClass(buf, mc));
+
        return MathAtom(new MathMacro(buf, s));
 }
 

-----------------------------------------------------------------------

Summary of changes:
 src/Makefile.am                                    |    2 +
 src/insets/InsetCode.h                             |    2 +
 src/mathed/InsetMathClass.cpp                      |   57 ++++++++++++++++++++
 .../{InsetMathLefteqn.h => InsetMathClass.h}       |   20 +++++---
 src/mathed/MathFactory.cpp                         |    6 ++-
 5 files changed, 79 insertions(+), 8 deletions(-)
 create mode 100644 src/mathed/InsetMathClass.cpp
 copy src/mathed/{InsetMathLefteqn.h => InsetMathClass.h} (58%)


hooks/post-receive
-- 
Repository for new features

Reply via email to