]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathParser.cpp
Years forgotten files.
[lyx.git] / src / mathed / MathParser.cpp
index 1982af3c86c47b2b2e85f59fb367d4a1c9a654c0..05ceed80f251bf6d78f210276f8a03e8cf8b1b01 100644 (file)
@@ -56,9 +56,11 @@ following hack as starting point to write some macros:
 #include "InsetMathRef.h"
 #include "InsetMathRoot.h"
 #include "InsetMathScript.h"
+#include "InsetMathSideset.h"
 #include "InsetMathSpace.h"
 #include "InsetMathSplit.h"
 #include "InsetMathSqrt.h"
+#include "InsetMathStackrel.h"
 #include "InsetMathString.h"
 #include "InsetMathTabular.h"
 #include "MathMacroTemplate.h"
@@ -1441,6 +1443,45 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
                }
 
+               else if (t.cs() == "sideset") {
+                       // Here allowed formats are \sideset{_{bl}^{tl}}{_{br}^{tr}}{operator}
+                       MathData ar[2];
+                       InsetMathScript * script[2] = {0, 0};
+                       for (int i = 0; i < 2; ++i) {
+                               parse(ar[i], FLAG_ITEM, mode);
+                               if (ar[i].size() == 1)
+                                       script[i] = ar[i][0].nucleus()->asScriptInset();
+                       }
+                       bool const hasscript[2] = {script[0] ? true : false, script[1] ? true : false};
+                       cell->push_back(MathAtom(new InsetMathSideset(buf, hasscript[0], hasscript[1])));
+                       if (hasscript[0]) {
+                               if (script[0]->hasDown())
+                                       cell->back().nucleus()->cell(1) = script[0]->down();
+                               if (script[0]->hasUp())
+                                       cell->back().nucleus()->cell(2) = script[0]->up();
+                       } else
+                               cell->back().nucleus()->cell(1) = ar[0];
+                       if (hasscript[1]) {
+                               if (script[1]->hasDown())
+                                       cell->back().nucleus()->cell(2 + hasscript[0]) = script[1]->down();
+                               if (script[1]->hasUp())
+                                       cell->back().nucleus()->cell(3 + hasscript[0]) = script[1]->up();
+                       } else
+                               cell->back().nucleus()->cell(2 + hasscript[0]) = ar[1];
+                       parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+               }
+
+               else if (t.cs() == "stackrel") {
+                       // Here allowed formats are \stackrel[subscript]{superscript}{operator}
+                       MathData ar;
+                       parse(ar, FLAG_OPTION, mode);
+                       cell->push_back(MathAtom(new InsetMathStackrel(buf, !ar.empty())));
+                       if (!ar.empty())
+                               cell->back().nucleus()->cell(2) = ar;
+                       parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+                       parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
+               }
+
                else if (t.cs() == "xrightarrow" || t.cs() == "xleftarrow") {
                        cell->push_back(createInsetMath(t.cs(), buf));
                        parse(cell->back().nucleus()->cell(1), FLAG_OPTION, mode);