math_kerninset.h \
math_lefteqninset.C \
math_lefteqninset.h \
+ math_liminset.C \
+ math_liminset.h \
math_macro.C \
math_macro.h \
math_macroarg.C \
os << ')';
}
+
void MathDiffInset::mathematicize(MathematicaStream & os) const
{
os << "Dt[";
#include "math_exfuncinset.h"
#include "math_exintinset.h"
#include "math_fracinset.h"
+#include "math_liminset.h"
#include "math_matrixinset.h"
#include "math_mathmlstream.h"
#include "math_numberinset.h"
void extractFunctions(MathArray & ar)
{
// we need at least two items...
- if (ar.size() <= 1)
+ if (ar.size() < 2)
return;
//lyxerr << "\nFunctions from: " << ar << "\n";
void extractIntegrals(MathArray & ar)
{
// we need at least three items...
- if (ar.size() <= 2)
+ if (ar.size() < 3)
return;
//lyxerr << "\nIntegrals from: " << ar << "\n";
// search sums
//
-bool testSumSymbol(MathInset * p)
-{
- return testSymbol(p, "sum");
-}
-
bool testEqualSign(MathAtom const & at)
{
void extractSums(MathArray & ar)
{
// we need at least two items...
- if (ar.size() <= 1)
+ if (ar.size() < 2)
return;
//lyxerr << "\nSums from: " << ar << "\n";
- for (MathArray::size_type i = 0; i + 1< ar.size(); ++i) {
+ for (MathArray::size_type i = 0; i + 1 < ar.size(); ++i) {
MathArray::iterator it = ar.begin() + i;
// is this a sum name?
- if (!testSumSymbol(it->nucleus()))
+ if (!testSymbol(it->nucleus(), "sum"))
continue;
// create a proper inset as replacement
}
+//
+// search limits
+//
+
+
+bool testRightArrow(MathAtom const & at)
+{
+ return
+ testSymbol(at.nucleus(), "to") ||
+ testSymbol(at.nucleus(), "rightarrow");
+}
+
+
+
+// replace '\lim_{x->x0} f(x)' sequences by a real MathLimInset
+// assume 'extractDelims' ran before
+void extractLims(MathArray & ar)
+{
+ // we need at least three items...
+ if (ar.size() < 3)
+ return;
+
+ //lyxerr << "\nLimits from: " << ar << "\n";
+ for (MathArray::size_type i = 0; i + 2 < ar.size(); ++i) {
+ MathArray::iterator it = ar.begin() + i;
+
+ // is this a limit function?
+ if (!testSymbol(it->nucleus(), "lim"))
+ continue;
+
+ // the next one must be a subscript (without superscript)
+ MathScriptInset * sub = (*(it + 1))->asScriptInset();
+ if (!sub || !sub->hasDown() || sub->hasUp())
+ continue;
+
+ // and it must contain a -> symbol
+ MathArray & s = sub->down().data();
+ MathArray::iterator st = find_if(s.begin(), s.end(), &testRightArrow);
+ if (st == s.end())
+ continue;
+
+ // the -> splits the subscript int x and x0
+ MathArray x = MathArray(s, 0, st - s.begin());
+ MathArray x0 = MathArray(s, st - s.begin() + 1, s.size());
+
+ // use something behind the script as core
+ MathArray f;
+ MathArray::iterator tt = extractArgument(f, it + 2, ar.end());
+
+ // create a proper inset as replacement
+ MathLimInset * p = new MathLimInset(f, x, x0);
+
+ // cleanup
+ ar.erase(it + 1, tt);
+ (*it).reset(p);
+ }
+ //lyxerr << "\nLimits to: " << ar << "\n";
+}
+
//
// combine searches
extractSums(ar);
extractDiff(ar);
extractExps(ar);
+ extractLims(ar);
extractStrings(ar);
}
--- /dev/null
+#include "math_liminset.h"
+#include "math_support.h"
+#include "math_mathmlstream.h"
+#include "math_symbolinset.h"
+#include "debug.h"
+
+
+MathLimInset::MathLimInset
+ (MathArray const & f, MathArray const & x, MathArray const & x0)
+ : MathNestInset(3)
+{
+ cell(0) = f;
+ cell(1) = x;
+ cell(2) = x0;
+}
+
+
+MathInset * MathLimInset::clone() const
+{
+ return new MathLimInset(*this);
+}
+
+
+void MathLimInset::normalize(NormalStream & os) const
+{
+ os << "[lim " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
+}
+
+
+void MathLimInset::metrics(MathMetricsInfo &) const
+{
+ lyxerr << "should not happen\n";
+}
+
+
+void MathLimInset::draw(MathPainterInfo &, int, int) const
+{
+ lyxerr << "should not happen\n";
+}
+
+
+void MathLimInset::maplize(MapleStream & os) const
+{
+ os << "limit(" << cell(0) << ',' << cell(1) << '=' << cell(2) << ')';
+}
+
+
+void MathLimInset::mathematicize(MathematicaStream & os) const
+{
+ os << "Lim[" << cell(0) << ',' << cell(1) << ',' << cell(2) << ']';
+}
+
+
+void MathLimInset::mathmlize(MathMLStream & os) const
+{
+ os << "lim(" << cell(0) << ',' << cell(1) << ',' << cell(2) << ')';
+}
+
+
+void MathLimInset::write(WriteStream &) const
+{
+ lyxerr << "should not happen\n";
+}
--- /dev/null
+// -*- C++ -*-
+#ifndef MATH_LIMINSET_H
+#define MATH_LIMINSET_H
+
+// lim_{x->x0} f(x) in one block
+// for interfacing external programs
+
+#include "math_nestinset.h"
+
+class MathLimInset : public MathNestInset {
+public:
+ ///
+ MathLimInset(MathArray const & f, MathArray const & x, MathArray const & x0);
+ ///
+ MathInset * clone() const;
+ ///
+ void metrics(MathMetricsInfo & mi) const;
+ ///
+ void draw(MathPainterInfo & pi, int x, int y) const;
+
+ ///
+ void normalize(NormalStream &) const;
+ ///
+ void maplize(MapleStream &) const;
+ ///
+ void mathematicize(MathematicaStream &) const;
+ ///
+ void mathmlize(MathMLStream &) const;
+ ///
+ void write(WriteStream & os) const;
+};
+
+#endif
// fontmath.ltx
- define("\\def\\lnot{\\neg}");
- define("\\def\\land{\\wedge}");
- define("\\def\\lor{\\vee}");
- define("\\def\\ne{\\neq}");
- define("\\def\\le{\\leq}");
- define("\\def\\ge{\\geq}");
- define("\\def\\owns{\\ni}");
- define("\\def\\gets{\\leftarrow}");
- define("\\def\\to{\\rightarrow}");
- define("\\def\\|{\\Vert}");
-
define("\\def\\longleftrightarrow{\\leftarrow\\kern-8mu\\rightarrow}");
define("\\def\\Longleftrightarrow{\\Leftarrow\\kern-8mu\\Rightarrow}");
define("\\def\\doteq{\\stackrel{\\cdot}{\\=}}");
define("\\def\\dashrightarrow{\\lyxdabar\\lyxdabar\\lyxright}");
define("\\def\\dashleftarrow{\\lyxleft\\lyxdabar\\lyxdabar}");
define("\\def\\dasharrow{\\dashrightarrow}");
- define("\\def\\Box{\\square}");
- define("\\def\\Diamond{\\lozenge}");
define("\\def\\leadsto{\\rightsquigarrow}");
// amssymb.sty
define("\\def\\Doteq{\\doteqdot}");
define("\\def\\doublecup{\\Cup}");
define("\\def\\doublecap{\\Cap}");
- define("\\def\\llless{\\lll}");
- define("\\def\\gggtr{\\ggg}");
//}
//if (math_font_available(LM_TC_MSB)) {