Jean-Marc,

please consider putting this into 1.3.4cvs.

The mathcursor.C part fixes a hard crash in certain situations when
selecting up/down close to subscript insets...

The rest is the new 'boldsymbol' inset. Should be non-intrusive.

Andre'
Index: Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/Makefile.am,v
retrieving revision 1.110
diff -u -p -r1.110 Makefile.am
--- Makefile.am 24 Sep 2002 18:20:26 -0000      1.110
+++ Makefile.am 30 Sep 2003 08:16:51 -0000
@@ -27,6 +27,8 @@ libmathed_la_SOURCES = \
        math_biginset.h \
        math_binominset.C \
        math_binominset.h \
+       math_boldsymbolinset.C \
+       math_boldsymbolinset.h \
        math_boxinset.C \
        math_boxinset.h \
        math_braceinset.C \
Index: math_boldsymbolinset.C
===================================================================
RCS file: math_boldsymbolinset.C
diff -N math_boldsymbolinset.C
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ math_boldsymbolinset.C      30 Sep 2003 08:16:51 -0000
@@ -0,0 +1,77 @@
+/**
+ * \file math_boldsymbolinset.C
+ * 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 "math_boldsymbolinset.h"
+#include "math_mathmlstream.h"
+#include "math_data.h"
+#include "LaTeXFeatures.h"
+#include "support/LOstream.h"
+
+
+MathBoldsymbolInset::MathBoldsymbolInset()
+       : MathNestInset(1)
+{}
+
+
+MathInset * MathBoldsymbolInset::clone() const
+{
+       return new MathBoldsymbolInset(*this);
+}
+
+
+void MathBoldsymbolInset::metrics(MathMetricsInfo & mi) const
+{
+       //FontSetChanger dummy(mi.base, "mathbf");
+       dim_ = cell(0).metrics(mi);
+       metricsMarkers(1);
+       ++dim_.w;  // for 'double stroke'
+}
+
+
+void MathBoldsymbolInset::draw(MathPainterInfo & pi, int x, int y) const
+{
+       //FontSetChanger dummy(pi.base, "mathbf");
+       cell(0).draw(pi, x + 1, y);
+       cell(0).draw(pi, x + 2, y);
+       drawMarkers(pi, x, y);
+}
+
+
+void MathBoldsymbolInset::metricsT(TextMetricsInfo const & mi) const
+{
+       dim_ = cell(0).metricsT(mi);
+}
+
+
+void MathBoldsymbolInset::drawT(TextPainter & pain, int x, int y) const
+{
+       cell(0).drawT(pain, x, y);
+}
+
+
+void MathBoldsymbolInset::validate(LaTeXFeatures & features) const
+{
+       MathNestInset::validate(features);
+       features.require("amssymb");
+}
+
+
+void MathBoldsymbolInset::write(WriteStream & os) const
+{
+       os << "\\boldsymbol{" << cell(0) << "}";
+}
+
+
+void MathBoldsymbolInset::infoize(std::ostream & os) const
+{
+       os << "Boldsymbol ";
+}
Index: math_boldsymbolinset.h
===================================================================
RCS file: math_boldsymbolinset.h
diff -N math_boldsymbolinset.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ math_boldsymbolinset.h      30 Sep 2003 08:16:51 -0000
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+/**
+ * \file math_boldsymbolinset.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_BOLDSYMBOLINSET_H
+#define MATH_BOLDSYMBOLINSET_H
+
+#include "math_nestinset.h"
+
+
+/// Inset for AMSTeX's \boldsymbol 
+class MathBoldsymbolInset : public MathNestInset {
+public:
+       ///
+       MathBoldsymbolInset();
+       ///
+       MathInset * clone() const;
+       ///
+       void metrics(MathMetricsInfo & mi) const;
+       ///
+       void draw(MathPainterInfo & pi, int x, int y) const;
+       ///
+       void metricsT(TextMetricsInfo const & mi) const;
+       ///
+       void drawT(TextPainter & pi, int x, int y) const;
+       ///
+       void validate(LaTeXFeatures & features) const;
+       ///
+       void write(WriteStream & os) const;
+       ///
+       void infoize(std::ostream & os) const;
+};
+
+#endif
Index: math_cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_cursor.C,v
retrieving revision 1.333
diff -u -p -r1.333 math_cursor.C
--- math_cursor.C       7 Jan 2003 11:24:42 -0000       1.333
+++ math_cursor.C       30 Sep 2003 08:16:51 -0000
@@ -932,28 +932,30 @@ bool MathCursor::goUpDown(bool up)
                xo = targetx_;
 
        // try neigbouring script insets
-       // try left
-       if (hasPrevAtom()) {
-               MathScriptInset const * p = prevAtom()->asScriptInset();
-               if (p && p->has(up)) {
-                       --pos();
-                       push(nextAtom());
-                       idx() = up; // the superscript has index 1
-                       pos() = size();
-                       ///lyxerr << "updown: handled by scriptinset to the left\n";
-                       return true;
+       if (!selection()) {
+               // try left
+               if (hasPrevAtom()) {
+                       MathScriptInset const * p = prevAtom()->asScriptInset();
+                       if (p && p->has(up)) {
+                               --pos();
+                               push(nextAtom());
+                               idx() = up; // the superscript has index 1
+                               pos() = size();
+                               ///lyxerr << "updown: handled by scriptinset to the 
left\n";
+                               return true;
+                       }
                }
-       }
 
-       // try right
-       if (hasNextAtom()) {
-               MathScriptInset const * p = nextAtom()->asScriptInset();
-               if (p && p->has(up)) {
-                       push(nextAtom());
-                       idx() = up;
-                       pos() = 0;
-                       ///lyxerr << "updown: handled by scriptinset to the right\n";
-                       return true;
+               // try right
+               if (hasNextAtom()) {
+                       MathScriptInset const * p = nextAtom()->asScriptInset();
+                       if (p && p->has(up)) {
+                               push(nextAtom());
+                               idx() = up;
+                               pos() = 0;
+                               ///lyxerr << "updown: handled by scriptinset to the 
right\n";
+                               return true;
+                       }
                }
        }
 
Index: math_factory.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_factory.C,v
retrieving revision 1.70
diff -u -p -r1.70 math_factory.C
--- math_factory.C      18 Dec 2002 22:15:59 -0000      1.70
+++ math_factory.C      30 Sep 2003 08:16:51 -0000
@@ -9,6 +9,7 @@
 #include "math_amsarrayinset.h"
 #include "math_binominset.h"
 #include "math_boxinset.h"
+#include "math_boldsymbolinset.h"
 #include "math_casesinset.h"
 #include "math_decorationinset.h"
 #include "math_dotsinset.h"
@@ -292,6 +293,8 @@ MathAtom createMathInset(string const & 
                return MathAtom(new MathLefteqnInset);
        if (s == "lyxert")
                return MathAtom(new MathErtInset);
+       if (s == "boldsymbol")
+               return MathAtom(new MathBoldsymbolInset);
 
        if (MathMacroTable::has(s))
                return MathAtom(new MathMacro(s));

Reply via email to