The attached patch replaces hull types like "simple", "eqnarray" with an
enum 'hullSimple', 'hullEqnArray' etc.
Should save a few CPU cycles, be more typesafe and prevent a controversy
in which string format the type should be stored.
Objections?
Andre'
PS: Opening the current UserGuide with current LyX results in an error:
Traceback (most recent call last):
File "/usr/src/lyx/trunk/lib/lyx2lyx/lyx2lyx", line 21, in ?
import LyX
File "/usr/src/lyx/trunk/lib/lyx2lyx/LyX.py", line 28, in ?
import lyx2lyx_version
ImportError: No module named lyx2lyx_version
Index: mathed/math_inset.h
===================================================================
--- mathed/math_inset.h (revision 14873)
+++ mathed/math_inset.h (working copy)
@@ -19,6 +19,23 @@
#include <string>
+enum HullType {
+ hullNone,
+ hullSimple,
+ hullEquation,
+ hullEqnArray,
+ hullAlign,
+ hullAlignAt,
+ hullXAlignAt,
+ hullXXAlignAt,
+ hullFlAlign,
+ hullMultline,
+ hullGather
+};
+
+HullType hullType(std::string const & name);
+std::string hullName(HullType type);
+
/**
Abstract base class for all math objects. A math insets is for use of the
@@ -171,9 +188,9 @@
/// LyXInset stuff
virtual bool numberedType() const { return false; }
/// hull type
- virtual std::string const & getType() const;
+ virtual HullType getType() const;
/// change type
- virtual void mutate(std::string const &) {}
+ virtual void mutate(HullType &) {}
/// usually the latex name
virtual std::string name() const;
Index: mathed/math_hullinset.C
===================================================================
--- mathed/math_hullinset.C (revision 14873)
+++ mathed/math_hullinset.C (working copy)
@@ -74,21 +74,20 @@
namespace {
- int getCols(string const & type)
+ int getCols(HullType type)
{
- if (type == "eqnarray")
- return 3;
- if (type == "align")
- return 2;
- if (type == "flalign")
- return 2;
- if (type == "alignat")
- return 2;
- if (type == "xalignat")
- return 2;
- if (type == "xxalignat")
- return 2;
- return 1;
+ switch (type) {
+ case hullEqnArray:
+ return 3;
+ case hullAlign:
+ case hullFlAlign:
+ case hullAlignAt:
+ case hullXAlignAt:
+ case hullXXAlignAt:
+ return 2;
+ default:
+ return 1;
+ }
}
@@ -109,35 +108,50 @@
}
- int typecode(string const & s)
- {
- if (s == "none") return 0;
- if (s == "simple") return 1;
- if (s == "equation") return 2;
- if (s == "eqnarray") return 3;
- if (s == "align") return 4;
- if (s == "alignat") return 5;
- if (s == "xalignat") return 6;
- if (s == "xxalignat") return 7;
- if (s == "multline") return 8;
- if (s == "gather") return 9;
- if (s == "flalign") return 10;
- lyxerr << "unknown hull type '" << s << "'" << endl;
- return -1;
- }
+} // end anon namespace
- bool smaller(string const & s, string const & t)
- {
- return typecode(s) < typecode(t);
- }
+HullType hullType(std::string const & s)
+{
+ if (s == "none") return hullNone;
+ if (s == "simple") return hullSimple;
+ if (s == "equation") return hullEquation;
+ if (s == "eqnarray") return hullEqnArray;
+ if (s == "align") return hullAlign;
+ if (s == "alignat") return hullAlignAt;
+ if (s == "xalignat") return hullXAlignAt;
+ if (s == "xxalignat") return hullXXAlignAt;
+ if (s == "multline") return hullMultline;
+ if (s == "gather") return hullGather;
+ if (s == "flalign") return hullFlAlign;
+ lyxerr << "unknown hull type '" << s << "'" << endl;
+ return HullType(-1);
+}
-} // end anon namespace
+std::string hullName(HullType type)
+{
+ switch (type) {
+ case hullNone: return "none";
+ case hullSimple: return "simple";
+ case hullEquation: return "equation";
+ case hullEqnArray: return "eqnarray";
+ case hullAlign: return "align";
+ case hullAlignAt: return "alignat";
+ case hullXAlignAt: return "xalignat";
+ case hullXXAlignAt: return "xxalignat";
+ case hullMultline: return "multline";
+ case hullGather: return "gather";
+ case hullFlAlign: return "flalign";
+ default:
+ lyxerr << "unknown hull type '" << type << "'" << endl;
+ return "none";
+ }
+}
MathHullInset::MathHullInset()
- : MathGridInset(1, 1), type_("none"), nonum_(1), label_(1),
+ : MathGridInset(1, 1), type_(hullNone), nonum_(1), label_(1),
preview_(new RenderPreview(this))
{
//lyxerr << "sizeof MathInset: " << sizeof(MathInset) << endl;
@@ -149,7 +163,7 @@
}
-MathHullInset::MathHullInset(string const & type)
+MathHullInset::MathHullInset(HullType type)
: MathGridInset(getCols(type), 1), type_(type), nonum_(1), label_(1),
preview_(new RenderPreview(this))
{
@@ -201,7 +215,7 @@
MathInset::mode_type MathHullInset::currentMode() const
{
- if (type_ == "none")
+ if (type_ == hullNone)
return UNDECIDED_MODE;
// definitely math mode ...
return MATH_MODE;
@@ -226,9 +240,9 @@
char MathHullInset::defaultColAlign(col_type col)
{
- if (type_ == "eqnarray")
+ if (type_ == hullEqnArray)
return "rcl"[col];
- if (typecode(type_) >= typecode("align"))
+ if (type_ >= hullAlign)
return "rl"[col & 1];
return 'c';
}
@@ -236,11 +250,11 @@
int MathHullInset::defaultColSpace(col_type col)
{
- if (type_ == "align" || type_ == "alignat")
+ if (type_ == hullAlign || type_ == hullAlignAt)
return 0;
- if (type_ == "xalignat")
+ if (type_ == hullXAlignAt)
return (col & 1) ? 20 : 0;
- if (type_ == "xxalignat" || type_ == "flalign")
+ if (type_ == hullXXAlignAt || type_ == hullFlAlign)
return (col & 1) ? 40 : 0;
return 0;
}
@@ -248,7 +262,7 @@
char const * MathHullInset::standardFont() const
{
- return type_ == "none" ? "lyxnochange" : "mathnormal";
+ return type_ == hullNone ? "lyxnochange" : "mathnormal";
}
@@ -427,19 +441,19 @@
bool MathHullInset::ams() const
{
return
- type_ == "align" ||
- type_ == "flalign" ||
- type_ == "multline" ||
- type_ == "gather" ||
- type_ == "alignat" ||
- type_ == "xalignat" ||
- type_ == "xxalignat";
+ type_ == hullAlign ||
+ type_ == hullFlAlign ||
+ type_ == hullMultline ||
+ type_ == hullGather ||
+ type_ == hullAlignAt ||
+ type_ == hullXAlignAt ||
+ type_ == hullXXAlignAt;
}
bool MathHullInset::display() const
{
- return type_ != "simple" && type_ != "none";
+ return type_ != hullSimple && type_ != hullNone;
}
@@ -453,11 +467,11 @@
bool MathHullInset::numberedType() const
{
- if (type_ == "none")
+ if (type_ == hullNone)
return false;
- if (type_ == "simple")
+ if (type_ == hullSimple)
return false;
- if (type_ == "xxalignat")
+ if (type_ == hullXXAlignAt)
return false;
for (row_type row = 0; row < nrows(); ++row)
if (!nonum_[row])
@@ -488,31 +502,32 @@
{
bool n = numberedType();
- if (type_ == "none")
+ if (type_ == hullNone)
;
- else if (type_ == "simple") {
+ else if (type_ == hullSimple) {
os << '$';
if (cell(0).empty())
os << ' ';
}
- else if (type_ == "equation") {
+ else if (type_ == hullEquation) {
if (n)
os << "\\begin{equation" << star(n) << "}\n";
else
os << "\\[\n";
}
- else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign"
- || type_ == "gather" || type_ == "multline")
+ else if (type_ == hullEqnArray || type_ == hullAlign || type_ ==
+hullFlAlign
+ || type_ == hullGather || type_ == hullMultline)
os << "\\begin{" << type_ << star(n) << "}\n";
- else if (type_ == "alignat" || type_ == "xalignat")
+ else if (type_ == hullAlignAt || type_ == hullXAlignAt)
os << "\\begin{" << type_ << star(n) << '}'
<< '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
- else if (type_ == "xxalignat")
+ else if (type_ == hullXXAlignAt)
os << "\\begin{" << type_ << '}'
<< '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
@@ -525,24 +540,25 @@
{
bool n = numberedType();
- if (type_ == "none")
+ if (type_ == hullNone)
os << "\n";
- else if (type_ == "simple")
+ else if (type_ == hullSimple)
os << '$';
- else if (type_ == "equation")
+ else if (type_ == hullEquation)
if (n)
os << "\\end{equation" << star(n) << "}\n";
else
os << "\\]\n";
- else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign"
- || type_ == "alignat" || type_ == "xalignat"
- || type_ == "gather" || type_ == "multline")
+ else if (type_ == hullEqnArray || type_ == hullAlign || type_ ==
+hullFlAlign
+ || type_ == hullAlignAt || type_ == hullXAlignAt
+ || type_ == hullGather || type_ == hullMultline)
os << "\\end{" << type_ << star(n) << "}\n";
- else if (type_ == "xxalignat")
+ else if (type_ == hullXXAlignAt)
os << "\\end{" << type_ << "}\n";
else
@@ -553,18 +569,18 @@
bool MathHullInset::rowChangeOK() const
{
return
- type_ == "eqnarray" || type_ == "align" ||
- type_ == "flalign" || type_ == "alignat" ||
- type_ == "xalignat" || type_ == "xxalignat" ||
- type_ == "gather" || type_ == "multline";
+ type_ == hullEqnArray || type_ == hullAlign ||
+ type_ == hullFlAlign || type_ == hullAlignAt ||
+ type_ == hullXAlignAt || type_ == hullXXAlignAt ||
+ type_ == hullGather || type_ == hullMultline;
}
bool MathHullInset::colChangeOK() const
{
return
- type_ == "align" || type_ == "flalign" ||type_ == "alignat" ||
- type_ == "xalignat" || type_ == "xxalignat";
+ type_ == hullAlign || type_ == hullFlAlign ||type_ ==
hullAlignAt ||
+ type_ == hullXAlignAt || type_ == hullXXAlignAt;
}
@@ -635,7 +651,7 @@
MathArray ar;
for (idx_type i = 0; i < nargs(); ++i)
ar.append(cell(i));
- *this = MathHullInset("simple");
+ *this = MathHullInset(hullSimple);
cell(0) = ar;
setDefaults();
}
@@ -700,21 +716,20 @@
}
-string const & MathHullInset::getType() const
+HullType MathHullInset::getType() const
{
return type_;
}
-void MathHullInset::setType(string const & type)
+void MathHullInset::setType(HullType type)
{
type_ = type;
setDefaults();
}
-
-void MathHullInset::mutate(string const & newtype)
+void MathHullInset::mutate(HullType newtype)
{
//lyxerr << "mutating from '" << type_ << "' to '" << newtype << "'" <<
endl;
@@ -726,56 +741,53 @@
// directly supported because it handles labels and numbering for
// "down mutation".
- if (newtype == "dump") {
- dump();
- }
-
- else if (newtype == type_) {
+ if (newtype == type_) {
// done
}
- else if (typecode(newtype) < 0) {
+ else if (newtype < hullNone) {
// unknown type
+ dump();
}
- else if (type_ == "none") {
- setType("simple");
+ else if (type_ == hullNone) {
+ setType(hullSimple);
numbered(0, false);
mutate(newtype);
}
- else if (type_ == "simple") {
- if (newtype == "none") {
- setType("none");
+ else if (type_ == hullSimple) {
+ if (newtype == hullNone) {
+ setType(hullNone);
numbered(0, false);
} else {
- setType("equation");
+ setType(hullEquation);
numbered(0, false);
mutate(newtype);
}
}
- else if (type_ == "equation") {
- if (smaller(newtype, type_)) {
- setType("simple");
+ else if (type_ == hullEquation) {
+ if (newtype < type_) {
+ setType(hullSimple);
numbered(0, false);
mutate(newtype);
- } else if (newtype == "eqnarray") {
+ } else if (newtype == hullEqnArray) {
// split it "nicely" on the first relop
splitTo3Cols();
- setType("eqnarray");
- } else if (newtype == "multline" || newtype == "gather") {
+ setType(hullEqnArray);
+ } else if (newtype == hullMultline || newtype == hullGather) {
setType(newtype);
} else {
// split it "nicely"
splitTo2Cols();
- setType("align");
+ setType(hullAlign);
mutate(newtype);
}
}
- else if (type_ == "eqnarray") {
- if (smaller(newtype, type_)) {
+ else if (type_ == hullEqnArray) {
+ if (newtype < type_) {
// set correct (no)numbering
bool allnonum = true;
for (row_type row = 0; row < nrows(); ++row)
@@ -797,21 +809,21 @@
mutate(newtype);
} else { // align & Co.
changeCols(2);
- setType("align");
+ setType(hullAlign);
mutate(newtype);
}
}
- else if (type_ == "align" || type_ == "alignat" ||
- type_ == "xalignat" || type_ == "flalign") {
- if (smaller(newtype, "align")) {
+ else if (type_ == hullAlign || type_ == hullAlignAt ||
+ type_ == hullXAlignAt || type_ == hullFlAlign) {
+ if (newtype < hullAlign) {
changeCols(3);
- setType("eqnarray");
+ setType(hullEqnArray);
mutate(newtype);
- } else if (newtype == "gather" || newtype == "multline") {
+ } else if (newtype == hullGather || newtype == hullMultline) {
changeCols(1);
setType(newtype);
- } else if (newtype == "xxalignat") {
+ } else if (newtype == hullXXAlignAt) {
for (row_type row = 0; row < nrows(); ++row)
numbered(row, false);
setType(newtype);
@@ -820,14 +832,14 @@
}
}
- else if (type_ == "xxalignat") {
+ else if (type_ == hullXXAlignAt) {
for (row_type row = 0; row < nrows(); ++row)
numbered(row, false);
- if (smaller(newtype, "align")) {
+ if (newtype < hullAlign) {
changeCols(3);
- setType("eqnarray");
+ setType(hullEqnArray);
mutate(newtype);
- } else if (newtype == "gather" || newtype == "multline") {
+ } else if (newtype == hullGather || newtype == hullMultline) {
changeCols(1);
setType(newtype);
} else {
@@ -835,21 +847,21 @@
}
}
- else if (type_ == "multline" || type_ == "gather") {
- if (newtype == "gather" || newtype == "multline")
+ else if (type_ == hullMultline || type_ == hullGather) {
+ if (newtype == hullGather || newtype == hullMultline)
setType(newtype);
- else if (newtype == "align" || newtype == "flalign" ||
- newtype == "alignat" || newtype == "xalignat") {
+ else if (newtype == hullAlign || newtype == hullFlAlign ||
+ newtype == hullAlignAt || newtype == hullXAlignAt) {
splitTo2Cols();
setType(newtype);
- } else if (newtype == "xxalignat") {
+ } else if (newtype == hullXXAlignAt) {
splitTo2Cols();
for (row_type row = 0; row < nrows(); ++row)
numbered(row, false);
setType(newtype);
} else {
splitTo3Cols();
- setType("eqnarray");
+ setType(hullEqnArray);
mutate(newtype);
}
}
@@ -867,7 +879,7 @@
if (numberedType()) {
if (!label_[row].empty() && !nonum_[row])
res += "\\label{" + label_[row] + '}';
- if (nonum_[row] && (type_ != "multline"))
+ if (nonum_[row] && (type_ != hullMultline))
res += "\\nonumber ";
}
return res + MathGridInset::eolString(row, emptyline, fragile);
@@ -936,7 +948,7 @@
cur.idx() -= cur.idx() % ncols();
cur.pos() = 0;
- if (getType() == "simple") {
+ if (getType() == hullSimple) {
size_type pos = cur.cell().find_last(eq);
MathArray ar;
if (cur.inMathed() && cur.selection()) {
@@ -954,9 +966,9 @@
return;
}
- if (getType() == "equation") {
+ if (getType() == hullEquation) {
lyxerr << "use equation inset" << endl;
- mutate("eqnarray");
+ mutate(hullEqnArray);
MathArray & ar = cur.cell();
lyxerr << "use cell: " << ar << endl;
++cur.idx();
@@ -1009,11 +1021,11 @@
case LFUN_BREAK_LINE:
// some magic for the common case
- if (type_ == "simple" || type_ == "equation") {
+ if (type_ == hullSimple || type_ == hullEquation) {
recordUndoInset(cur);
bool const align =
cur.bv().buffer()->params().use_amsmath ==
BufferParams::AMS_ON;
- mutate(align ? "align" : "eqnarray");
+ mutate(align ? hullAlign : hullEqnArray);
cur.idx() = 0;
cur.pos() = cur.lastpos();
}
@@ -1025,7 +1037,7 @@
if (display()) {
recordUndoInset(cur);
bool old = numberedType();
- if (type_ == "multline")
+ if (type_ == hullMultline)
numbered(nrows() - 1, !old);
else
for (row_type row = 0; row < nrows(); ++row)
@@ -1037,7 +1049,7 @@
case LFUN_MATH_NONUMBER:
if (display()) {
recordUndoInset(cur);
- row_type r = (type_ == "multline") ? nrows() - 1 :
cur.row();
+ row_type r = (type_ == hullMultline) ? nrows() - 1 :
cur.row();
bool old = numbered(r);
cur.message(old ? _("No number") : _("Number"));
numbered(r, !old);
@@ -1046,7 +1058,7 @@
case LFUN_LABEL_INSERT: {
recordUndoInset(cur);
- row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
+ row_type r = (type_ == hullMultline) ? nrows() - 1 : cur.row();
string old_label = label(r);
string const default_label =
(lyxrc.label_init_length >= 0) ? "eq:" : "";
@@ -1075,7 +1087,7 @@
InsetCommandMailer::string2params(name,
lyx::to_utf8(cmd.argument()), p);
string str = p.getContents();
recordUndoInset(cur);
- row_type const r = (type_ == "multline") ? nrows() - 1
: cur.row();
+ row_type const r = (type_ == hullMultline) ? nrows() -
1 : cur.row();
str = lyx::support::trim(str);
if (!str.empty())
numbered(r, true);
@@ -1104,7 +1116,7 @@
recordUndoInset(cur);
row_type row = cur.row();
col_type col = cur.col();
- mutate(lyx::to_utf8(cmd.argument()));
+ mutate(hullType(lyx::to_utf8(cmd.argument())));
cur.idx() = row * ncols() + col;
if (cur.idx() > cur.lastidx()) {
cur.idx() = cur.lastidx();
@@ -1118,7 +1130,7 @@
case LFUN_MATH_DISPLAY: {
recordUndoInset(cur);
- mutate(type_ == "simple" ? "equation" : "simple");
+ mutate(type_ == hullSimple ? hullEquation : hullSimple);
cur.idx() = 0;
cur.pos() = cur.lastpos();
//cur.dispatched(FINISHED);
@@ -1152,7 +1164,7 @@
status.enabled(true);
return true;
case LFUN_LABEL_INSERT:
- status.enabled(type_ != "simple");
+ status.enabled(type_ != hullSimple);
return true;
case LFUN_INSET_INSERT: {
// Don't test createMathInset_fromDialogStr(), since
@@ -1160,7 +1172,7 @@
// dialog would not be applyable.
string const name = cmd.getArg(0);
status.enabled(name == "ref" ||
- (name == "label" && type_ != "simple"));
+ (name == "label" && type_ != hullSimple));
break;
}
case LFUN_TABULAR_FEATURE: {
@@ -1173,7 +1185,7 @@
|| s == "copy-row")) {
status.message(bformat(
N_("Can't change number of rows in '%1$s'"),
- type_));
+ hullName(type_)));
status.enabled(false);
return true;
}
@@ -1183,24 +1195,24 @@
|| s == "copy-column")) {
status.message(bformat(
N_("Can't change number of columns in '%1$s'"),
- type_));
+ hullName(type_)));
status.enabled(false);
return true;
}
- if ((type_ == "simple"
- || type_ == "equation"
- || type_ == "none") &&
+ if ((type_ == hullSimple
+ || type_ == hullEquation
+ || type_ == hullNone) &&
(s == "add-hline-above" || s == "add-hline-below")) {
status.message(bformat(
N_("Can't add horizontal grid lines in '%1$s'"),
- type_));
+ hullName(type_)));
status.enabled(false);
return true;
}
if (s == "add-vline-left" || s == "add-vline-right") {
status.message(bformat(
N_("Can't add vertical grid lines in '%1$s'"),
- type_));
+ hullName(type_)));
status.enabled(false);
return true;
}
@@ -1433,8 +1445,8 @@
MathMLStream ms(os);
int res = 0;
string name;
- if (getType() == "simple")
- name= "inlineequation";
+ if (getType() == hullSimple)
+ name = "inlineequation";
else
name = "informalequation";
Index: mathed/math_hullinset.h
===================================================================
--- mathed/math_hullinset.h (revision 14873)
+++ mathed/math_hullinset.h (working copy)
@@ -24,7 +24,7 @@
///
MathHullInset();
///
- explicit MathHullInset(std::string const & type);
+ explicit MathHullInset(HullType type);
///
~MathHullInset();
///
@@ -73,9 +73,9 @@
void delCol(col_type col);
/// get type
- std::string const & getType() const;
+ HullType getType() const;
/// change type
- void mutate(std::string const &);
+ void mutate(HullType newtype);
///
int defaultColSpace(col_type col);
@@ -131,7 +131,7 @@
private:
virtual std::auto_ptr<InsetBase> doClone() const;
///
- void setType(std::string const & type);
+ void setType(HullType type);
///
void validate1(LaTeXFeatures & features);
///
@@ -170,7 +170,7 @@
bool colChangeOK() const;
/// "none", "simple", "display", "eqnarray",...
- std::string type_;
+ HullType type_;
///
std::vector<int> nonum_;
///
Index: mathed/math_parser.C
===================================================================
--- mathed/math_parser.C (revision 14873)
+++ mathed/math_parser.C (working copy)
@@ -576,7 +576,7 @@
skipSpaces();
MathArray ar;
parse(ar, false, MathInset::UNDECIDED_MODE);
- if (ar.size() != 1 || ar.front()->getType() == "none") {
+ if (ar.size() != 1 || ar.front()->getType() == hullNone) {
lyxerr << "unusual contents found: " << ar << endl;
at = MathAtom(new MathParInset(ar));
//if (at->nargs() > 0)
@@ -726,13 +726,13 @@
Token const & n = getToken();
if (n.cat() == catMath) {
// TeX's $$...$$ syntax for displayed
math
- cell->push_back(MathAtom(new
MathHullInset("equation")));
+ cell->push_back(MathAtom(new
MathHullInset(hullEquation)));
parse2(cell->back(), FLAG_SIMPLE,
MathInset::MATH_MODE, false);
getToken(); // skip the second '$' token
} else {
// simple $...$ stuff
putback();
- cell->push_back(MathAtom(new
MathHullInset("simple")));
+ cell->push_back(MathAtom(new
MathHullInset(hullSimple)));
parse2(cell->back(), FLAG_SIMPLE,
MathInset::MATH_MODE, false);
}
}
@@ -914,12 +914,12 @@
}
else if (t.cs() == "(") {
- cell->push_back(MathAtom(new MathHullInset("simple")));
+ cell->push_back(MathAtom(new
MathHullInset(hullSimple)));
parse2(cell->back(), FLAG_SIMPLE2,
MathInset::MATH_MODE, false);
}
else if (t.cs() == "[") {
- cell->push_back(MathAtom(new
MathHullInset("equation")));
+ cell->push_back(MathAtom(new
MathHullInset(hullEquation)));
parse2(cell->back(), FLAG_EQUATION,
MathInset::MATH_MODE, false);
}
@@ -1114,59 +1114,59 @@
}
else if (name == "math") {
- cell->push_back(MathAtom(new
MathHullInset("simple")));
+ cell->push_back(MathAtom(new
MathHullInset(hullSimple)));
parse2(cell->back(), FLAG_END,
MathInset::MATH_MODE, true);
}
else if (name == "equation" || name == "equation*"
|| name == "displaymath") {
- cell->push_back(MathAtom(new
MathHullInset("equation")));
+ cell->push_back(MathAtom(new
MathHullInset(hullEquation)));
parse2(cell->back(), FLAG_END,
MathInset::MATH_MODE, (name == "equation"));
}
else if (name == "eqnarray" || name == "eqnarray*") {
- cell->push_back(MathAtom(new
MathHullInset("eqnarray")));
+ cell->push_back(MathAtom(new
MathHullInset(hullEqnArray)));
parse2(cell->back(), FLAG_END,
MathInset::MATH_MODE, !stared(name));
}
else if (name == "align" || name == "align*") {
- cell->push_back(MathAtom(new
MathHullInset("align")));
+ cell->push_back(MathAtom(new
MathHullInset(hullAlign)));
parse2(cell->back(), FLAG_END,
MathInset::MATH_MODE, !stared(name));
}
else if (name == "flalign" || name == "flalign*") {
- cell->push_back(MathAtom(new
MathHullInset("flalign")));
+ cell->push_back(MathAtom(new
MathHullInset(hullFlAlign)));
parse2(cell->back(), FLAG_END,
MathInset::MATH_MODE, !stared(name));
}
else if (name == "alignat" || name == "alignat*") {
// ignore this for a while
getArg('{', '}');
- cell->push_back(MathAtom(new
MathHullInset("alignat")));
+ cell->push_back(MathAtom(new
MathHullInset(hullAlignAt)));
parse2(cell->back(), FLAG_END,
MathInset::MATH_MODE, !stared(name));
}
else if (name == "xalignat" || name == "xalignat*") {
// ignore this for a while
getArg('{', '}');
- cell->push_back(MathAtom(new
MathHullInset("xalignat")));
+ cell->push_back(MathAtom(new
MathHullInset(hullXAlignAt)));
parse2(cell->back(), FLAG_END,
MathInset::MATH_MODE, !stared(name));
}
else if (name == "xxalignat") {
// ignore this for a while
getArg('{', '}');
- cell->push_back(MathAtom(new
MathHullInset("xxalignat")));
+ cell->push_back(MathAtom(new
MathHullInset(hullXXAlignAt)));
parse2(cell->back(), FLAG_END,
MathInset::MATH_MODE, !stared(name));
}
else if (name == "multline" || name == "multline*") {
- cell->push_back(MathAtom(new
MathHullInset("multline")));
+ cell->push_back(MathAtom(new
MathHullInset(hullMultline)));
parse2(cell->back(), FLAG_END,
MathInset::MATH_MODE, !stared(name));
}
else if (name == "gather" || name == "gather*") {
- cell->push_back(MathAtom(new
MathHullInset("gather")));
+ cell->push_back(MathAtom(new
MathHullInset(hullGather)));
parse2(cell->back(), FLAG_END,
MathInset::MATH_MODE, !stared(name));
}
Index: mathed/math_inset.C
===================================================================
--- mathed/math_inset.C (revision 14873)
+++ mathed/math_inset.C (working copy)
@@ -119,10 +119,9 @@
}
-string const & MathInset::getType() const
+HullType MathInset::getType() const
{
- static string const t = "none";
- return t;
+ return hullNone;
}
Index: text3.C
===================================================================
--- text3.C (revision 14873)
+++ text3.C (working copy)
@@ -152,7 +152,7 @@
if (sel.empty()) {
const int old_pos = cur.pos();
- cur.insert(new MathHullInset("simple"));
+ cur.insert(new MathHullInset(hullSimple));
BOOST_ASSERT(old_pos == cur.pos());
cur.nextInset()->edit(cur, true);
// don't do that also for LFUN_MATH_MODE
@@ -178,10 +178,10 @@
LyXLex lex(0, 0);
lex.setStream(is);
formula->read(cur.buffer(), lex);
- if (formula->getType() == "none")
+ if (formula->getType() == hullNone)
// Don't create pseudo formulas if
// delimiters are left out
- formula->mutate("simple");
+ formula->mutate(hullSimple);
cur.insert(formula);
} else
cur.insert(new MathMacroTemplate(is));
@@ -1251,7 +1251,7 @@
case LFUN_MATH_MATRIX:
case LFUN_MATH_DELIM:
case LFUN_MATH_BIGDELIM: {
- cur.insert(new MathHullInset("simple"));
+ cur.insert(new MathHullInset(hullSimple));
cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
cur.dispatch(cmd);
break;