Fix bug #4565: Using keyboard shortcuts to write Greek letters with an underbar produces LaTeX errors.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33963 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2010-03-31 01:09:38 +00:00
parent 33978c0b1b
commit 4fc5f86137
2 changed files with 17 additions and 1 deletions

View 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) << '}';
}

View 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;