]> git.lyx.org Git - features.git/commitdiff
Fix bug #4565: Using keyboard shortcuts to write Greek letters with an underbar produ...
authorEnrico Forestieri <forenr@lyx.org>
Wed, 31 Mar 2010 01:09:38 +0000 (01:09 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Wed, 31 Mar 2010 01:09:38 +0000 (01:09 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33963 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathDecoration.cpp
src/mathed/InsetMathDecoration.h

index a5e333e308c8ba017dae148c27c8bb7297dc0270..f10cc4c13d4fcf74108119c92398bcc5b45a823e 100644 (file)
@@ -96,8 +96,17 @@ bool InsetMathDecoration::wide() const
 }
 
 
+InsetMath::mode_type InsetMathDecoration::currentMode() const
+{
+       return key_->name == "underbar" ? TEXT_MODE : MATH_MODE;
+}
+
+
 void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const
 {
+       FontSetChanger dummy(mi.base, currentMode() == TEXT_MODE ?
+                               "textnormal" : "mathnormal");
+
        cell(0).metrics(mi, dim);
 
        dh_  = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
@@ -117,6 +126,9 @@ void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const
 
 void InsetMathDecoration::draw(PainterInfo & pi, int x, int y) const
 {
+       FontSetChanger dummy(pi.base, currentMode() == TEXT_MODE ?
+                               "textnormal" : "mathnormal");
+
        cell(0).draw(pi, x + 1, y);
        Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
        if (wide())
@@ -134,7 +146,9 @@ void InsetMathDecoration::write(WriteStream & os) const
        MathEnsurer ensurer(os);
        if (os.fragile() && protect())
                os << "\\protect";
-       os << '\\' << key_->name << '{' << cell(0) << '}';
+       os << '\\' << key_->name << '{';
+       ModeSpecifier specifier(os, currentMode());
+       os << cell(0) << '}';
 }
 
 
index adabcd7c04425d6637e2a88f3fdee77983aec810..9e58065ee3f8c76bcc9106edf2c495c317f97088 100644 (file)
@@ -26,6 +26,8 @@ public:
        ///
        explicit InsetMathDecoration(Buffer * buf, latexkeys const * key);
        ///
+       mode_type currentMode() const;
+       ///
        void draw(PainterInfo &, int x, int y) const;
        ///
        void write(WriteStream & os) const;