]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathExFunc.cpp
Account for old versions of Pygments
[lyx.git] / src / mathed / InsetMathExFunc.cpp
1 /**
2  * \file InsetMathExFunc.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathExFunc.h"
14
15 #include "MathData.h"
16 #include "MathStream.h"
17 #include "MathSupport.h"
18 #include "MetricsInfo.h"
19
20 #include "support/docstream.h"
21
22 using namespace std;
23
24 namespace lyx {
25
26
27 InsetMathExFunc::InsetMathExFunc(Buffer * buf, docstring const & name)
28         : InsetMathNest(buf, 1), name_(name)
29 {}
30
31
32 InsetMathExFunc::InsetMathExFunc(Buffer * buf, docstring const & name, MathData const & ar)
33         : InsetMathNest(buf, 1), name_(name)
34 {
35         cell(0) = ar;
36 }
37
38
39 Inset * InsetMathExFunc::clone() const
40 {
41         return new InsetMathExFunc(*this);
42 }
43
44
45 void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const
46 {
47         metricsStrRedBlack(mi, dim, name_);
48 }
49
50
51 void InsetMathExFunc::draw(PainterInfo & pi, int x, int y) const
52 {
53         drawStrBlack(pi, x, y, name_);
54 }
55
56
57 docstring InsetMathExFunc::name() const
58 {
59         return name_;
60 }
61
62
63 void InsetMathExFunc::maple(MapleStream & os) const
64 {
65         if (name_ == "det")
66                 os << "linalg[det](" << cell(0) << ')';
67         else
68                 os << name_ << '(' << cell(0) << ')';
69 }
70
71
72 void InsetMathExFunc::maxima(MaximaStream & os) const
73 {
74         if (name_ == "det")
75                 os << "determinant(" << cell(0) << ')';
76         else
77                 os << name_ << '(' << cell(0) << ')';
78 }
79
80
81 static string asMathematicaName(string const & name)
82 {
83         if (name == "sin")    return "Sin";
84         if (name == "sinh")   return "Sinh";
85         if (name == "arcsin") return "ArcSin";
86         if (name == "asin")   return "ArcSin";
87         if (name == "cos")    return "Cos";
88         if (name == "cosh")   return "Cosh";
89         if (name == "arccos") return "ArcCos";
90         if (name == "acos")   return "ArcCos";
91         if (name == "tan")    return "Tan";
92         if (name == "tanh")   return "Tanh";
93         if (name == "arctan") return "ArcTan";
94         if (name == "atan")   return "ArcTan";
95         if (name == "cot")    return "Cot";
96         if (name == "coth")   return "Coth";
97         if (name == "csc")    return "Csc";
98         if (name == "sec")    return "Sec";
99         if (name == "exp")    return "Exp";
100         if (name == "log")    return "Log";
101         if (name == "ln" )    return "Log";
102         if (name == "arg" )   return "Arg";
103         if (name == "det" )   return "Det";
104         if (name == "gcd" )   return "GCD";
105         if (name == "max" )   return "Max";
106         if (name == "min" )   return "Min";
107         if (name == "erf" )   return "Erf";
108         if (name == "erfc" )  return "Erfc";
109         return name;
110 }
111
112
113 static docstring asMathematicaName(docstring const & name)
114 {
115         return from_utf8(asMathematicaName(to_utf8(name)));
116 }
117
118
119 void InsetMathExFunc::mathematica(MathematicaStream & os) const
120 {
121         os << asMathematicaName(name_) << '[' << cell(0) << ']';
122 }
123
124
125 void InsetMathExFunc::mathmlize(MathStream & os) const
126 {
127         os << "<mi>" << name_ << "</mi><mo>&af;</mo>";
128         os << cell(0);
129 }
130
131
132 void InsetMathExFunc::htmlize(HtmlStream & os) const
133 {
134         os << name_ << cell(0);
135 }
136
137
138 void InsetMathExFunc::octave(OctaveStream & os) const
139 {
140         os << name_ << '(' << cell(0) << ')';
141 }
142
143
144 } // namespace lyx