]> git.lyx.org Git - features.git/commitdiff
Correctly classify macros
authorEnrico Forestieri <forenr@lyx.org>
Sat, 24 Sep 2016 23:11:16 +0000 (01:11 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Sat, 24 Sep 2016 23:11:16 +0000 (01:11 +0200)
Some macros defined in the lib/symbols file are classified are texmode.
But the MathMacro class was missing a currentMode method for returning
this information.

src/mathed/MathMacro.cpp
src/mathed/MathMacro.h

index e1484e81b11708d4c42645e72483236db568427d..d1a8b50c7b69233d2bd4ed43521edfd5b0615661 100644 (file)
@@ -614,9 +614,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
                drawMarkers2(pi, expx, expy);
        } else {
                bool drawBox = lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_INLINE_BOX;
-               bool user_macro = !MacroTable::globalMacros().get(name());
-               bool upshape = user_macro ? false : d->macro_ && d->macro_->symbol()
-                               && d->macro_->symbol()->extra == "textmode";
+               bool upshape = currentMode() == TEXT_MODE;
                Changer dummy = pi.base.font.changeShape(upshape ? UP_SHAPE
                                                        : pi.base.font.shape());
 
@@ -753,6 +751,17 @@ size_t MathMacro::appetite() const
 }
 
 
+InsetMath::mode_type MathMacro::currentMode() const
+{
+       // User defined macros are always assumed to be mathmode macros.
+       // Only the global macros defined in lib/symbols may be textmode.
+
+       MacroData const * data = MacroTable::globalMacros().get(name());
+       bool textmode = data && data->symbol() && data->symbol()->extra == "textmode";
+       return textmode ? TEXT_MODE : MATH_MODE;
+}
+
+
 void MathMacro::validate(LaTeXFeatures & features) const
 {
        // Immediately after a document is loaded, in some cases the MacroData
index b389e272e4b2f3aa4ff3bad1799c19876f4d03ef..1a8654ac4035a9c671990aaf9d61269df5ef754e 100644 (file)
@@ -70,6 +70,8 @@ public:
 
        ///
        void validate(LaTeXFeatures &) const;
+       ///
+       mode_type currentMode() const;
 
        ///
        void write(WriteStream & os) const;