--- /dev/null
+#include "math_exintinset.h"
+#include "math_support.h"
+#include "debug.h"
+#include "math_mathmlstream.h"
+#include "math_symbolinset.h"
+
+
+MathExIntInset::MathExIntInset(MathScriptInset const & scripts,
+ MathArray const & core, MathArray const & diff)
+ : int_(new MathSymbolInset("int")),
+ scripts_(scripts), core_(core), diff_(diff)
+{}
+
+
+MathInset * MathExIntInset::clone() const
+{
+ return new MathExIntInset(*this);
+}
+
+
+void MathExIntInset::write(WriteStream & os) const
+{
+ scripts_.write(int_.nucleus(), os);
+ os << core_ << "d" << diff_;
+}
+
+
+void MathExIntInset::normalize(NormalStream & os) const
+{
+ //os << "[int " << scripts_ << ' ' << core_ << ' ' << diff_ << ']'
+}
+
+
+void MathExIntInset::metrics(MathMetricsInfo const &) const
+{
+ lyxerr << "should not happen\n";
+}
+
+
+void MathExIntInset::draw(Painter &, int, int) const
+{
+ lyxerr << "should not happen\n";
+}
+
+
+void MathExIntInset::maplize(MapleStream & os) const
+{
+ //os << name_.c_str() << '(' << cell(0) << ')';
+}
+
+void MathExIntInset::mathmlize(MathMLStream & os) const
+{
+ //os << name_.c_str() << '(' << cell(0) << ')';
+}
--- /dev/null
+// -*- C++ -*-
+#ifndef MATH_EXINTINSET_H
+#define MATH_EXINTINSET_H
+
+// /\int_l^u f(x) dxin one block (as opposed to 'f','(','x',')' or 'f','x')
+// for interfacing external programs
+
+#include "math_scriptinset.h"
+
+class MathExIntInset : public MathInset {
+public:
+ ///
+ MathExIntInset(MathScriptInset const &, MathArray const &, MathArray const &);
+ ///
+ MathInset * clone() const;
+ ///
+ void metrics(MathMetricsInfo const & st) const;
+ ///
+ void draw(Painter &, int x, int y) const;
+ ///
+ void write(WriteStream & os) const;
+ ///
+ void normalize(NormalStream &) const;
+ ///
+ void maplize(MapleStream &) const;
+ ///
+ void mathmlize(MathMLStream &) const;
+private:
+ ///
+ MathAtom int_;
+ ///
+ MathScriptInset scripts_;
+ ///
+ MathArray core_;
+ ///
+ MathArray diff_;
+};
+#endif
#include "math_charinset.h"
#include "math_deliminset.h"
#include "math_exfuncinset.h"
+#include "math_exintinset.h"
#include "math_funcinset.h"
#include "math_matrixinset.h"
#include "math_mathmlstream.h"
typedef MathInset * ReplaceArgumentFunc(const MathArray & ar);
// search end of nested sequence
-MathArray::iterator searchNestedEnd(
+MathArray::iterator endNestSearch(
MathArray::iterator it,
MathArray::iterator last,
TestItemFunc testOpen,
continue;
// search end of sequence
- MathArray::iterator jt = searchNestedEnd(it, ar.end(), testOpen, testClose);
+ MathArray::iterator jt = endNestSearch(it, ar.end(), testOpen, testClose);
if (jt == ar.end())
continue;
}
-bool testParanOpen(MathInset * p)
+//
+// search deliminiters
+//
+
+bool openParanTest(MathInset * p)
{
return extractString(p) == "(";
}
-bool testParanClose(MathInset * p)
+bool closeParanTest(MathInset * p)
{
return extractString(p) == ")";
}
-MathInset * replaceByDelimInset(const MathArray & ar)
+MathInset * delimReplacement(const MathArray & ar)
{
MathDelimInset * del = new MathDelimInset("(", ")");
del->cell(0) = ar;
// replace '('...')' sequences by a real MathDelimInset
void extractDelims(MathArray & ar) {
lyxerr << "\nDelims from: " << ar << "\n";
- replaceNested(ar, testParanOpen, testParanClose, replaceByDelimInset);
+ replaceNested(ar, openParanTest, closeParanTest, delimReplacement);
lyxerr << "\nDelims to: " << ar << "\n";
}
+
+//
+// search well-known functions
+//
+
+
// replace 'f' '(...)' and 'f' '^n' '(...)' sequences by a real MathExFuncInset
// assume 'extractDelims' ran before
void extractFunctions(MathArray & ar)
}
-bool testIntSymbol(MathInset * p)
+//
+// search integrals
+//
+
+bool intSymbolTest(MathInset * p)
{
return p->asSymbolInset() && p->asSymbolInset()->name() == "int";
}
-bool testSmallD(MathInset * p)
+bool differentialTest(MathInset * p)
{
string s = extractString(p);
return s.size() && s[0] == 'd';
}
+MathInset * intReplacement(const MathArray & ar)
+{
+ MathDelimInset * del = new MathDelimInset("(", ")");
+ del->cell(0) = ar;
+ return del;
+}
+
+
// replace '\int' ['_^'] x 'd''x'(...)' sequences by a real MathExIntInset
// assume 'extractDelims' ran before
void extractIntegrals(MathArray & ar)
MathArray::iterator it = ar.begin() + i;
// is this a integral name?
- if (!testIntSymbol(it->nucleus()))
+ if (!intSymbolTest(it->nucleus()))
continue;
// search 'd'
MathArray::iterator jt =
- searchNestedEnd(it, ar.end(), testIntSymbol, testSmallD);
+ endNestSearch(it, ar.end(), intSymbolTest, differentialTest);
// create a proper inset as replacement
- //MathInset * p = replaceArg(MathArray(it + 1, jt));
+ MathInset * p = intReplacement(MathArray(it + 1, jt));
// replace the original stuff by the new inset
- //ar.erase(it + 1, jt + 1);
- //(*it).reset(p);
+ ar.erase(it + 1, jt + 1);
+ (*it).reset(p);
}
}