]> git.lyx.org Git - features.git/commitdiff
more math-extern
authorAndré Pönitz <poenitz@gmx.net>
Fri, 9 Nov 2001 14:48:57 +0000 (14:48 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 9 Nov 2001 14:48:57 +0000 (14:48 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2998 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_exintinset.C [new file with mode: 0644]
src/mathed/math_exintinset.h [new file with mode: 0644]
src/mathed/math_extern.C

diff --git a/src/mathed/math_exintinset.C b/src/mathed/math_exintinset.C
new file mode 100644 (file)
index 0000000..2ad11b3
--- /dev/null
@@ -0,0 +1,54 @@
+#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) << ')';
+}
diff --git a/src/mathed/math_exintinset.h b/src/mathed/math_exintinset.h
new file mode 100644 (file)
index 0000000..c92497a
--- /dev/null
@@ -0,0 +1,38 @@
+// -*- 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
index e944e6ab4e2d1596ee0e3c485a39ae461dbff1db..947ce0ebc54c2357f5bd318ccdaf563c5c8cab53 100644 (file)
@@ -7,6 +7,7 @@
 #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"
@@ -114,7 +115,7 @@ typedef bool TestItemFunc(MathInset *);
 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,
@@ -150,7 +151,7 @@ void replaceNested(
                        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;
 
@@ -164,19 +165,23 @@ void replaceNested(
 } 
 
 
-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;
@@ -187,11 +192,17 @@ MathInset * replaceByDelimInset(const MathArray & 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)
@@ -241,19 +252,31 @@ 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)
@@ -267,19 +290,19 @@ 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);
        }
 }