X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_macrotable.C;h=885bd5b3b3738e00df1d4d466397937c7348cea7;hb=7338f3b980d4dc5793ff80be814b7a74e1c72274;hp=d6436c9d51aca29dab116833841142f3a0e26f29;hpb=1c77a120de8a2ed328d3700f9af75bfebe36793c;p=lyx.git diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index d6436c9d51..885bd5b3b3 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -1,10 +1,14 @@ -#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" @@ -14,6 +18,10 @@ #include "debug.h" #include "math_support.h" // math_font_available +#include + +using std::endl; + MathMacroTable::table_type MathMacroTable::macro_table; @@ -21,136 +29,35 @@ 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->asMacroTemplate()->nargs() << "] : " - << it->second->cell(0) << "\n"; - lyxerr << "------------------------------------------\n"; + << it->second->cell(0) << endl; + lyxerr << "------------------------------------------" << endl; */ } MathAtom & MathMacroTable::provide(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::create(string const & name, int na) +void MathMacroTable::create(MathAtom const & at) { - macro_table[name] = MathAtom(new MathMacroTemplate(name, na)); -} - - -void MathMacroTable::create - (string const & name, int na, MathArray const & ar1, MathArray const & ar2) -{ - MathAtom t(new MathMacroTemplate(name, na)); - t->cell(0) = ar1; - t->cell(1) = ar2; - macro_table[name] = t; -} - - -void MathMacroTable::define(string const & def) -{ - string name; - mathed_parse_macro(name, def); + macro_table[at->asMacroTemplate()->name()] = at; } bool MathMacroTable::has(string const & name) { - builtinMacros(); return macro_table.find(name) != macro_table.end(); } - - -void MathMacroTable::builtinMacros() -{ - static bool built = false; - - if (built) - return; - - built = true; - //lyxerr[Debug::MATHED] << "Building macros\n"; - //define("\\def\\emptyset{\\not0}"); - define("\\def\\notin{\\not\\in}"); - define("\\def\\slash{/}"); - - // fontmath.ltx - - define("\\def\\lnot{\\neg}"); - define("\\def\\land{\\wedge}"); - define("\\def\\lor{\\vee}"); - define("\\def\\ne{\\neq}"); - define("\\def\\le{\\leq}"); - define("\\def\\ge{\\geq}"); - define("\\def\\owns{\\ni}"); - define("\\def\\gets{\\leftarrow}"); - define("\\def\\to{\\rightarrow}"); - define("\\def\\|{\\Vert}"); - - define("\\def\\longleftrightarrow{\\leftarrow\\kern-8mu\\rightarrow}"); - define("\\def\\Longleftrightarrow{\\Leftarrow\\kern-8mu\\Rightarrow}"); - define("\\def\\doteq{\\stackrel{\\cdot}{\\=}}"); - - if (math_font_available(LM_TC_CMSY)) { - define("\\def\\longrightarrow{\\lyxbar\\kern-6mu\\rightarrow}"); - define("\\def\\longleftarrow{\\leftarrow\\kern-6mu\\lyxbar}"); - define("\\def\\mapsto{\\mapstochar\\kern-4mu\\rightarrow}"); - define("\\def\\longmapsto{\\mapstochar\\kern-3mu\\lyxbar\\kern-6mu\\rightarrow}"); - } - - if (math_font_available(LM_TC_CMR) && math_font_available(LM_TC_CMSY)) { - define("\\def\\Longrightarrow{\\lyxeq\\kern-5mu\\Rightarrow}"); - define("\\def\\Longleftarrow{\\Leftarrow\\kern-5mu\\lyxeq}"); - define("\\def\\models{\\vert\\kern-3mu\\lyxeq}"); - } - - if (math_font_available(LM_TC_CMM)) { - define("\\def\\hookrightarrow{\\lhook\\kern-8mu\\rightarrow}"); - define("\\def\\hookleftarrow{\\leftarrow\\kern-8mu\\rhook}"); - define("\\def\\bowtie{\\triangleright\\kern-2mu\\triangleleft}"); - } - - if (math_font_available(LM_TC_MSA)) { - //amsfonts.sty - - define("\\def\\dashrightarrow{\\lyxdabar\\lyxdabar\\lyxright}"); - define("\\def\\dashleftarrow{\\lyxleft\\lyxdabar\\lyxdabar}"); - define("\\def\\dasharrow{\\dashrightarrow}"); - define("\\def\\Box{\\square}"); - define("\\def\\Diamond{\\lozenge}"); - define("\\def\\leadsto{\\rightsquigarrow}"); - - // amssymb.sty - - define("\\def\\restriction{\\upharpoonright}"); - define("\\def\\Doteq{\\doteqdot}"); - define("\\def\\doublecup{\\Cup}"); - define("\\def\\doublecap{\\Cap}"); - define("\\def\\llless{\\lll}"); - define("\\def\\gggtr{\\ggg}"); - } - - if (math_font_available(LM_TC_MSB)) { - define("\\def\\Join{\\ltimes\\kern-12mu\\rtimes}"); - } - - //define("\def\lint", 4, "\\int_#1^#2#3 d#4}"); - //define("\\def\\silentmult{\\cdot}"); - //define("\def\binom", 2, "\\left(\\frac#1#2\\right)}"); -}