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