]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
Fix to bug 2362: Deleting superscript also deletes subscript.
[lyx.git] / src / mathed / math_inset.C
1 /**
2  * \file math_inset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "math_inset.h"
15 #include "math_data.h"
16 #include "math_mathmlstream.h"
17 #include "debug.h"
18
19 #include "support/lstrings.h"
20
21 using std::string;
22 using std::ostream;
23 using std::endl;
24
25
26 MathArray & MathInset::cell(idx_type)
27 {
28         static MathArray dummyCell;
29         lyxerr << "I don't have a cell 1" << endl;
30         return dummyCell;
31 }
32
33
34 MathArray const & MathInset::cell(idx_type) const
35 {
36         static MathArray dummyCell;
37         lyxerr << "I don't have a cell 2" << endl;
38         return dummyCell;
39 }
40
41
42 void MathInset::dump() const
43 {
44         lyxerr << "---------------------------------------------" << endl;
45         WriteStream wi(lyxerr, false, true);
46         write(wi);
47         lyxerr << "\n---------------------------------------------" << endl;
48 }
49
50
51 void MathInset::metricsT(TextMetricsInfo const &, Dimension &) const
52 {
53 #ifdef WITH_WARNINGS
54         lyxerr << "MathInset::metricsT(Text) called directly!" << endl;
55 #endif
56 }
57
58
59 void MathInset::drawT(TextPainter &, int, int) const
60 {
61 #ifdef WITH_WARNINGS
62         lyxerr << "MathInset::drawT(Text) called directly!" << endl;
63 #endif
64 }
65
66
67
68 void MathInset::write(WriteStream & os) const
69 {
70         string const s = name();
71         os << '\\' << s.c_str();
72         // We need an extra ' ' unless this is a single-char-non-ASCII name
73         // or anything non-ASCII follows
74         if (s.size() != 1 || isalpha(s[0]))
75                 os.pendingSpace(true);
76 }
77
78
79 void MathInset::normalize(NormalStream & os) const
80 {
81         os << '[' << name().c_str() << "] ";
82 }
83
84
85 void MathInset::octave(OctaveStream & os) const
86 {
87         NormalStream ns(os.os());
88         normalize(ns);
89 }
90
91
92 void MathInset::maple(MapleStream & os) const
93 {
94         NormalStream ns(os.os());
95         normalize(ns);
96 }
97
98
99 void MathInset::maxima(MaximaStream & os) const
100 {
101         MapleStream ns(os.os());
102         maple(ns);
103 }
104
105
106 void MathInset::mathematica(MathematicaStream & os) const
107 {
108         NormalStream ns(os.os());
109         normalize(ns);
110 }
111
112
113 void MathInset::mathmlize(MathMLStream & os) const
114 {
115         NormalStream ns(os.os());
116         normalize(ns);
117 }
118
119
120 string const & MathInset::getType() const
121 {
122         static string const t = "none";
123         return t;
124 }
125
126
127 string MathInset::name() const
128 {
129         return "unknown";
130 }
131
132
133 ostream & operator<<(ostream & os, MathAtom const & at)
134 {
135         WriteStream wi(os, false, false);
136         at->write(wi);
137         return os;
138 }