]> git.lyx.org Git - lyx.git/blob - src/mathed/command_inset.C
7af795e341579f13602379b87a6f0b1f85d9b13f
[lyx.git] / src / mathed / command_inset.C
1
2 #include "command_inset.h"
3 #include "math_mathmlstream.h"
4
5
6 CommandInset::CommandInset(string const & data)
7 {
8         lock_ = true;
9
10         string::size_type idx0 = data.find("|++|");
11         name_ = data.substr(0, idx0);
12         if (idx0 == string::npos)
13                 return;
14         idx0 += 4;
15         string::size_type idx1 = data.find("|++|", idx0);
16         cell(0) = asArray(data.substr(idx0, idx1 - idx0));
17         if (idx1 == string::npos)
18                 return;
19         cell(1) = asArray(data.substr(idx1 + 4));
20 }
21
22
23 MathInset * CommandInset::clone() const
24 {
25         return new CommandInset(*this);
26 }
27
28
29 void CommandInset::write(WriteStream & os) const
30 {
31         os << "\\" << name_.c_str();
32         if (cell(1).size())
33                 os << "[" << cell(1) << "]";
34         os << "{" << cell(0) << "}";
35 }
36
37
38 string CommandInset::screenLabel() const
39 {
40         return name_;
41 }