From 0e793113cae88c3ff67881d1bfebf0ac889662a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 15 Nov 2001 15:14:27 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3033 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 5 +++++ src/mathed/formula.C | 1 + src/mathed/math_extern.C | 33 +++++++++++++++++++++++++++++++++ src/mathed/math_funcinset.C | 28 ++++++++++++++-------------- src/mathed/math_stringinset.C | 22 +++++++++++----------- 5 files changed, 64 insertions(+), 25 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index c02865ed51..dabc4ff5be 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,8 @@ + +2001-11-07 André Pönitz + + * math_extern.C: support for integrals, sums, e^x, and d/dx + 2001-11-15 Jean-Marc Lasgouttes * math_extern.C (extractNumber): diff --git a/src/mathed/formula.C b/src/mathed/formula.C index a4441609b2..0ef83f5d8b 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -505,6 +505,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action, bool needEqnArray(string const & extra) { + return false; return extra == "dsolve"; } diff --git a/src/mathed/math_extern.C b/src/mathed/math_extern.C index ae162c5435..ff48405a75 100644 --- a/src/mathed/math_extern.C +++ b/src/mathed/math_extern.C @@ -293,6 +293,38 @@ void splitScripts(MathArray & ar) } +// +// extract exp(...) +// + +void extractExps(MathArray & ar) +{ + lyxerr << "\nExps from: " << ar << "\n"; + + for (MathArray::size_type i = 0; i + 1 < ar.size(); ++i) { + MathArray::iterator it = ar.begin() + i; + + // is this 'e'? + MathCharInset const * p = (*it)->asCharInset(); + if (!p || p->getChar() != 'e') + continue; + + // we need an exponent but no subscript + MathScriptInset * sup = (*(it + 1))->asScriptInset(); + if (!sup || sup->hasDown()) + continue; + + // create a proper exp-inset as replacement + MathExFuncInset * func = new MathExFuncInset("exp"); + func->cell(0) = sup->cell(1); + + // clean up + (*it).reset(func); + ar.erase(it + 1); + } + lyxerr << "\nExps to: " << ar << "\n"; +} + // // search deliminiters @@ -669,6 +701,7 @@ void extractStructure(MathArray & ar) extractIntegrals(ar); extractSums(ar); extractDiff(ar); + extractExps(ar); extractStrings(ar); } diff --git a/src/mathed/math_funcinset.C b/src/mathed/math_funcinset.C index c2bf78c277..b8cf2d1829 100644 --- a/src/mathed/math_funcinset.C +++ b/src/mathed/math_funcinset.C @@ -36,18 +36,6 @@ void MathFuncInset::setName(string const & n) } -void MathFuncInset::write(WriteStream & os) const -{ - os << "\\" << name_.c_str() << ' '; -} - - -void MathFuncInset::normalize(NormalStream & os) const -{ - os << "[func " << name_.c_str() << ']'; -} - - void MathFuncInset::metrics(MathMetricsInfo const & mi) const { mi_ = mi; @@ -63,7 +51,7 @@ void MathFuncInset::draw(Painter & pain, int x, int y) const void MathFuncInset::maplize(MapleStream & os) const { - os << name_.c_str(); + os << ' ' << name_.c_str(); } @@ -75,5 +63,17 @@ void MathFuncInset::mathmlize(MathMLStream & os) const void MathFuncInset::octavize(OctaveStream & os) const { - os << name_.c_str(); + os << ' ' << name_.c_str(); +} + + +void MathFuncInset::normalize(NormalStream & os) const +{ + os << "[func " << name_.c_str() << ']'; +} + + +void MathFuncInset::write(WriteStream & os) const +{ + os << "\\" << name_.c_str() << ' '; } diff --git a/src/mathed/math_stringinset.C b/src/mathed/math_stringinset.C index 6a41af3cd9..901a513584 100644 --- a/src/mathed/math_stringinset.C +++ b/src/mathed/math_stringinset.C @@ -59,15 +59,6 @@ void MathStringInset::draw(Painter & pain, int x, int y) const } -void MathStringInset::write(WriteStream & os) const -{ - if (math_font_name(code_)) - os << '\\' << math_font_name(code_) << '{' << str_.c_str() << '}'; - else - os << str_.c_str(); -} - - void MathStringInset::normalize(NormalStream & os) const { os << "[string " << str_.c_str() << ' ' << "mathalpha" << "]"; @@ -77,7 +68,7 @@ void MathStringInset::normalize(NormalStream & os) const void MathStringInset::maplize(MapleStream & os) const { if (code_ != LM_TC_VAR || str_.size() <= 1) { - os << str_.c_str(); + os << ' ' << str_.c_str() << ' '; return; } @@ -91,7 +82,7 @@ void MathStringInset::maplize(MapleStream & os) const void MathStringInset::octavize(OctaveStream & os) const { if (code_ != LM_TC_VAR || str_.size() <= 1) { - os << str_.c_str(); + os << ' ' << str_.c_str() << ' '; return; } @@ -113,3 +104,12 @@ void MathStringInset::mathmlize(MathMLStream & os) const else os << str_.c_str(); } + + +void MathStringInset::write(WriteStream & os) const +{ + if (math_font_name(code_)) + os << '\\' << math_font_name(code_) << '{' << str_.c_str() << '}'; + else + os << str_.c_str(); +} -- 2.39.2