]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_extern.C
enable direct input of #1...#9; some whitespace changes
[lyx.git] / src / mathed / math_extern.C
index ae162c54356a8b98a0032664261b0925a35ccf3f..6751dd405ad13aeaaf37ed8732dc9f88e34d0fce 100644 (file)
@@ -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
@@ -607,12 +639,12 @@ void extractDiff(MathArray & ar)
 
                // collect function, let jt point behind last used item
                MathArray::iterator jt = it + 1; 
-               int n = 1; 
+               //int n = 1; 
                MathArray & numer = f->cell(0);
                if (numer.size() > 1 && numer.at(1)->asScriptInset()) {
                        // this is something like  d^n f(x) / d... or  d^n / d...
                        // FIXME
-                       n = 1;  
+                       //n = 1;        
                        if (numer.size() > 2) 
                                diff->cell(0) = MathArray(numer.begin() + 2, numer.end());
                        else
@@ -656,6 +688,8 @@ void extractDiff(MathArray & ar)
        lyxerr << "\nDiffs to: " << ar << "\n";
 }
 
+
+
 //
 // combine searches
 //
@@ -669,6 +703,7 @@ void extractStructure(MathArray & ar)
        extractIntegrals(ar);
        extractSums(ar);
        extractDiff(ar);
+       extractExps(ar);
        extractStrings(ar);
 }
 
@@ -678,11 +713,11 @@ void write(MathArray const & dat, WriteStream & wi)
        MathArray ar = dat;
        extractStrings(ar);
        for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it) {
-               wi.firstitem = (it == ar.begin());
+               wi.firstitem() = (it == ar.begin());
                MathInset const * p = it->nucleus();
                if (it + 1 != ar.end()) {
                        if (MathScriptInset const * q = asScript(it)) {
-                               q->write(p, wi);
+                               q->write2(p, wi);
                                ++it;
                                continue;
                        } 
@@ -707,7 +742,7 @@ void octavize(MathArray const & dat, OctaveStream & os)
                MathInset const * p = it->nucleus();
                if (it + 1 != ar.end()) {
                        if (MathScriptInset const * q = asScript(it)) {
-                               q->octavize(p, os);
+                               q->octavize2(p, os);
                                ++it;   
                                continue;
                        }
@@ -725,7 +760,7 @@ void maplize(MathArray const & dat, MapleStream & os)
                MathInset const * p = it->nucleus();
                if (it + 1 != ar.end()) {
                        if (MathScriptInset const * q = asScript(it)) {
-                               q->maplize(p, os);
+                               q->maplize2(p, os);
                                ++it;   
                                continue;
                        }
@@ -749,7 +784,7 @@ void mathmlize(MathArray const & dat, MathMLStream & os)
                        MathInset const * p = it->nucleus();
                        if (it + 1 != ar.end()) {
                                if (MathScriptInset const * q = asScript(it)) {
-                                       q->mathmlize(p, os);
+                                       q->mathmlize2(p, os);
                                        ++it;   
                                        continue;
                                }