]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathString.C
cursor is no more damaging the background. L-shaped cursor is broken right now....
[lyx.git] / src / mathed / InsetMathString.C
1 /**
2  * \file InsetMathString.C
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 "InsetMathString.h"
14 #include "MathStream.h"
15 #include "MathStream.h"
16 #include "MathSupport.h"
17
18
19 namespace lyx {
20
21 using std::auto_ptr;
22 using std::vector;
23
24
25 InsetMathString::InsetMathString(docstring const & s)
26         : str_(s)
27 {}
28
29
30 auto_ptr<InsetBase> InsetMathString::doClone() const
31 {
32         return auto_ptr<InsetBase>(new InsetMathString(*this));
33 }
34
35
36 void InsetMathString::metrics(MetricsInfo & mi, Dimension & dim) const
37 {
38         mathed_string_dim(mi.base.font, str_, dim);
39 }
40
41
42 void InsetMathString::draw(PainterInfo & pi, int x, int y) const
43 {
44         pi.draw(x, y, str_);
45 }
46
47
48 void InsetMathString::normalize(NormalStream & os) const
49 {
50         os << "[string " << str_ << ' ' << "mathalpha" << ']';
51 }
52
53
54 void InsetMathString::maple(MapleStream & os) const
55 {
56         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
57                 os << ' ' << str_ << ' ';
58                 return;
59         }
60
61         // insert '*' between adjacent chars if type is LM_TC_VAR
62         os << str_[0];
63         for (size_t i = 1; i < str_.size(); ++i)
64                 os << str_[i];
65 }
66
67
68 void InsetMathString::mathematica(MathematicaStream & os) const
69 {
70         os << ' ' << str_ << ' ';
71 }
72
73
74 void InsetMathString::octave(OctaveStream & os) const
75 {
76         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
77                 os << ' ' << str_ << ' ';
78                 return;
79         }
80
81         // insert '*' between adjacent chars if type is LM_TC_VAR
82         os << str_[0];
83         for (size_t i = 1; i < str_.size(); ++i)
84                 os << str_[i];
85 }
86
87
88 void InsetMathString::mathmlize(MathStream & os) const
89 {
90 /*
91         if (code_ == LM_TC_VAR)
92                 os << "<mi> " << str_ << " </mi>";
93         else if (code_ == LM_TC_CONST)
94                 os << "<mn> " << str_ << " </mn>";
95         else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
96                 os << "<mtext> " << str_ <<  " </mtext>";
97         else
98 */
99                 os << str_;
100 }
101
102
103 void InsetMathString::write(WriteStream & os) const
104 {
105         os << str_;
106 }
107
108
109 } // namespace lyx