math_fboxinset.h \
math_fontinset.C \
math_fontinset.h \
+ math_fontoldinset.C \
+ math_fontoldinset.h \
math_fracinset.C \
math_fracinset.h \
math_fracbase.C \
#include "Lsstream.h"
#include "math_arrayinset.h"
#include "math_charinset.h"
+#include "math_deliminset.h"
#include "math_cursor.h"
+#include "math_factory.h"
#include "math_fontinset.h"
#include "math_hullinset.h"
#include "math_iterator.h"
bool sel = mathcursor->selection();
if (sel)
updateLocal(bv, true);
- mathcursor->handleNest(new MathFontInset(font));
+ mathcursor->handleNest(createMathInset(font));
mathcursor->insert(arg);
if (!sel)
updateLocal(bv, false);
rs = ')';
bv->lockedInsetStoreUndo(Undo::EDIT);
- mathcursor->handleDelim(ls, rs);
+ mathcursor->handleNest(MathAtom(new MathDelimInset(ls, rs)));
updateLocal(bv, true);
break;
}
#include "math_boxinset.h"
#include "math_casesinset.h"
#include "math_charinset.h"
-#include "math_deliminset.h"
#include "math_extern.h"
#include "math_factory.h"
#include "math_fboxinset.h"
}
-void MathCursor::handleDelim(string const & l, string const & r)
+void MathCursor::handleNest(MathAtom const & at)
{
- handleNest(new MathDelimInset(l, r));
-}
-
-
-void MathCursor::handleNest(MathInset * p)
-{
- p->cell(0) = grabAndEraseSelection().glue();
- insert(MathAtom(p)); // this invalidates p!
+ at->cell(0) = grabAndEraseSelection().glue();
+ insert(at);
pushRight(prevAtom());
}
///
void drawSelection(MathPainterInfo & pain) const;
///
- void handleDelim(string const & l, string const & r);
- ///
- void handleNest(MathInset * p);
+ void handleNest(MathAtom const & at);
/// splits cells and shifts right part to the next cell
void splitCell();
/// splits line and insert new row of cell
#include "support/LOstream.h"
-MathDecorationInset::MathDecorationInset(string const & name)
- : MathNestInset(1), name_(name)
+MathDecorationInset::MathDecorationInset(latexkeys const * key)
+ : MathNestInset(1), key_(key)
{}
bool MathDecorationInset::upper() const
{
- return name_.substr(0, 5) != "under";
+ return key_->name.substr(0, 5) != "under";
}
bool MathDecorationInset::isScriptable() const
{
return
- name_ == "overbrace" ||
- name_ == "underbrace" ||
- name_ == "overleftarrow" ||
- name_ == "overrightarrow" ||
- name_ == "overleftrightarrow" ||
- name_ == "underleftarrow" ||
- name_ == "underrightarrow" ||
- name_ == "underleftrightarrow";
+ key_->name == "overbrace" ||
+ key_->name == "underbrace" ||
+ key_->name == "overleftarrow" ||
+ key_->name == "overrightarrow" ||
+ key_->name == "overleftrightarrow" ||
+ key_->name == "underleftarrow" ||
+ key_->name == "underrightarrow" ||
+ key_->name == "underleftrightarrow";
}
bool MathDecorationInset::protect() const
{
return
- name_ == "overbrace" ||
- name_ == "underbrace" ||
- name_ == "overleftarrow" ||
- name_ == "overrightarrow" ||
- name_ == "overleftrightarrow" ||
- name_ == "underleftarrow" ||
- name_ == "underrightarrow" ||
- name_ == "underleftrightarrow";
+ key_->name == "overbrace" ||
+ key_->name == "underbrace" ||
+ key_->name == "overleftarrow" ||
+ key_->name == "overrightarrow" ||
+ key_->name == "overleftrightarrow" ||
+ key_->name == "underleftarrow" ||
+ key_->name == "underrightarrow" ||
+ key_->name == "underleftrightarrow";
}
bool MathDecorationInset::wide() const
{
return
- name_ == "overline" ||
- name_ == "underline" ||
- name_ == "overbrace" ||
- name_ == "underbrace" ||
- name_ == "overleftarrow" ||
- name_ == "overrightarrow" ||
- name_ == "overleftrightarrow" ||
- name_ == "widehat" ||
- name_ == "widetilde" ||
- name_ == "underleftarrow" ||
- name_ == "underrightarrow" ||
- name_ == "underleftrightarrow";
+ key_->name == "overline" ||
+ key_->name == "underline" ||
+ key_->name == "overbrace" ||
+ key_->name == "underbrace" ||
+ key_->name == "overleftarrow" ||
+ key_->name == "overrightarrow" ||
+ key_->name == "overleftrightarrow" ||
+ key_->name == "widehat" ||
+ key_->name == "widetilde" ||
+ key_->name == "underleftarrow" ||
+ key_->name == "underrightarrow" ||
+ key_->name == "underleftrightarrow";
}
{
xcell(0).draw(pi, x + 1, y);
if (wide())
- mathed_draw_deco(pi, x + 1, y + dy_, width(), dh_, name_);
+ mathed_draw_deco(pi, x + 1, y + dy_, width(), dh_, key_->name);
else
- mathed_draw_deco(pi, x + 1 + (width() - dw_) / 2, y + dy_, dw_, dh_, name_);
+ mathed_draw_deco(pi, x + 1 + (width() - dw_) / 2, y + dy_, dw_, dh_, key_->name);
drawMarkers(pi, x, y);
}
{
if (os.fragile() && protect())
os << "\\protect";
- os << '\\' << name_ << '{' << cell(0) << '}';
+ os << '\\' << key_->name << '{' << cell(0) << '}';
}
void MathDecorationInset::normalize(NormalStream & os) const
{
- os << "[deco " << name_ << ' ' << cell(0) << ']';
+ os << "[deco " << key_->name << ' ' << cell(0) << ']';
}
void MathDecorationInset::infoize(std::ostream & os) const
{
- os << "Deco: " << name_;
+ os << "Deco: " << key_->name;
}
\author Alejandro Aguilar Sierra
*/
+class latexkeys;
+
class MathDecorationInset : public MathNestInset {
public:
///
- explicit MathDecorationInset(string const & name);
+ explicit MathDecorationInset(latexkeys const * key);
///
MathInset * clone() const;
///
bool wide() const;
///
- string const name_;
+ latexkeys const * key_;
/// height cache of deco
mutable int dh_;
/// vertical offset cache of deco
#include "math_mathmlstream.h"
#include "math_streamstr.h"
#include "math_support.h"
+#include "math_parser.h"
-MathDotsInset::MathDotsInset(string const & name)
- : name_(name)
+MathDotsInset::MathDotsInset(latexkeys const * key)
+ : key_(key)
{}
void MathDotsInset::metrics(MathMetricsInfo & mi) const
{
mathed_char_dim(mi.base.font, 'M', dim_);
- if (name_ == "ldots" || name_ == "dotsm")
+ if (key_->name == "ldots" || key_->name == "dotsm")
dh_ = 0;
- else if (name_ == "cdots" || name_ == "dotsb"
- || name_ == "dotsm" || name_ == "dotsi")
+ else if (key_->name == "cdots" || key_->name == "dotsb"
+ || key_->name == "dotsm" || key_->name == "dotsi")
dh_ = ascent() / 2;
- else if (name_ == "dotsc")
+ else if (key_->name == "dotsc")
dh_ = ascent() / 4;
- else if (name_ == "vdots")
+ else if (key_->name == "vdots")
dim_.w /= 2;
- else if (name_ == "ddots")
+ else if (key_->name == "ddots")
dh_ = ascent();
}
void MathDotsInset::draw(MathPainterInfo & pain, int x, int y) const
{
- mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), name_);
- if (name_ == "vdots" || name_ == "ddots")
+ mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), key_->name);
+ if (key_->name == "vdots" || key_->name == "ddots")
++x;
- if (name_ != "vdots")
+ if (key_->name != "vdots")
--y;
- mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), name_);
+ mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), key_->name);
}
void MathDotsInset::write(WriteStream & os) const
{
- os << '\\' << name_ << ' ';
+ os << '\\' << key_->name << ' ';
}
void MathDotsInset::normalize(NormalStream & os) const
{
- os << "[" << name_ << "] ";
+ os << "[" << key_->name << "] ";
}
#define MATH_DOTSINSET_H
#include "math_diminset.h"
-#include "LString.h"
#ifdef __GNUG__
#pragma interface
#endif
+class latexkeys;
+
/// The different kinds of ellipsis
class MathDotsInset : public MathDimInset {
public:
///
- explicit MathDotsInset(string const &);
+ explicit MathDotsInset(latexkeys const * l);
///
MathInset * clone() const;
///
/// cache for the thing's heigth
mutable int dh_;
///
- string const name_;
+ latexkeys const * key_;
};
#endif
#include "math_dotsinset.h"
#include "math_fboxinset.h"
#include "math_fontinset.h"
+#include "math_fontoldinset.h"
#include "math_fracinset.h"
#include "math_kerninset.h"
#include "math_lefteqninset.h"
if (inset == "underset")
return MathAtom(new MathUndersetInset);
if (inset == "decoration")
- return MathAtom(new MathDecorationInset(l->name));
+ return MathAtom(new MathDecorationInset(l));
if (inset == "space")
return MathAtom(new MathSpaceInset(l->name));
if (inset == "dots")
- return MathAtom(new MathDotsInset(l->name));
+ return MathAtom(new MathDotsInset(l));
if (inset == "mbox")
return MathAtom(new MathBoxInset(l->name));
if (inset == "parbox")
if (inset == "style")
return MathAtom(new MathSizeInset(l));
if (inset == "font")
- return MathAtom(new MathFontInset(l->name));
+ return MathAtom(new MathFontInset(l));
if (inset == "oldfont")
- return MathAtom(new MathFontInset(l->name));
+ return MathAtom(new MathFontOldInset(l));
if (inset == "matrix")
return MathAtom(new MathAMSArrayInset(s));
return MathAtom(new MathSymbolInset(l));
#include "math_mathmlstream.h"
#include "math_streamstr.h"
#include "math_support.h"
+#include "math_parser.h"
#include "LaTeXFeatures.h"
#include "textpainter.h"
#include "frontends/Painter.h"
-MathFontInset::MathFontInset(string const & name)
- : MathNestInset(1), name_(name)
+MathFontInset::MathFontInset(latexkeys const * key)
+ : MathNestInset(1), key_(key)
{
//lock(true);
}
void MathFontInset::metrics(MathMetricsInfo & mi) const
{
- MathFontSetChanger dummy(mi.base, name_.c_str());
+ MathFontSetChanger dummy(mi.base, key_->name.c_str());
dim_ = xcell(0).metrics(mi);
metricsMarkers();
}
{
//lyxerr << "MathFontInset::draw\n";
//MathNestInset::draw(pi, x, y);
- MathFontSetChanger dummy(pi.base, name_.c_str());
+ MathFontSetChanger dummy(pi.base, key_->name.c_str());
xcell(0).draw(pi, x + 1, y);
drawMarkers(pi, x, y);
}
void MathFontInset::write(WriteStream & os) const
{
- os << '\\' << name_ << '{' << cell(0) << '}';
+ os << '\\' << key_->name << '{' << cell(0) << '}';
}
void MathFontInset::normalize(NormalStream & os) const
{
- os << "[font_ " << name_ << " " << cell(0) << "]";
+ os << "[font " << key_->name << " " << cell(0) << "]";
}
{
// Make sure amssymb is put in preamble if Blackboard Bold or
// Fraktur used:
- if (name_ == "mathfrak" || name_ == "mathbb")
+ if (key_->name == "mathfrak" || key_->name == "mathbb")
features.require("amssymb");
}
void MathFontInset::infoize(std::ostream & os) const
{
- os << "Font: " << name_;
+ os << "Font: " << key_->name;
}
#define MATH_FONTINSET_H
#include "math_nestinset.h"
-#include "LString.h"
-#include "lyxfont.h"
#ifdef __GNUG__
#pragma interface
#endif
-/** The base character inset.
+/** Inset for font changes
\author André Pönitz
*/
+class latexkeys;
+
class MathFontInset : public MathNestInset {
public:
///
- explicit MathFontInset(string const & name);
+ explicit MathFontInset(latexkeys const * key);
///
MathInset * clone() const;
///
void write(WriteStream & os) const;
///
void normalize(NormalStream &) const;
- /// identifies Fontinsets
- MathFontInset const * asFontInset() const { return this; }
///
void validate(LaTeXFeatures & features) const;
///
private:
/// the font to be used on screen
- string name_;
+ latexkeys const * key_;
};
#endif
--- /dev/null
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_fontoldinset.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+#include "math_support.h"
+#include "math_parser.h"
+#include "textpainter.h"
+#include "frontends/Painter.h"
+
+
+
+MathFontOldInset::MathFontOldInset(latexkeys const * key)
+ : MathNestInset(1), key_(key)
+{
+ //lock(true);
+}
+
+
+MathInset * MathFontOldInset::clone() const
+{
+ return new MathFontOldInset(*this);
+}
+
+
+void MathFontOldInset::metrics(MathMetricsInfo & mi) const
+{
+ MathFontSetChanger dummy(mi.base, key_->name.c_str());
+ dim_ = xcell(0).metrics(mi);
+ metricsMarkers();
+}
+
+
+void MathFontOldInset::draw(MathPainterInfo & pi, int x, int y) const
+{
+ MathFontSetChanger dummy(pi.base, key_->name.c_str());
+ xcell(0).draw(pi, x + 1, y);
+ drawMarkers(pi, x, y);
+}
+
+
+void MathFontOldInset::metricsT(TextMetricsInfo const & mi) const
+{
+ dim_ = xcell(0).metricsT(mi);
+}
+
+
+void MathFontOldInset::drawT(TextPainter & pain, int x, int y) const
+{
+ xcell(0).drawT(pain, x, y);
+}
+
+
+void MathFontOldInset::write(WriteStream & os) const
+{
+ os << "{\\" << key_->name << ' ' << cell(0) << '}';
+}
+
+
+void MathFontOldInset::normalize(NormalStream & os) const
+{
+ os << "[font " << key_->name << " " << cell(0) << "]";
+}
+
+
+void MathFontOldInset::infoize(std::ostream & os) const
+{
+ os << "Font: " << key_->name;
+}
--- /dev/null
+// -*- C++ -*-
+#ifndef MATH_FONTOLDINSET_H
+#define MATH_FONTOLDINSET_H
+
+#include "math_nestinset.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+/** Old-style font changes
+ \author André Pönitz
+ */
+
+class latexkeys;
+
+class MathFontOldInset : public MathNestInset {
+public:
+ ///
+ explicit MathFontOldInset(latexkeys const * key);
+ ///
+ MathInset * clone() const;
+ /// we write extra braces in any case...
+ bool extraBraces() const { return true; }
+ ///
+ void metrics(MathMetricsInfo & mi) const;
+ ///
+ void draw(MathPainterInfo & pi, int x, int y) const;
+ ///
+ void metricsT(TextMetricsInfo const & mi) const;
+ ///
+ void drawT(TextPainter & pi, int x, int y) const;
+ ///
+ void write(WriteStream & os) const;
+ ///
+ void normalize(NormalStream &) const;
+ ///
+ void infoize(std::ostream & os) const;
+
+private:
+ /// the font to be used on screen
+ latexkeys const * key_;
+};
+#endif
else if (type_ == "eqnarray" || type_ == "align")
os << "\\begin{" << type_ << star(n) << "}\n";
- else if (type_ == "alignat" || type_ == "xalignat" || type_ == "xxalignat")
+ else if (type_ == "alignat" || type_ == "xalignat")
os << "\\begin{" << type_ << star(n) << "}"
<< "{" << static_cast<unsigned int>(ncols()/2) << "}\n";
- else if (type_ == "multline" || type_ == "gather")
+ else if (type_ == "xxalignat" || type_ == "multline" || type_ == "gather")
os << "\\begin{" << type_ << "}\n";
else
class MathCharInset;
class MathDelimInset;
class MathFboxInset;
-class MathFontInset;
class MathGridInset;
class MathFracInset;
class MathHullInset;
virtual MathDelimInset * asDelimInset() { return 0; }
virtual MathDelimInset const * asDelimInset() const { return 0; }
virtual MathFboxInset * asFboxInset() { return 0; }
- virtual MathFontInset const * asFontInset() const { return 0; }
virtual MathFracInset * asFracInset() { return 0; }
virtual MathGridInset * asGridInset() { return 0; }
virtual MathHullInset * asHullInset() { return 0; }
}
+int MathParboxInset::pos2row(pos_type pos) const
+{
+ for (int r = 0, n = rows_.size(); r < n; ++r)
+ if (pos >= rows_[r].begin && pos < rows_[r].end)
+ return r;
+ lyxerr << "illegal row for pos " << pos << "\n";
+ return 0;
+}
+
+
void MathParboxInset::getPos(idx_type idx, pos_type pos, int & x, int & y) const
{
- for (int r = 0, n = rows_.size(); r < n; ++r) {
- if (pos >= rows_[r].begin && pos < rows_[r].end) {
- //lyxerr << "found cursor at pos " << pos << " in row " << r << "\n";
- x = cells_[0].xo() + cells_[0].pos2x(rows_[r].begin, pos, rows_[r].glue);
- y = cells_[0].yo() + rows_[r].yo;
- break;
- }
- }
+ int const r = pos2row(pos);
+ //lyxerr << "found cursor at pos " << pos << " in row " << r << "\n";
+ x = cells_[0].xo() + cells_[0].pos2x(rows_[r].begin, pos, rows_[r].glue);
+ y = cells_[0].yo() + rows_[r].yo;
// move cursor visually into empty cells ("blue rectangles");
if (cell(0).empty())
x += 2;
///
void setPosition(string const & pos);
private:
+ /// row corresponding to given position
+ int pos2row(pos_type pos) const;
/// width on screen
int lyx_width_;
/// width for TeX
latexkeys const * l = in_word_set(t.cs());
if (l) {
if (l->inset == "font") {
- lyxerr << "starting font " << t.cs() << "\n";
- MathAtom p = createMathInset(t.cs());
- bool textmode = (t.cs()[0] == 't');
- parse(p->cell(0), FLAG_ITEM, !textmode);
- cell->push_back(p);
- //lyxerr << "ending font\n";
+ cell->push_back(createMathInset(t.cs()));
+ parse(cell->back()->cell(0), FLAG_ITEM, l->extra == "mathmode");
}
else if (l->inset == "oldfont") {