]> git.lyx.org Git - lyx.git/blob - src/mathed/command_inset.C
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / command_inset.C
1
2 #include "command_inset.h"
3 #include "math_mathmlstream.h"
4 #include "funcrequest.h"
5
6
7 CommandInset::CommandInset(string const & data)
8 {
9         lock_ = true;
10
11         string::size_type idx0 = data.find("|++|");
12         name_ = data.substr(0, idx0);
13         if (idx0 == string::npos)
14                 return;
15         idx0 += 4;
16         string::size_type idx1 = data.find("|++|", idx0);
17         cell(0) = asArray(data.substr(idx0, idx1 - idx0));
18         if (idx1 == string::npos)
19                 return;
20         cell(1) = asArray(data.substr(idx1 + 4));
21 }
22
23
24 MathInset * CommandInset::clone() const
25 {
26         return new CommandInset(*this);
27 }
28
29
30 dispatch_result
31 CommandInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
32 {
33         switch (cmd.action) {
34                 default:
35                         return ButtonInset::dispatch(cmd, idx, pos);
36         }
37         return UNDISPATCHED;
38 }
39
40
41 void CommandInset::write(WriteStream & os) const
42 {
43         os << '\\' << name_.c_str();
44         if (cell(1).size())
45                 os << '[' << cell(1) << ']';
46         os << '{' << cell(0) << '}';
47 }
48
49
50 string CommandInset::screenLabel() const
51 {
52         return name_;
53 }