]> git.lyx.org Git - lyx.git/blob - src/mathed/math_factory.C
some visual support for \lefteqn
[lyx.git] / src / mathed / math_factory.C
1 #include <config.h>
2
3 #include "math_parser.h"
4 #include "math_binominset.h"
5 #include "math_decorationinset.h"
6 #include "math_dotsinset.h"
7 #include "math_funcinset.h"
8 #include "math_funcliminset.h"
9 #include "math_fracinset.h"
10 #include "math_kerninset.h"
11 #include "math_lefteqninset.h"
12 #include "math_macro.h"
13 #include "math_macrotable.h"
14 #include "math_macroarg.h"
15 #include "math_notinset.h"
16 #include "math_rootinset.h"
17 #include "math_spaceinset.h"
18 #include "math_specialcharinset.h"
19 #include "math_sqrtinset.h"
20 #include "math_symbolinset.h"
21 #include "math_stackrelinset.h"
22
23
24 MathAtom createMathInset(latexkeys const * l)
25 {
26         switch (l->token) {
27         case LM_TK_FUNCLIM:
28                 return MathAtom(new MathFuncLimInset(l));
29         case LM_TK_SPECIAL:
30                 return MathAtom(new MathSpecialCharInset(l->id));
31         case LM_TK_SYM:
32         case LM_TK_CMR:
33         case LM_TK_CMSY:
34         case LM_TK_CMM:
35         case LM_TK_CMEX:
36         case LM_TK_MSA:
37         case LM_TK_MSB:
38                 return MathAtom(new MathSymbolInset(l));
39         case LM_TK_STACK:
40                 return MathAtom(new MathStackrelInset);
41         case LM_TK_KERN: 
42                 return MathAtom(new MathKernInset);
43         case LM_TK_BINOM:
44         case LM_TK_CHOOSE:
45                 return MathAtom(new MathBinomInset);
46         case LM_TK_OVER:
47         case LM_TK_FRAC:
48                 return MathAtom(new MathFracInset);
49         case LM_TK_ATOP:
50                 return MathAtom(new MathFracInset(true));
51         case LM_TK_NOT:
52                 return MathAtom(new MathNotInset);
53         case LM_TK_LEFTEQN:
54                 return MathAtom(new MathLefteqnInset);
55         case LM_TK_SQRT:
56                 return MathAtom(new MathSqrtInset);
57         case LM_TK_ROOT:
58                 return MathAtom(new MathRootInset);
59         case LM_TK_DECORATION:
60                 return MathAtom(new MathDecorationInset(l->name));
61         case LM_TK_SPACE:
62                 return MathAtom(new MathSpaceInset(l->id));
63         case LM_TK_DOTS:
64                 return MathAtom(new MathDotsInset(l->name));
65         }
66         return MathAtom(new MathFuncInset(l->name));
67 }
68
69
70 MathAtom createMathInset(string const & s)
71 {
72         //cerr << "creating inset with name: '" << s << "'\n";
73         if (s.size() == 2 && s[0] == '#' && s[1] >= '1' && s[1] <= '9')
74                 return MathAtom(new MathMacroArgument(s[1] - '0'));
75
76         if (s.size() == 3 && s[0] == '\\' && s[1] == '#' && s[2] >= '1' && s[2] <= '9')
77                 return MathAtom(new MathMacroArgument(s[2] - '0'));
78
79         latexkeys const * l = in_word_set(s);
80         if (l)
81                 return createMathInset(l);
82
83         if (MathMacroTable::has(s)) 
84                 return MathAtom(new MathMacro(s));
85
86         return MathAtom(new MathFuncInset(s));
87 }