9 #include "math_macrotable.h"
10 #include "math_macro.h"
11 #include "math_macrotemplate.h"
12 #include "math_parser.h"
13 #include "math_fracinset.h"
14 #include "math_cheatinset.h"
15 #include "math_charinset.h"
19 MathArray mathed_parse_cell(string const &);
22 MathMacroTable::table_type MathMacroTable::macro_table;
25 void MathMacroTable::dump()
27 lyxerr << "\n------------------------------------------\n";
28 table_type::const_iterator it;
29 for (it = macro_table.begin(); it != macro_table.end(); ++it)
30 lyxerr << it->first << " [" << it->second.nargs() << "] : "
31 << it->second << "\n";
32 lyxerr << "------------------------------------------\n";
36 void MathMacroTable::insertTemplate(MathMacroTemplate const & p)
38 if (macro_table.find(p.name()) != macro_table.end())
39 lyxerr << "macro '" << p.name() << "' not new\n";
40 macro_table[p.name()] = p;
44 MathMacroTemplate & MathMacroTable::provideTemplate(string const & name)
48 table_type::iterator pos = macro_table.find(name);
50 if (pos == macro_table.end()) {
51 lyxerr << "MathMacroTable::provideTemplate: no template with name '"
52 << name << "' available.\n";
59 void MathMacroTable::createTemplate
60 (string const & name, int na, string const & text)
62 MathMacroTemplate t(name, na);
63 t.cell(0) = mathed_parse_cell(text);
68 bool MathMacroTable::hasTemplate(string const & name)
71 return macro_table.find(name) != macro_table.end();
75 MathMacro * MathMacroTable::cloneTemplate(string const & name)
77 return new MathMacro(provideTemplate(name));
81 void MathMacroTable::builtinMacros()
83 static bool built = false;
89 //lyxerr[Debug::MATHED] << "Building macros\n";
91 createTemplate("emptyset", 0, "\\not0");
92 createTemplate("ne", 0, "\\not=");
93 createTemplate("ge", 0, "\\geq");
94 createTemplate("gets", 0, "\\leftarrow");
95 createTemplate("land", 0, "\\wedge");
96 createTemplate("le", 0, "\\leq");
97 createTemplate("lor", 0, "\\vee");
98 createTemplate("notin", 0, "\\not\\in");
99 createTemplate("perp", 0, "\\bot");
100 createTemplate("owns", 0, "\\ni");
101 createTemplate("to", 0, "\\rightarrow");
102 //createTemplate("lint", 4, "\\int_#1^#2#3 d#4");
103 //createTemplate("silentmult", 0, "\\cdot");
104 //createTemplate("binom", 2, "\\left(\\frac#1#2\\right)");
106 MathMacroTemplate ll("ll", 0);
107 ll.cell(0).push_back(new MathCharInset('<', LM_TC_CONST));
108 ll.cell(0).push_back(new MathCheatInset(-0.9));
109 ll.cell(0).push_back(new MathCharInset('<', LM_TC_CONST));
112 MathMacroTemplate gg("gg", 0);
113 gg.cell(0).push_back(new MathCharInset('>', LM_TC_CONST));
114 gg.cell(0).push_back(new MathCheatInset(-0.9));
115 gg.cell(0).push_back(new MathCharInset('>', LM_TC_CONST));