math_diminset.h \
math_dotsinset.C \
math_dotsinset.h \
+ math_envinset.C \
+ math_envinset.h \
math_extern.C \
math_extern.h \
math_exfuncinset.C \
--- /dev/null
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_envinset.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+
+
+MathEnvInset::MathEnvInset(string const & name)
+ : MathNestInset(1), name_(name)
+{}
+
+
+MathInset * MathEnvInset::clone() const
+{
+ return new MathEnvInset(*this);
+}
+
+
+void MathEnvInset::metrics(MathMetricsInfo & mi) const
+{
+ xcell(0).metrics(mi);
+ ascent_ = xcell(0).ascent() + 1;
+ descent_ = xcell(0).descent() + 1;
+ width_ = xcell(0).width() + 2;
+}
+
+
+void MathEnvInset::draw(MathPainterInfo & pi, int x, int y) const
+{
+ xcell(0).draw(pi, x + 1, y);
+ drawMarkers2(pi, x, y);
+}
+
+
+void MathEnvInset::write(WriteStream & os) const
+{
+ os << "\\begin{" << name_ << '}' << cell(0) << "\\end{" << name_ << '}';
+}
+
+
+void MathEnvInset::normalize(NormalStream & os) const
+{
+ os << "[env " << name_ << " " << cell(0) << ']';
+}
+
+
+void MathEnvInset::infoize(std::ostream & os) const
+{
+ os << "Env: " << name_;
+}
--- /dev/null
+// -*- C++ -*-
+#ifndef MATH_ENVINSET_H
+#define MATH_ENVINSET_H
+
+#include "math_nestinset.h"
+#include "math_metricsinfo.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+/** Environtments á la \begin{something}...\end{something}
+ \author André Pönitz
+*/
+
+class MathEnvInset : public MathNestInset {
+public:
+ ///
+ MathEnvInset(string const & name_);
+ ///
+ MathInset * clone() const;
+ ///
+ void draw(MathPainterInfo &, int x, int y) const;
+ ///
+ void write(WriteStream & os) const;
+ /// write normalized content
+ void normalize(NormalStream & ns) const;
+ ///
+ void metrics(MathMetricsInfo & mi) const;
+ ///
+ void infoize(std::ostream & os) const;
+
+private:
+ /// name of that environment
+ string name_;
+};
+
+#endif
}
+void MathNestInset::drawMarkers2(MathPainterInfo & pi, int x, int y) const
+{
+ if (!editing())
+ return;
+ drawMarkers(pi, x, y);
+ int t = x + width() - 1;
+ int a = y - ascent();
+ pi.pain.line(x, a + 3, x, a, LColor::mathframe);
+ pi.pain.line(t, a + 3, t, a, LColor::mathframe);
+ pi.pain.line(x, a, x + 3, a, LColor::mathframe);
+ pi.pain.line(t - 2, a, t, a, LColor::mathframe);
+}
+
+
void MathNestInset::validate(LaTeXFeatures & features) const
{
for (idx_type i = 0; i < nargs(); ++i)
void metrics(MathMetricsInfo const & mi) const;
/// draw background if locked
void draw(MathPainterInfo & pi, int x, int y) const;
- /// draw angular markers
+ /// draw two angular markers
void drawMarkers(MathPainterInfo & pi, int x, int y) const;
+ /// draw four angular markers
+ void drawMarkers2(MathPainterInfo & pi, int x, int y) const;
/// appends itself with macro arguments substituted
void substitute(MathMacro const & macro);
/// identifies NestInsets
#include "math_boxinset.h"
#include "math_charinset.h"
#include "math_deliminset.h"
+#include "math_envinset.h"
#include "math_extern.h"
#include "math_factory.h"
#include "math_kerninset.h"
} else if (nextToken().cs() == "newcommand") {
+ // skip the 'newcommand'
getToken();
if (getToken().cat() != catBegin) {
name = getToken().cs();
if (getToken().cat() != catEnd) {
- error("'}' expected\n");
+ error("'}' in \\newcommand expected\n");
return false;
}
parse_into2(cell->back(), FLAG_END, true, !stared(name));
}
- else {
- latexkeys const * l = in_word_set(name);
- if (l) {
- if (l->inset == "matrix") {
- cell->push_back(createMathInset(name));
- parse_into2(cell->back(), FLAG_END, mathmode, false);
- }
- } else {
- lyxerr << "unknow math inset begin '" << name << "'\n";
+ else if (latexkeys const * l = in_word_set(name)) {
+ if (l->inset == "matrix") {
+ cell->push_back(createMathInset(name));
+ parse_into2(cell->back(), FLAG_END, mathmode, false);
}
}
+
+ else {
+ // lyxerr << "unknow math inset begin '" << name << "'\n";
+ // create generic environment inset
+ cell->push_back(MathAtom(new MathEnvInset(name)));
+ parse_into(cell->back()->cell(0), FLAG_END, mathmode);
+ }
}
else if (t.cs() == "kern") {
// Sadly, HP-UX CC can't handle that kind of initialization.
// XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
- if (space_ > 6)
+ if (space_ >= 6)
return;
int xp[4];