X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_macrotable.C;h=885bd5b3b3738e00df1d4d466397937c7348cea7;hb=7338f3b980d4dc5793ff80be814b7a74e1c72274;hp=c7cc1a4819b6f1dfc49889e19dd30369ad6c95ef;hpb=7e7a1070393277f5b298dcd5e2a42dc5ca4e23ed;p=lyx.git diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index c7cc1a4819..885bd5b3b3 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -1,22 +1,26 @@ -#include - -#include +/** + * \file math_macrotable.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author André Pönitz + * + * Full author contact details are available in file CREDITS. + */ -#ifdef __GNUG__ -#pragma implementation -#endif +#include #include "math_macrotable.h" #include "math_macro.h" #include "math_macrotemplate.h" #include "math_parser.h" -#include "math_fracinset.h" -#include "math_cheatinset.h" -#include "math_charinset.h" +#include "math_mathmlstream.h" #include "debug.h" +#include "math_support.h" // math_font_available +#include -MathArray mathed_parse_cell(string const &); +using std::endl; MathMacroTable::table_type MathMacroTable::macro_table; @@ -24,94 +28,36 @@ MathMacroTable::table_type MathMacroTable::macro_table; void MathMacroTable::dump() { - lyxerr << "\n------------------------------------------\n"; +/* + lyxerr << "\n------------------------------------------" << endl; table_type::const_iterator it; for (it = macro_table.begin(); it != macro_table.end(); ++it) - lyxerr << it->first << " [" << it->second.nargs() << "] : " - << it->second << "\n"; - lyxerr << "------------------------------------------\n"; + lyxerr << it->first + << " [" << it->second->asMacroTemplate()->nargs() << "] : " + << it->second->cell(0) << endl; + lyxerr << "------------------------------------------" << endl; +*/ } -void MathMacroTable::insertTemplate(MathMacroTemplate const & p) +MathAtom & MathMacroTable::provide(string const & name) { - if (macro_table.find(p.name()) != macro_table.end()) - lyxerr << "macro '" << p.name() << "' not new\n"; - macro_table[p.name()] = p; -} - - -MathMacroTemplate & MathMacroTable::provideTemplate(string const & name) -{ - builtinMacros(); - table_type::iterator pos = macro_table.find(name); - if (pos == macro_table.end()) { lyxerr << "MathMacroTable::provideTemplate: no template with name '" - << name << "' available.\n"; + << name << "' available." << endl; } - return pos->second; } -void MathMacroTable::createTemplate - (string const & name, int na, string const & text) +void MathMacroTable::create(MathAtom const & at) { - MathMacroTemplate t(name, na); - t.cell(0) = mathed_parse_cell(text); - insertTemplate(t); + macro_table[at->asMacroTemplate()->name()] = at; } -bool MathMacroTable::hasTemplate(string const & name) +bool MathMacroTable::has(string const & name) { - builtinMacros(); return macro_table.find(name) != macro_table.end(); } - - -MathMacro * MathMacroTable::cloneTemplate(string const & name) -{ - return new MathMacro(provideTemplate(name)); -} - - -void MathMacroTable::builtinMacros() -{ - static bool built = false; - - if (built) - return; - - built = true; - //lyxerr[Debug::MATHED] << "Building macros\n"; - - createTemplate("emptyset", 0, "\\not0"); - createTemplate("ne", 0, "\\not="); - createTemplate("ge", 0, "\\geq"); - createTemplate("gets", 0, "\\leftarrow"); - createTemplate("land", 0, "\\wedge"); - createTemplate("le", 0, "\\leq"); - createTemplate("lor", 0, "\\vee"); - createTemplate("notin", 0, "\\not\\in"); - createTemplate("perp", 0, "\\bot"); - createTemplate("owns", 0, "\\ni"); - createTemplate("to", 0, "\\rightarrow"); - //createTemplate("lint", 4, "\\int_#1^#2#3 d#4"); - //createTemplate("silentmult", 0, "\\cdot"); - //createTemplate("binom", 2, "\\left(\\frac#1#2\\right)"); - - MathMacroTemplate ll("ll", 0); - ll.cell(0).push_back(new MathCharInset('<', LM_TC_CONST)); - ll.cell(0).push_back(new MathCheatInset(-0.9)); - ll.cell(0).push_back(new MathCharInset('<', LM_TC_CONST)); - insertTemplate(ll); - - MathMacroTemplate gg("gg", 0); - gg.cell(0).push_back(new MathCharInset('>', LM_TC_CONST)); - gg.cell(0).push_back(new MathCheatInset(-0.9)); - gg.cell(0).push_back(new MathCharInset('>', LM_TC_CONST)); - insertTemplate(gg); -}