From ba496b94acc56d41595d266bfdc4cce669006e4b Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Wed, 12 Mar 2008 14:33:16 +0000 Subject: [PATCH] Merge InsetMathBoldSymbol and InsetMathBM by providing \boldsymbol through the bm package. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23684 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/scons/scons_manifest.py | 2 - lib/bind/cua.bind | 1 + lib/bind/mac.bind | 1 + src/LaTeXFeatures.cpp | 6 -- src/Makefile.am | 2 - src/mathed/InsetMathBM.cpp | 86 ----------------------------- src/mathed/InsetMathBM.h | 47 ---------------- src/mathed/InsetMathBoldSymbol.cpp | 24 ++++++-- src/mathed/InsetMathBoldSymbol.h | 8 ++- src/mathed/InsetMathHull.cpp | 1 - src/mathed/MathFactory.cpp | 9 ++- 11 files changed, 32 insertions(+), 155 deletions(-) delete mode 100644 src/mathed/InsetMathBM.cpp delete mode 100644 src/mathed/InsetMathBM.h diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index 7f921de18b..269dd0fdde 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -453,7 +453,6 @@ src_mathed_header_files = Split(''' InsetMathAMSArray.h InsetMathArray.h InsetMathBig.h - InsetMathBM.h InsetMathBoldSymbol.h InsetMathBox.h InsetMathBrace.h @@ -522,7 +521,6 @@ src_mathed_files = Split(''' InsetMathAMSArray.cpp InsetMathArray.cpp InsetMathBig.cpp - InsetMathBM.cpp InsetMathBoldSymbol.cpp InsetMathBox.cpp InsetMathBrace.cpp diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind index 93b42cfa19..1fbe955301 100644 --- a/lib/bind/cua.bind +++ b/lib/bind/cua.bind @@ -55,6 +55,7 @@ \bind "C-Prior" "buffer-previous" \bind "C-S-Tab" "buffer-previous" +\bind "C-M-b" "math-insert \mathbf" \bind "C-b" "font-bold" \bind "C-e" "font-emph" # used below for line-delete-forward diff --git a/lib/bind/mac.bind b/lib/bind/mac.bind index 8aff298fe2..a540c90a5b 100644 --- a/lib/bind/mac.bind +++ b/lib/bind/mac.bind @@ -42,6 +42,7 @@ \bind "M-Tab" "buffer-next" \bind "M-S-BackTab" "buffer-previous" +\bind "C-M-b" "math-insert \mathbf" \bind "C-b" "font-bold" \bind "C-e" "font-emph" \bind "C-k" "font-noun" # 'k' for capitals diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 60769c3a3a..4b47083660 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -136,10 +136,6 @@ static string const floatingfootnote_def = " \\expandafter\\noexpand\\csname SF@gobble@opt \\endcsname}\n" "\\def\\SF@gobble@twobracket[#1]#2{}\n"; -static string const boldsymbol_def = - "%% Bold symbol macro for standard LaTeX users\n" - "\\providecommand{\\boldsymbol}[1]{\\mbox{\\boldmath $#1$}}\n"; - static string const binom_def = "%% Binom macro for standard LaTeX users\n" "\\newcommand{\\binom}[2]{{#1 \\choose #2}}\n"; @@ -664,8 +660,6 @@ string const LaTeXFeatures::getMacros() const macros << guillemotright_def << '\n'; // Math mode - if (mustProvide("boldsymbol") && !isRequired("amsmath")) - macros << boldsymbol_def << '\n'; if (mustProvide("binom") && !isRequired("amsmath")) macros << binom_def << '\n'; if (mustProvide("mathcircumflex")) diff --git a/src/Makefile.am b/src/Makefile.am index 9c77897119..cc907b5407 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -329,7 +329,6 @@ SOURCEFILESMATHED = \ mathed/InsetMathAMSArray.cpp \ mathed/InsetMathArray.cpp \ mathed/InsetMathBig.cpp \ - mathed/InsetMathBM.cpp \ mathed/InsetMathBoldSymbol.cpp \ mathed/InsetMathBox.cpp \ mathed/InsetMathBrace.cpp \ @@ -395,7 +394,6 @@ HEADERFILESMATHED = \ mathed/InsetMathAMSArray.h \ mathed/InsetMathArray.h \ mathed/InsetMathBig.h \ - mathed/InsetMathBM.h \ mathed/InsetMathBoldSymbol.h \ mathed/InsetMathBox.h \ mathed/InsetMathBrace.h \ diff --git a/src/mathed/InsetMathBM.cpp b/src/mathed/InsetMathBM.cpp deleted file mode 100644 index 9001ea8473..0000000000 --- a/src/mathed/InsetMathBM.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/** - * \file InsetMathBM.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Bernhard Roider - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "InsetMathBM.h" - -#include "MathStream.h" -#include "MathData.h" -#include "LaTeXFeatures.h" - -#include - - -namespace lyx { - -InsetMathBM::InsetMathBM() - : InsetMathNest(1) -{} - - -Inset * InsetMathBM::clone() const -{ - return new InsetMathBM(*this); -} - - -void InsetMathBM::metrics(MetricsInfo & mi, Dimension & dim) const -{ - //FontSetChanger dummy(mi.base, "mathbf"); - cell(0).metrics(mi, dim); - metricsMarkers(dim); - ++dim.wid; // for 'double stroke' -} - - -void InsetMathBM::draw(PainterInfo & 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 InsetMathBM::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) const -{ - // FIXME: BROKEN! - Dimension dim; - cell(0).metricsT(mi, dim); -} - - -void InsetMathBM::drawT(TextPainter & pain, int x, int y) const -{ - cell(0).drawT(pain, x, y); -} - - -void InsetMathBM::validate(LaTeXFeatures & features) const -{ - InsetMathNest::validate(features); - features.require("bm"); -} - - -void InsetMathBM::write(WriteStream & os) const -{ - os << "\\bm{" << cell(0) << "}"; -} - - -void InsetMathBM::infoize(odocstream & os) const -{ - os << "bm "; -} - - -} // namespace lyx diff --git a/src/mathed/InsetMathBM.h b/src/mathed/InsetMathBM.h deleted file mode 100644 index 5192930b28..0000000000 --- a/src/mathed/InsetMathBM.h +++ /dev/null @@ -1,47 +0,0 @@ -// -*- C++ -*- -/** - * \file InsetMathBM.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Bernhard Roider - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef MATH_BMINSET_H -#define MATH_BMINSET_H - -#include "InsetMathNest.h" - - -namespace lyx { - - -/// Inset for \bm -class InsetMathBM : public InsetMathNest { -public: - /// - InsetMathBM(); - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// - void draw(PainterInfo & pi, int x, int y) const; - /// - void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; - /// - void drawT(TextPainter & pi, int x, int y) const; - /// - void validate(LaTeXFeatures & features) const; - /// - void write(WriteStream & os) const; - /// - void infoize(odocstream & os) const; -private: - virtual Inset * clone() const; -}; - - -} // namespace lyx - -#endif diff --git a/src/mathed/InsetMathBoldSymbol.cpp b/src/mathed/InsetMathBoldSymbol.cpp index 45ed5355ef..7a7e5ece76 100644 --- a/src/mathed/InsetMathBoldSymbol.cpp +++ b/src/mathed/InsetMathBoldSymbol.cpp @@ -21,8 +21,8 @@ namespace lyx { -InsetMathBoldSymbol::InsetMathBoldSymbol() - : InsetMathNest(1) +InsetMathBoldSymbol::InsetMathBoldSymbol(Kind kind) + : InsetMathNest(1), kind_(kind) {} @@ -67,19 +67,33 @@ void InsetMathBoldSymbol::drawT(TextPainter & pain, int x, int y) const void InsetMathBoldSymbol::validate(LaTeXFeatures & features) const { InsetMathNest::validate(features); - features.require("amssymb"); + features.require("bm"); } void InsetMathBoldSymbol::write(WriteStream & os) const { - os << "\\boldsymbol{" << cell(0) << "}"; + switch (kind_) { + case BOLD: + os << "\\boldsymbol{" << cell(0) << "}"; + break; + case HEAVY: + os << "\\heavysymbol{" << cell(0) << "}"; + break; + } } void InsetMathBoldSymbol::infoize(odocstream & os) const { - os << "Boldsymbol "; + switch (kind_) { + case BOLD: + os << "Boldsymbol "; + break; + case HEAVY: + os << "Heavysymbol "; + break; + } } diff --git a/src/mathed/InsetMathBoldSymbol.h b/src/mathed/InsetMathBoldSymbol.h index 80e0e43da7..0a998b149e 100644 --- a/src/mathed/InsetMathBoldSymbol.h +++ b/src/mathed/InsetMathBoldSymbol.h @@ -21,8 +21,12 @@ namespace lyx { /// Inset for AMSTeX's \boldsymbol class InsetMathBoldSymbol : public InsetMathNest { public: + enum Kind { + BOLD, + HEAVY + }; /// - InsetMathBoldSymbol(); + InsetMathBoldSymbol(Kind kind = BOLD); /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// @@ -37,6 +41,8 @@ public: void write(WriteStream & os) const; /// void infoize(odocstream & os) const; + /// + Kind kind_; private: virtual Inset * clone() const; }; diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index c4d9d7481a..e8db74d582 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -570,7 +570,6 @@ void InsetMathHull::validate(LaTeXFeatures & features) const //if (features.amsstyle) // return; - features.require("boldsymbol"); //features.binom = true; InsetMathGrid::validate(features); diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index b1e73b2a3a..fbd9ffabe3 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -14,7 +14,6 @@ #include "InsetMathAMSArray.h" #include "InsetMathArray.h" -#include "InsetMathBM.h" #include "InsetMathBoldSymbol.h" #include "InsetMathBox.h" #include "InsetMathCases.h" @@ -376,10 +375,10 @@ MathAtom createInsetMath(docstring const & s) return MathAtom(new InsetMathFrac(InsetMathFrac::ATOP)); if (s == "lefteqn") return MathAtom(new InsetMathLefteqn); - if (s == "boldsymbol") - return MathAtom(new InsetMathBoldSymbol); - if (s == "bm") - return MathAtom(new InsetMathBM); + if (s == "boldsymbol" || s == "bm") + return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::BOLD)); + if (s == "heavysymbol" || s == "hm") + return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::HEAVY)); if (s == "color" || s == "normalcolor") return MathAtom(new InsetMathColor(true)); if (s == "textcolor") -- 2.39.2