diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index 2013797755..d7736b8a9f 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -54,6 +54,8 @@ libmathed_la_SOURCES = \ math_exintinset.h \ math_factory.C \ math_factory.h \ + math_fontinset.C \ + math_fontinset.h \ math_fracinset.C \ math_fracinset.h \ math_fracbase.C \ diff --git a/src/mathed/fonts_as_insets.diff b/src/mathed/fonts_as_insets.diff new file mode 100644 index 0000000000..838c942472 --- /dev/null +++ b/src/mathed/fonts_as_insets.diff @@ -0,0 +1,2868 @@ +? index.html +? symbols.tex +? symbols.log +? symbols.idx +? symbols.aux +? symbols.toc +? symbols.dvi +? symbols-a4_ps.zip +? symbol.diff +? fonts_as_insets.diff +? math_symbolinset.h.new +? math_symbolinset.C.new +Index: Makefile.am +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/Makefile.am,v +retrieving revision 1.86 +diff -u -p -r1.86 Makefile.am +--- Makefile.am 25 Mar 2002 11:15:27 -0000 1.86 ++++ Makefile.am 25 Mar 2002 12:01:57 -0000 +@@ -54,6 +54,8 @@ libmathed_la_SOURCES = \ + math_exintinset.h \ + math_factory.C \ + math_factory.h \ ++ math_fontinset.C \ ++ math_fontinset.h \ + math_fracinset.C \ + math_fracinset.h \ + math_fracbase.C \ +Index: formula.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formula.C,v +retrieving revision 1.187 +diff -u -p -r1.187 formula.C +--- formula.C 21 Mar 2002 17:42:54 -0000 1.187 ++++ formula.C 25 Mar 2002 12:01:57 -0000 +@@ -353,16 +353,16 @@ void InsetFormula::draw(BufferView * bv, + int w = par_->width(); + int h = par_->height(); + int a = par_->ascent(); +- Painter & pain = bv->painter(); ++ MathPainterInfo pain = MathPainterInfo(bv->painter()); + + if (lcolor.getX11Name(LColor::mathbg)!=lcolor.getX11Name(LColor::background)) +- pain.fillRectangle(x, y - a, w, h, LColor::mathbg); ++ pain.pain.fillRectangle(x, y - a, w, h, LColor::mathbg); + + if (mathcursor && + const_cast(mathcursor->formula()) == this) + { + mathcursor->drawSelection(pain); +- pain.rectangle(x, y - a, w, h, LColor::mathframe); ++ pain.pain.rectangle(x, y - a, w, h, LColor::mathframe); + } + + par_->draw(pain, x, y); +@@ -546,7 +546,7 @@ void InsetFormula::handleExtern(const st + mathcursor->last(); + mathcursor->stripFromLastEqualSign(); + ar = mathcursor->cursor().cell(); +- mathcursor->insert(MathAtom(new MathCharInset('=', LM_TC_VAR))); ++ mathcursor->insert('='); + //lyxerr << "use whole cell: " << ar << "\n"; + } + +Index: formulabase.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulabase.C,v +retrieving revision 1.135 +diff -u -p -r1.135 formulabase.C +--- formulabase.C 21 Mar 2002 17:42:55 -0000 1.135 ++++ formulabase.C 25 Mar 2002 12:01:57 -0000 +@@ -74,7 +74,7 @@ void handleFont(BufferView * bv, string + { + if (mathcursor->selection()) + bv->lockedInsetStoreUndo(Undo::EDIT); +- mathcursor->handleFont(t); ++ //mathcursor->handleFont(t); + for (string::const_iterator it = arg.begin(); it != arg.end(); ++it) + mathcursor->insert(*it); + } +@@ -103,6 +103,7 @@ InsetFormulaBase::InsetFormulaBase() + //lyxerr << "sizeof MathInset: " << sizeof(MathInset) << "\n"; + //lyxerr << "sizeof(MathMetricsInfo): " << sizeof(MathMetricsInfo) << "\n"; + //lyxerr << "sizeof(MathCharInset): " << sizeof(MathCharInset) << "\n"; ++ //lyxerr << "sizeof(LyXFont): " << sizeof(LyXFont) << "\n"; + } + + +Index: formulamacro.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulamacro.C,v +retrieving revision 1.90 +diff -u -p -r1.90 formulamacro.C +--- formulamacro.C 21 Mar 2002 17:42:55 -0000 1.90 ++++ formulamacro.C 25 Mar 2002 12:01:57 -0000 +@@ -167,7 +167,7 @@ MathInsetTypes InsetFormulaMacro::getTyp + void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f, + int y, float & x, bool /*cleared*/) const + { +- Painter & pain = bv->painter(); ++ MathPainterInfo pain = MathPainterInfo(bv->painter()); + LyXFont font(f); + + // label +@@ -178,14 +178,14 @@ void InsetFormulaMacro::draw(BufferView + int const h = ascent(bv, font) + descent(bv, font) - 2; + + // LColor::mathbg used to be "AntiqueWhite" but is "linen" now, too +- pain.fillRectangle(int(x), a , w, h, LColor::mathmacrobg); +- pain.rectangle(int(x), a, w, h, LColor::mathframe); ++ pain.pain.fillRectangle(int(x), a , w, h, LColor::mathmacrobg); ++ pain.pain.rectangle(int(x), a, w, h, LColor::mathframe); + + if (mathcursor && + const_cast(mathcursor->formula()) == this) + mathcursor->drawSelection(pain); + +- pain.text(int(x + 2), y, prefix(), font); ++ pain.pain.text(int(x + 2), y, prefix(), font); + x += width(bv, font); + + // formula +Index: math_amsarrayinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_amsarrayinset.C,v +retrieving revision 1.5 +diff -u -p -r1.5 math_amsarrayinset.C +--- math_amsarrayinset.C 21 Mar 2002 17:42:55 -0000 1.5 ++++ math_amsarrayinset.C 25 Mar 2002 12:01:57 -0000 +@@ -66,7 +66,7 @@ void MathAMSArrayInset::metrics(MathMetr + } + + +-void MathAMSArrayInset::draw(Painter & pain, int x, int y) const ++void MathAMSArrayInset::draw(MathPainterInfo & pain, int x, int y) const + { + MathGridInset::draw(pain, x + 6, y); + int yy = y - ascent_; +Index: math_amsarrayinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_amsarrayinset.h,v +retrieving revision 1.2 +diff -u -p -r1.2 math_amsarrayinset.h +--- math_amsarrayinset.h 21 Mar 2002 17:42:55 -0000 1.2 ++++ math_amsarrayinset.h 25 Mar 2002 12:01:57 -0000 +@@ -20,7 +20,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter & pain, int x, int y) const; ++ void draw(MathPainterInfo & pain, int x, int y) const; + /// + MathAMSArrayInset * asAMSArrayInset() { return this; } + +Index: math_biginset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_biginset.C,v +retrieving revision 1.5 +diff -u -p -r1.5 math_biginset.C +--- math_biginset.C 21 Mar 2002 17:42:55 -0000 1.5 ++++ math_biginset.C 25 Mar 2002 12:01:57 -0000 +@@ -52,7 +52,7 @@ void MathBigInset::metrics(MathMetricsIn + } + + +-void MathBigInset::draw(Painter & pain, int x, int y) const ++void MathBigInset::draw(MathPainterInfo & pain, int x, int y) const + { + mathed_draw_deco(pain, x + 1, y - ascent_, 4, height(), delim_); + } +Index: math_biginset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_biginset.h,v +retrieving revision 1.3 +diff -u -p -r1.3 math_biginset.h +--- math_biginset.h 21 Mar 2002 17:42:55 -0000 1.3 ++++ math_biginset.h 25 Mar 2002 12:01:57 -0000 +@@ -20,7 +20,7 @@ public: + /// + MathInset * clone() const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void write(WriteStream & os) const; + /// +Index: math_binaryopinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_binaryopinset.C,v +retrieving revision 1.7 +diff -u -p -r1.7 math_binaryopinset.C +--- math_binaryopinset.C 21 Mar 2002 17:42:55 -0000 1.7 ++++ math_binaryopinset.C 25 Mar 2002 12:01:57 -0000 +@@ -5,7 +5,7 @@ + #endif + + #include "math_binaryopinset.h" +-#include "Painter.h" ++#include "MathPainterInfo.h" + #include "support/LOstream.h" + #include "math_support.h" + #include "math_mathmlstream.h" +@@ -42,7 +42,7 @@ void MathBinaryOpInset::metrics(MathMetr + } + + +-void MathBinaryOpInset::draw(Painter & pain, int x, int y) const ++void MathBinaryOpInset::draw(MathPainterInfo & pain, int x, int y) const + { + xcell(0).draw(pain, x, y); + drawChar(pain, LM_TC_CONST, mi_, x + xcell(0).width() , y, op_); +Index: math_binaryopinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_binaryopinset.h,v +retrieving revision 1.3 +diff -u -p -r1.3 math_binaryopinset.h +--- math_binaryopinset.h 9 Nov 2001 08:35:55 -0000 1.3 ++++ math_binaryopinset.h 25 Mar 2002 12:01:57 -0000 +@@ -19,7 +19,7 @@ public: + /// + MathInset * clone() const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void write(WriteStream & os) const; + /// +Index: math_binominset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_binominset.C,v +retrieving revision 1.12 +diff -u -p -r1.12 math_binominset.C +--- math_binominset.C 21 Mar 2002 17:42:55 -0000 1.12 ++++ math_binominset.C 25 Mar 2002 12:01:57 -0000 +@@ -46,7 +46,7 @@ void MathBinomInset::metrics(MathMetrics + } + + +-void MathBinomInset::draw(Painter & pain, int x, int y) const ++void MathBinomInset::draw(MathPainterInfo & pain, int x, int y) const + { + int m = x + width() / 2; + xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5); +Index: math_binominset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_binominset.h,v +retrieving revision 1.5 +diff -u -p -r1.5 math_binominset.h +--- math_binominset.h 21 Mar 2002 17:42:55 -0000 1.5 ++++ math_binominset.h 25 Mar 2002 12:01:57 -0000 +@@ -24,7 +24,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + private: + /// + int dw() const; +Index: math_boxinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_boxinset.C,v +retrieving revision 1.10 +diff -u -p -r1.10 math_boxinset.C +--- math_boxinset.C 3 Jan 2002 12:02:53 -0000 1.10 ++++ math_boxinset.C 25 Mar 2002 12:01:57 -0000 +@@ -41,7 +41,7 @@ void MathBoxInset::rebreak() + } + + +-void MathBoxInset::draw(Painter & pain, int x, int y) const ++void MathBoxInset::draw(MathPainterInfo & pain, int x, int y) const + { + MathGridInset::draw(pain, x, y); + mathed_draw_framebox(pain, x, y, this); +Index: math_boxinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_boxinset.h,v +retrieving revision 1.7 +diff -u -p -r1.7 math_boxinset.h +--- math_boxinset.h 18 Dec 2001 12:21:32 -0000 1.7 ++++ math_boxinset.h 25 Mar 2002 12:01:57 -0000 +@@ -30,7 +30,7 @@ public: + /// + void normalize(NormalStream &) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + + private: + /// +Index: math_braceinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_braceinset.C,v +retrieving revision 1.7 +diff -u -p -r1.7 math_braceinset.C +--- math_braceinset.C 21 Mar 2002 17:42:55 -0000 1.7 ++++ math_braceinset.C 25 Mar 2002 12:01:57 -0000 +@@ -36,7 +36,7 @@ void MathBraceInset::metrics(MathMetrics + } + + +-void MathBraceInset::draw(Painter & pain, int x, int y) const ++void MathBraceInset::draw(MathPainterInfo & pain, int x, int y) const + { + drawChar(pain, font_, x, y, '{'); + xcell(0).draw(pain, x + wid_, y); +Index: math_braceinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_braceinset.h,v +retrieving revision 1.6 +diff -u -p -r1.6 math_braceinset.h +--- math_braceinset.h 21 Mar 2002 17:42:55 -0000 1.6 ++++ math_braceinset.h 25 Mar 2002 12:01:57 -0000 +@@ -22,7 +22,7 @@ public: + /// + MathBraceInset * asBraceInset() { return this; } + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void write(WriteStream & os) const; + /// write normalized content +Index: math_casesinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_casesinset.C,v +retrieving revision 1.6 +diff -u -p -r1.6 math_casesinset.C +--- math_casesinset.C 21 Mar 2002 17:42:55 -0000 1.6 ++++ math_casesinset.C 25 Mar 2002 12:01:57 -0000 +@@ -8,7 +8,6 @@ + #include "math_parser.h" + #include "math_mathmlstream.h" + #include "math_support.h" +-#include "Painter.h" + + + MathCasesInset::MathCasesInset(row_type n) +@@ -29,7 +28,7 @@ void MathCasesInset::metrics(MathMetrics + } + + +-void MathCasesInset::draw(Painter & pain, int x, int y) const ++void MathCasesInset::draw(MathPainterInfo & pain, int x, int y) const + { + mathed_draw_deco(pain, x + 1, y - ascent(), 6, height(), "{"); + MathGridInset::draw(pain, x + 8, y); +Index: math_casesinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_casesinset.h,v +retrieving revision 1.2 +diff -u -p -r1.2 math_casesinset.h +--- math_casesinset.h 21 Mar 2002 17:42:55 -0000 1.2 ++++ math_casesinset.h 25 Mar 2002 12:01:57 -0000 +@@ -18,7 +18,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter & pain, int x, int y) const; ++ void draw(MathPainterInfo & pain, int x, int y) const; + + /// + void normalize(NormalStream &) const; +Index: math_charinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_charinset.C,v +retrieving revision 1.38 +diff -u -p -r1.38 math_charinset.C +--- math_charinset.C 21 Mar 2002 17:42:55 -0000 1.38 ++++ math_charinset.C 25 Mar 2002 12:01:57 -0000 +@@ -5,8 +5,6 @@ + #endif + + #include "math_charinset.h" +-#include "LColor.h" +-#include "Painter.h" + #include "support/LOstream.h" + #include "font.h" + #include "debug.h" +@@ -27,33 +25,29 @@ using std::strchr; + #endif + + +-bool isBinaryOp(char c, MathTextCodes type) +-{ +- return type < LM_TC_SYMB && strchr("+-<>=/*", c); +-} ++namespace { + ++ bool isBinaryOp(char c, MathTextCodes type) ++ { ++ return type < LM_TC_SYMB && strchr("+-<>=/*", c); ++ } + +-MathCharInset::MathCharInset(char c) +- : char_(c), code_(nativeCode(c)) +-{ +-//lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl; +-} + ++ MathTextCodes nativeCode(char c) ++ { ++ if (isalpha(c)) ++ return LM_TC_VAR; ++ //if (strchr("0123456789;:!|[]().,?+/-*<>=", c) ++ return LM_TC_CONST; ++ } + +-MathCharInset::MathCharInset(char c, MathTextCodes t) +- : char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t) +-{ +-//lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl; + } + + +-MathTextCodes MathCharInset::nativeCode(char c) +-{ +- if (isalpha(c)) +- return LM_TC_VAR; +- //if (strchr("0123456789;:!|[]().,?+/-*<>=", c) +- return LM_TC_CONST; +-} ++MathCharInset::MathCharInset(char c) ++ : char_(c) ++{} ++ + + + MathInset * MathCharInset::clone() const +@@ -64,19 +58,18 @@ MathInset * MathCharInset::clone() const + + void MathCharInset::metrics(MathMetricsInfo const & mi) const + { +- whichFont(font_, code_, mi); +- mathed_char_dim(font_, char_, ascent_, descent_, width_); +- if (isBinaryOp(char_, code_)) +- width_ += 2 * lyxfont::width(' ', font_); ++ mathed_char_dim(mi.font, char_, ascent_, descent_, width_); ++ if (isBinaryOp(char_, mi.code)) ++ width_ += 2 * lyxfont::width(' ', mi.font); + } + + +-void MathCharInset::draw(Painter & pain, int x, int y) const ++void MathCharInset::draw(MathPainterInfo & pain, int x, int y) const + { + //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl; +- if (isBinaryOp(char_, code_)) +- x += lyxfont::width(' ', font_); +- drawChar(pain, font_, x, y, char_); ++ if (isBinaryOp(char_, pain.code)) ++ x += lyxfont::width(' ', pain.font); ++ drawChar(pain, pain.font, x, y, char_); + } + + +@@ -95,31 +88,9 @@ void MathCharInset::drawT(TextPainter & + } + + +-void MathCharInset::writeHeader(ostream & os) const +-{ +- if (math_font_name(code_)) +- os << '\\' << math_font_name(code_) << '{'; +-} +- +- +-void MathCharInset::writeTrailer(ostream & os) const +-{ +- if (math_font_name(code_)) +- os << '}'; +-} +- +- +-void MathCharInset::writeRaw(ostream & os) const +-{ +- os << char_; +-} +- +- + void MathCharInset::write(WriteStream & os) const + { +- writeHeader(os.os()); +- writeRaw(os.os()); +- writeTrailer(os.os()); ++ os << char_; + } + + +@@ -135,23 +106,8 @@ bool MathCharInset::isRelOp() const + } + + +-void MathCharInset::handleFont(MathTextCodes t) +-{ +- code_ = (code_ == t) ? LM_TC_VAR : t; +-} +- +- +-void MathCharInset::validate(LaTeXFeatures & features) const +-{ +- // Make sure amssymb is put in preamble if Blackboard Bold or +- // Fraktur used: +- if ((code_ == LM_TC_BB) || (code_ == LM_TC_EUFRAK)) +- features.require("amssymb"); +-} +- +- + bool MathCharInset::match(MathInset * p) const + { + MathCharInset const * q = p->asCharInset(); +- return q && char_ == q->char_ && code_ == q->code_; ++ return q && char_ == q->char_; + } +Index: math_charinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_charinset.h,v +retrieving revision 1.20 +diff -u -p -r1.20 math_charinset.h +--- math_charinset.h 21 Mar 2002 06:57:13 -0000 1.20 ++++ math_charinset.h 25 Mar 2002 12:01:57 -0000 +@@ -17,15 +17,11 @@ public: + /// + explicit MathCharInset(char c); + /// +- MathCharInset(char c, MathTextCodes t); +- /// + MathInset * clone() const; + /// +- static MathTextCodes nativeCode(char c); +- /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void metricsT(TextMetricsInfo const & st) const; + /// +@@ -33,26 +29,14 @@ public: + /// + void write(WriteStream & os) const; + /// +- void writeHeader(std::ostream &) const; +- /// +- void writeTrailer(std::ostream &) const; +- /// +- void writeRaw(std::ostream &) const; +- /// + void normalize(NormalStream &) const; + /// identifies Charinsets + MathCharInset const * asCharInset() const { return this; } + /// + char getChar() const { return char_; } + /// +- MathTextCodes code() const { return code_; } +- /// + bool isRelOp() const; + /// +- void validate(LaTeXFeatures & features) const; +- /// +- void handleFont(MathTextCodes t); +- /// + bool match(MathInset *) const; + /// identifies complicated things that need braces if used as arg + bool needsBraces() const { return false; } +@@ -60,9 +44,5 @@ public: + private: + /// the character + char char_; +- /// the font to be used on screen +- MathTextCodes code_; +- /// +- mutable LyXFont font_; + }; + #endif +Index: math_cursor.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_cursor.C,v +retrieving revision 1.248 +diff -u -p -r1.248 math_cursor.C +--- math_cursor.C 22 Mar 2002 09:31:26 -0000 1.248 ++++ math_cursor.C 25 Mar 2002 12:01:57 -0000 +@@ -171,7 +171,7 @@ Selection theSelection; + + + MathCursor::MathCursor(InsetFormulaBase * formula, bool left) +- : formula_(formula), lastcode_(LM_TC_MIN), selection_(false) ++ : formula_(formula), selection_(false) + { + left ? first() : last(); + } +@@ -299,11 +299,9 @@ bool MathCursor::left(bool sel) + dump("Left 1"); + if (inMacroMode()) { + macroModeClose(); +- lastcode_ = LM_TC_MIN; + return true; + } + selHandle(sel); +- lastcode_ = LM_TC_MIN; + + if (hasPrevAtom() && openable(prevAtom(), sel)) { + if (prevAtom()->isHyperActive()) { +@@ -322,11 +320,9 @@ bool MathCursor::right(bool sel) + dump("Right 1"); + if (inMacroMode()) { + macroModeClose(); +- lastcode_ = LM_TC_MIN; + return true; + } + selHandle(sel); +- lastcode_ = LM_TC_MIN; + + if (hasNextAtom() && openable(nextAtom(), sel)) { + if (nextAtom()->isHyperActive()) { +@@ -395,7 +391,6 @@ void MathCursor::home(bool sel) + dump("home 1"); + selHandle(sel); + macroModeClose(); +- lastcode_ = LM_TC_MIN; + if (!par()->idxHome(idx(), pos())) + popLeft(); + dump("home 2"); +@@ -407,7 +402,6 @@ void MathCursor::end(bool sel) + dump("end 1"); + selHandle(sel); + macroModeClose(); +- lastcode_ = LM_TC_MIN; + if (!par()->idxEnd(idx(), pos())) + popRight(); + dump("end 2"); +@@ -423,7 +417,7 @@ void MathCursor::plainErase() + void MathCursor::markInsert() + { + //lyxerr << "inserting mark\n"; +- array().insert(pos(), MathAtom(new MathCharInset(0, lastcode_))); ++ array().insert(pos(), MathAtom(new MathCharInset(0))); + } + + +@@ -441,16 +435,10 @@ void MathCursor::plainInsert(MathAtom co + } + + +-void MathCursor::insert(char c, MathTextCodes t) +-{ +- //lyxerr << "inserting '" << c << "'\n"; +- plainInsert(MathAtom(new MathCharInset(c, t))); +-} +- +- + void MathCursor::insert(char c) + { +- insert(c, lastcode_); ++ //lyxerr << "inserting '" << c << "'\n"; ++ plainInsert(MathAtom(new MathCharInset(c))); + } + + +@@ -741,7 +729,7 @@ void MathCursor::selGet(MathArray & ar) + + + +-void MathCursor::drawSelection(Painter & pain) const ++void MathCursor::drawSelection(MathPainterInfo & pain) const + { + if (!selection_) + return; +@@ -756,7 +744,7 @@ void MathCursor::drawSelection(Painter & + int y1 = c.yo() - c.ascent(); + int x2 = c.xo() + c.pos2x(i2.pos_); + int y2 = c.yo() + c.descent(); +- pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection); ++ pain.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection); + } else { + vector indices + = i1.par_->idxBetween(i1.idx_, i2.idx_); +@@ -766,7 +754,7 @@ void MathCursor::drawSelection(Painter & + int y1 = c.yo() - c.ascent(); + int x2 = c.xo() + c.width(); + int y2 = c.yo() + c.descent(); +- pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection); ++ pain.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection); + } + } + +@@ -784,23 +772,6 @@ void MathCursor::drawSelection(Painter & + } + + +-void MathCursor::handleFont(MathTextCodes t) +-{ +- macroModeClose(); +- if (selection_) { +- MathCursorPos i1; +- MathCursorPos i2; +- getSelection(i1, i2); +- if (i1.idx_ == i2.idx_) { +- MathArray & ar = i1.cell(); +- for (MathInset::pos_type pos = i1.pos_; pos != i2.pos_; ++pos) +- ar.at(pos)->handleFont(t); +- } +- } else +- lastcode_ = (lastcode_ == t) ? LM_TC_VAR : t; +-} +- +- + void MathCursor::handleDelim(string const & l, string const & r) + { + handleNest(new MathDelimInset(l, r)); +@@ -866,7 +837,7 @@ MathCursor::pos_type & MathCursor::pos() + + bool MathCursor::inMacroMode() const + { +- return macroNamePos() != -1; ++ return false; + } + + +@@ -1369,11 +1340,6 @@ bool MathCursor::interpret(string const + return true; + } + +- latexkeys const * l = in_word_set(s.substr(1)); +- if (l && (l->token == LM_TK_FONT || l->token == LM_TK_OLDFONT)) { +- lastcode_ = static_cast(l->id); +- return true; +- } + + // prevent entering of recursive macros + if (formula()->lyxCode() == Inset::MATHMACRO_CODE +@@ -1423,7 +1389,7 @@ bool MathCursor::interpret(char c) + int n = c - '0'; + MathMacroTemplate * p = formula()->par()->asMacroTemplate(); + if (p && 1 <= n && n <= p->numargs()) +- insert(MathAtom(new MathMacroArgument(c - '0', lastcode_))); ++ insert(MathAtom(new MathMacroArgument(c - '0'))); + else { + insert(MathAtom(new MathSpecialCharInset('#'))); + interpret(c); // try again +@@ -1442,12 +1408,12 @@ bool MathCursor::interpret(char c) + } + + if (isalpha(c)) { +- insert(c, LM_TC_TEX); ++ insert(c); // LM_TC_TEX; + return true; + } + + if (name == "\\") { +- insert(c, LM_TC_TEX); ++ insert(c); // LM_TC_TEX; + macroModeClose(); + return true; + } +@@ -1455,9 +1421,9 @@ bool MathCursor::interpret(char c) + macroModeClose(); + + if (c == '\\') +- insert(c, LM_TC_TEX); ++ insert(c); // LM_TC_TEX; + else if (c != ' ') +- insert(c, lastcode_); ++ insert(c); // lastcode_; + + return true; + } +@@ -1469,13 +1435,13 @@ bool MathCursor::interpret(char c) + // fall through in the other cases + } + +- if (lastcode_ == LM_TC_TEXTRM || par()->asBoxInset()) { ++ if ( /*lastcode_ == LM_TC_TEXTRM || */par()->asBoxInset()) { + // suppress direct insertion of two spaces in a row + // the still allows typing 'a' and deleting the 'a', but + // it is better than nothing... + if (c == ' ' && hasPrevAtom() && prevAtom()->getChar() == ' ') + return true; +- insert(c, LM_TC_TEXTRM); ++ insert(c); // LM_TC_TEXTRM; + return true; + } + +@@ -1491,13 +1457,13 @@ bool MathCursor::interpret(char c) + } + + if (c == '#') { +- insert(c, LM_TC_TEX); ++ insert(c); // LM_TC_TEX; + return true; + } + + /* + if (c == '{' || c == '}', c)) { +- insert(c, LM_TC_TEX); ++ insert(c); // LM_TC_TEX; + return true; + } + */ +@@ -1513,10 +1479,10 @@ bool MathCursor::interpret(char c) + + if (c == '$' || c == '%') { + insert(MathAtom(new MathSpecialCharInset(c))); +- lastcode_ = LM_TC_VAR; + return true; + } + ++/* + if (isalpha(c) && lastcode_ == LM_TC_GREEK) { + insert(c, LM_TC_VAR); + return true; +@@ -1533,10 +1499,10 @@ bool MathCursor::interpret(char c) + //bv->owner()->message(_("TeX mode")); + return true; + } ++*/ + + // no special circumstances, so insert the character without any fuss +- insert(c, lastcode_ == LM_TC_MIN ? MathCharInset::nativeCode(c) : lastcode_); +- lastcode_ = LM_TC_MIN; ++ insert(c); + return true; + } + +Index: math_cursor.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_cursor.h,v +retrieving revision 1.103 +diff -u -p -r1.103 math_cursor.h +--- math_cursor.h 21 Mar 2002 17:42:55 -0000 1.103 ++++ math_cursor.h 25 Mar 2002 12:01:57 -0000 +@@ -27,7 +27,7 @@ + #include "LString.h" + + class InsetFormulaBase; +-class Painter; ++class MathPainterInfo; + class Selection; + + /** +@@ -149,9 +149,7 @@ public: + /// + void selGet(MathArray & ar); + /// +- void drawSelection(Painter & pain) const; +- /// +- void handleFont(MathTextCodes t); ++ void drawSelection(MathPainterInfo & pain) const; + /// + void handleDelim(string const & l, string const & r); + /// +@@ -163,14 +161,12 @@ public: + /// read contents of line into an array + void readLine(MathArray & ar) const; + /// remove this as soon as LyXFunc::getStatus is "localized" +- MathTextCodes getLastCode() const { return lastcode_; } ++ MathTextCodes getLastCode() const { return LM_TC_MIN; } + /// + void pullArg(bool goright); + /// + bool isInside(MathInset const *) const; + /// +- MathTextCodes nextCode() const; +- /// + char valign() const; + /// + char halign() const; +@@ -266,8 +262,6 @@ private: + string macroName() const; + /// + MathInset::difference_type macroNamePos() const; +- /// +- void insert(char, MathTextCodes t); + /// can we enter the inset? + bool openable(MathAtom const &, bool selection) const; + /// write access to cursor cell position +@@ -281,11 +275,11 @@ private: + mutable cursor_type Anchor_; + /// pointer to enclsing LyX inset + InsetFormulaBase * formula_; +- /// text code of last char entered +- MathTextCodes lastcode_; + // Selection stuff + /// do we currently select + bool selection_; ++ /// are we entering a macro name? ++ bool macromode_; + }; + + extern MathCursor * mathcursor; +Index: math_decorationinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_decorationinset.C,v +retrieving revision 1.44 +diff -u -p -r1.44 math_decorationinset.C +--- math_decorationinset.C 21 Mar 2002 17:42:55 -0000 1.44 ++++ math_decorationinset.C 25 Mar 2002 12:01:57 -0000 +@@ -94,7 +94,7 @@ void MathDecorationInset::metrics(MathMe + } + + +-void MathDecorationInset::draw(Painter & pain, int x, int y) const ++void MathDecorationInset::draw(MathPainterInfo & pain, int x, int y) const + { + xcell(0).draw(pain, x, y); + if (wide()) +Index: math_decorationinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_decorationinset.h,v +retrieving revision 1.25 +diff -u -p -r1.25 math_decorationinset.h +--- math_decorationinset.h 19 Mar 2002 16:55:58 -0000 1.25 ++++ math_decorationinset.h 25 Mar 2002 12:01:57 -0000 +@@ -20,7 +20,7 @@ public: + /// + MathInset * clone() const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void write(WriteStream & os) const; + /// +Index: math_deliminset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_deliminset.C,v +retrieving revision 1.48 +diff -u -p -r1.48 math_deliminset.C +--- math_deliminset.C 21 Mar 2002 17:42:55 -0000 1.48 ++++ math_deliminset.C 25 Mar 2002 12:01:57 -0000 +@@ -67,7 +67,7 @@ void MathDelimInset::metrics(MathMetrics + } + + +-void MathDelimInset::draw(Painter & pain, int x, int y) const ++void MathDelimInset::draw(MathPainterInfo & pain, int x, int y) const + { + int const w = dw(); + int const b = y - ascent_; +Index: math_deliminset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_deliminset.h,v +retrieving revision 1.25 +diff -u -p -r1.25 math_deliminset.h +--- math_deliminset.h 14 Feb 2002 12:38:02 -0000 1.25 ++++ math_deliminset.h 25 Mar 2002 12:01:57 -0000 +@@ -32,7 +32,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + + /// + void write(WriteStream & os) const; +Index: math_diffinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_diffinset.C,v +retrieving revision 1.2 +diff -u -p -r1.2 math_diffinset.C +--- math_diffinset.C 21 Mar 2002 17:42:55 -0000 1.2 ++++ math_diffinset.C 25 Mar 2002 12:01:57 -0000 +@@ -38,7 +38,7 @@ void MathDiffInset::metrics(MathMetricsI + } + + +-void MathDiffInset::draw(Painter &, int, int) const ++void MathDiffInset::draw(MathPainterInfo &, int, int) const + { + lyxerr << "should not happen\n"; + } +Index: math_diffinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_diffinset.h,v +retrieving revision 1.1 +diff -u -p -r1.1 math_diffinset.h +--- math_diffinset.h 13 Nov 2001 16:27:06 -0000 1.1 ++++ math_diffinset.h 25 Mar 2002 12:01:57 -0000 +@@ -18,7 +18,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + + /// + void normalize(NormalStream &) const; +Index: math_dotsinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_dotsinset.C,v +retrieving revision 1.27 +diff -u -p -r1.27 math_dotsinset.C +--- math_dotsinset.C 21 Mar 2002 17:42:55 -0000 1.27 ++++ math_dotsinset.C 25 Mar 2002 12:01:57 -0000 +@@ -35,7 +35,7 @@ void MathDotsInset::metrics(MathMetricsI + } + + +-void MathDotsInset::draw(Painter & pain, int x, int y) const ++void MathDotsInset::draw(MathPainterInfo & pain, int x, int y) const + { + mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, name_); + char const c = name_[0]; +Index: math_dotsinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_dotsinset.h,v +retrieving revision 1.18 +diff -u -p -r1.18 math_dotsinset.h +--- math_dotsinset.h 21 Mar 2002 17:42:55 -0000 1.18 ++++ math_dotsinset.h 25 Mar 2002 12:01:57 -0000 +@@ -17,7 +17,7 @@ public: + /// + MathInset * clone() const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void write(WriteStream & os) const; + /// +Index: math_exfuncinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_exfuncinset.C,v +retrieving revision 1.12 +diff -u -p -r1.12 math_exfuncinset.C +--- math_exfuncinset.C 21 Mar 2002 17:42:55 -0000 1.12 ++++ math_exfuncinset.C 25 Mar 2002 12:01:57 -0000 +@@ -24,7 +24,7 @@ void MathExFuncInset::metrics(MathMetric + } + + +-void MathExFuncInset::draw(Painter & pain, int x, int y) const ++void MathExFuncInset::draw(MathPainterInfo & pain, int x, int y) const + { + drawStr(pain, font_, x, y, name_); + } +Index: math_exfuncinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_exfuncinset.h,v +retrieving revision 1.8 +diff -u -p -r1.8 math_exfuncinset.h +--- math_exfuncinset.h 19 Mar 2002 16:55:58 -0000 1.8 ++++ math_exfuncinset.h 25 Mar 2002 12:01:57 -0000 +@@ -16,7 +16,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + + /// + void normalize(NormalStream &) const; +Index: math_exintinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_exintinset.C,v +retrieving revision 1.16 +diff -u -p -r1.16 math_exintinset.C +--- math_exintinset.C 21 Mar 2002 17:42:55 -0000 1.16 ++++ math_exintinset.C 25 Mar 2002 12:01:57 -0000 +@@ -55,7 +55,7 @@ void MathExIntInset::metrics(MathMetrics + } + + +-void MathExIntInset::draw(Painter &, int, int) const ++void MathExIntInset::draw(MathPainterInfo &, int, int) const + { + lyxerr << "should not happen" << endl; + } +Index: math_exintinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_exintinset.h,v +retrieving revision 1.8 +diff -u -p -r1.8 math_exintinset.h +--- math_exintinset.h 15 Nov 2001 14:14:37 -0000 1.8 ++++ math_exintinset.h 25 Mar 2002 12:01:57 -0000 +@@ -19,7 +19,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + + /// + void normalize(NormalStream &) const; +Index: math_extern.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_extern.C,v +retrieving revision 1.21 +diff -u -p -r1.21 math_extern.C +--- math_extern.C 21 Mar 2002 17:42:55 -0000 1.21 ++++ math_extern.C 25 Mar 2002 12:01:57 -0000 +@@ -118,16 +118,10 @@ MathScriptInset const * asScript(MathArr + // returns sequence of char with same code starting at it up to end + // it might be less, though... + MathArray::const_iterator charSequence(MathArray::const_iterator it, +- MathArray::const_iterator end, string & s, MathTextCodes & c) ++ MathArray::const_iterator end, string & s) + { +- MathCharInset const * p = (*it)->asCharInset(); +- c = p->code(); +- for (; it != end; ++it) { +- p = (*it)->asCharInset(); +- if (!p || p->code() != c) +- break; +- s += p->getChar(); +- } ++ for (; it != end && (*it)->asCharInset(); ++it) ++ s += (*it)->getChar(); + return it; + } + +@@ -143,7 +137,7 @@ void extractStrings(MathArray & ar) + // create proper string inset + MathStringInset * p = new MathStringInset; + MathArray::const_iterator +- jt = charSequence(it, ar.end(), p->str_, p->code_); ++ jt = charSequence(it, ar.end(), p->str_); + + // clean up + (*it).reset(p); +@@ -196,8 +190,7 @@ bool extractString(MathInset * p, string + bool extractNumber(MathArray const & ar, int & i) + { + string s; +- MathTextCodes c; +- charSequence(ar.begin(), ar.end(), s, c); ++ charSequence(ar.begin(), ar.end(), s); + istringstream is(s.c_str()); + is >> i; + return is; +Index: math_factory.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_factory.C,v +retrieving revision 1.32 +diff -u -p -r1.32 math_factory.C +--- math_factory.C 21 Mar 2002 17:42:55 -0000 1.32 ++++ math_factory.C 25 Mar 2002 12:01:57 -0000 +@@ -8,6 +8,7 @@ + #include "math_casesinset.h" + #include "math_decorationinset.h" + #include "math_dotsinset.h" ++#include "math_fontinset.h" + #include "math_funcinset.h" + #include "math_funcliminset.h" + #include "math_fracinset.h" +@@ -82,6 +83,9 @@ MathAtom createMathInset(latexkeys const + return MathAtom(new MathFuncInset(l->name)); + case LM_TK_STY: + return MathAtom(new MathSizeInset(l)); ++ case LM_TK_FONT: ++ case LM_TK_OLDFONT: ++ return MathAtom(new MathFontInset(static_cast(l->id))); + default: + return MathAtom(new MathUnknownInset(l->name)); + } +Index: math_fontinset.C +=================================================================== +RCS file: math_fontinset.C +diff -N math_fontinset.C +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ math_fontinset.C 25 Mar 2002 12:01:57 -0000 +@@ -0,0 +1,86 @@ ++#include ++ ++#ifdef __GNUG__ ++#pragma implementation ++#endif ++ ++#include "math_fontinset.h" ++#include "support/LOstream.h" ++#include "debug.h" ++#include "math_mathmlstream.h" ++#include "math_support.h" ++#include "LaTeXFeatures.h" ++#include "textpainter.h" ++ ++ ++MathFontInset::MathFontInset(MathTextCodes code) ++ : MathNestInset(1), code_(code) ++{} ++ ++ ++MathInset * MathFontInset::clone() const ++{ ++ return new MathFontInset(*this); ++} ++ ++ ++void MathFontInset::metrics(MathMetricsInfo const & mi) const ++{ ++ MathMetricsInfo m = mi; ++ whichFont(m.font, code_, mi); ++ font_ = mi.font; ++ xcell(0).metrics(m); ++ width_ = xcell(0).width(); ++ ascent_ = xcell(0).ascent(); ++ descent_ = xcell(0).descent(); ++} ++ ++ ++void MathFontInset::draw(MathPainterInfo & pain, int x, int y) const ++{ ++ lyxerr << "MathFontInset::draw\n"; ++ xcell(0).draw(pain, x, y); ++} ++ ++ ++void MathFontInset::metricsT(TextMetricsInfo const & mi) const ++{ ++ xcell(0).metricsT(mi); ++ width_ = xcell(0).width(); ++ ascent_ = xcell(0).ascent(); ++ descent_ = xcell(0).descent(); ++} ++ ++ ++void MathFontInset::drawT(TextPainter & pain, int x, int y) const ++{ ++ //lyxerr << "drawing font code: " << code_ << '\n'; ++ xcell(0).drawT(pain, x, y); ++} ++ ++ ++void MathFontInset::write(WriteStream & os) const ++{ ++ os << math_font_name(code_) << '{' << cell(0) << '}'; ++} ++ ++ ++void MathFontInset::normalize(NormalStream & os) const ++{ ++ os << "[font_ " << code_ << " " << cell(0) << "]"; ++} ++ ++ ++void MathFontInset::handleFont(MathTextCodes t) ++{ ++ code_ = (code_ == t) ? LM_TC_VAR : t; ++} ++ ++ ++void MathFontInset::validate(LaTeXFeatures & features) const ++{ ++ // Make sure amssymb is put in preamble if Blackboard Bold or ++ // Fraktur used: ++ if ((code_ == LM_TC_BB) || (code_ == LM_TC_EUFRAK)) ++ features.require("amssymb"); ++} +Index: math_fontinset.h +=================================================================== +RCS file: math_fontinset.h +diff -N math_fontinset.h +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ math_fontinset.h 25 Mar 2002 12:01:57 -0000 +@@ -0,0 +1,48 @@ ++// -*- C++ -*- ++#ifndef MATH_FONTINSET_H ++#define MATH_FONTINSET_H ++ ++#include "math_nestinset.h" ++ ++#ifdef __GNUG__ ++#pragma interface ++#endif ++ ++/** The base character inset. ++ \author André Pönitz ++ */ ++ ++class MathFontInset : public MathNestInset { ++public: ++ /// ++ explicit MathFontInset(MathTextCodes t); ++ /// ++ MathInset * clone() const; ++ /// ++ void metrics(MathMetricsInfo const & st) const; ++ /// ++ void draw(MathPainterInfo &, int x, int y) const; ++ /// ++ void metricsT(TextMetricsInfo const & st) const; ++ /// ++ void drawT(TextPainter &, int x, int y) const; ++ /// ++ void write(WriteStream & os) const; ++ /// ++ void normalize(NormalStream &) const; ++ /// identifies Fontinsets ++ MathFontInset const * asFontInset() const { return this; } ++ /// ++ MathTextCodes code() const { return code_; } ++ /// ++ void validate(LaTeXFeatures & features) const; ++ /// ++ void handleFont(MathTextCodes t); ++ ++private: ++ /// the font to be used on screen ++ MathTextCodes code_; ++ /// ++ mutable LyXFont font_; ++}; ++#endif +Index: math_fracinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_fracinset.C,v +retrieving revision 1.44 +diff -u -p -r1.44 math_fracinset.C +--- math_fracinset.C 21 Mar 2002 17:42:55 -0000 1.44 ++++ math_fracinset.C 25 Mar 2002 12:01:57 -0000 +@@ -41,13 +41,13 @@ void MathFracInset::metrics(MathMetricsI + } + + +-void MathFracInset::draw(Painter & pain, int x, int y) const ++void MathFracInset::draw(MathPainterInfo & pain, int x, int y) const + { + int m = x + width() / 2; + xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 2 - 5); + xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent() + 2 - 5); + if (!atop_) +- pain.line(x, y - 5, x + width(), y - 5, LColor::math); ++ pain.pain.line(x, y - 5, x + width(), y - 5, LColor::math); + } + + +Index: math_fracinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_fracinset.h,v +retrieving revision 1.28 +diff -u -p -r1.28 math_fracinset.h +--- math_fracinset.h 21 Mar 2002 06:57:13 -0000 1.28 ++++ math_fracinset.h 25 Mar 2002 12:01:57 -0000 +@@ -20,7 +20,7 @@ public: + /// + void metrics(MathMetricsInfo const & mi) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void metricsT(TextMetricsInfo const & mi) const; + /// +Index: math_funcinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_funcinset.C,v +retrieving revision 1.37 +diff -u -p -r1.37 math_funcinset.C +--- math_funcinset.C 21 Mar 2002 17:42:55 -0000 1.37 ++++ math_funcinset.C 25 Mar 2002 12:01:57 -0000 +@@ -6,7 +6,6 @@ + + #include "math_funcinset.h" + #include "font.h" +-#include "Painter.h" + #include "math_support.h" + #include "math_mathmlstream.h" + #include "math_streamstr.h" +@@ -45,7 +44,7 @@ void MathFuncInset::metrics(MathMetricsI + } + + +-void MathFuncInset::draw(Painter & pain, int x, int y) const ++void MathFuncInset::draw(MathPainterInfo & pain, int x, int y) const + { + drawStr(pain, font_, x, y, name_); + } +Index: math_funcinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_funcinset.h,v +retrieving revision 1.26 +diff -u -p -r1.26 math_funcinset.h +--- math_funcinset.h 19 Mar 2002 16:55:58 -0000 1.26 ++++ math_funcinset.h 25 Mar 2002 12:01:57 -0000 +@@ -21,7 +21,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + string const & name() const; + /// identifies FuncInsets +Index: math_funcliminset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_funcliminset.C,v +retrieving revision 1.14 +diff -u -p -r1.14 math_funcliminset.C +--- math_funcliminset.C 21 Mar 2002 17:42:55 -0000 1.14 ++++ math_funcliminset.C 25 Mar 2002 12:01:57 -0000 +@@ -43,7 +43,7 @@ void MathFuncLimInset::metrics(MathMetri + } + + +-void MathFuncLimInset::draw(Painter & pain, int x, int y) const ++void MathFuncLimInset::draw(MathPainterInfo & pain, int x, int y) const + { + drawStr(pain, font_, x, y, name_); + } +Index: math_funcliminset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_funcliminset.h,v +retrieving revision 1.8 +diff -u -p -r1.8 math_funcliminset.h +--- math_funcliminset.h 19 Mar 2002 16:55:58 -0000 1.8 ++++ math_funcliminset.h 25 Mar 2002 12:01:57 -0000 +@@ -20,7 +20,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + bool isScriptable() const; + +Index: math_gridinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_gridinset.C,v +retrieving revision 1.60 +diff -u -p -r1.60 math_gridinset.C +--- math_gridinset.C 21 Mar 2002 17:42:55 -0000 1.60 ++++ math_gridinset.C 25 Mar 2002 12:01:57 -0000 +@@ -355,7 +355,7 @@ void MathGridInset::metrics(MathMetricsI + } + + +-void MathGridInset::draw(Painter & pain, int x, int y) const ++void MathGridInset::draw(MathPainterInfo & pain, int x, int y) const + { + for (idx_type idx = 0; idx < nargs(); ++idx) + xcell(idx).draw(pain, x + cellXOffset(idx), y + cellYOffset(idx)); +@@ -364,14 +364,14 @@ void MathGridInset::draw(Painter & pain, + for (int i = 0; i < rowinfo_[row].lines_; ++i) { + int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_ + - i * hlinesep() - hlinesep()/2 - rowsep()/2; +- pain.line(x + 1, yy, x + width_ - 1, yy); ++ pain.pain.line(x + 1, yy, x + width_ - 1, yy); + } + + for (col_type col = 0; col <= ncols(); ++col) + for (int i = 0; i < colinfo_[col].lines_; ++i) { + int xx = x + colinfo_[col].offset_ + - i * vlinesep() - vlinesep()/2 - colsep()/2; +- pain.line(xx, y - ascent_ + 1, xx, y + descent_ - 1); ++ pain.pain.line(xx, y - ascent_ + 1, xx, y + descent_ - 1); + } + } + +Index: math_gridinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_gridinset.h,v +retrieving revision 1.38 +diff -u -p -r1.38 math_gridinset.h +--- math_gridinset.h 21 Mar 2002 17:42:55 -0000 1.38 ++++ math_gridinset.h 25 Mar 2002 12:01:57 -0000 +@@ -72,7 +72,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void metricsT(TextMetricsInfo const & st) const; + /// +Index: math_hullinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_hullinset.C,v +retrieving revision 1.21 +diff -u -p -r1.21 math_hullinset.C +--- math_hullinset.C 21 Mar 2002 17:42:56 -0000 1.21 ++++ math_hullinset.C 25 Mar 2002 12:01:57 -0000 +@@ -186,7 +186,7 @@ void MathHullInset::metrics(MathMetricsI + } + + +-void MathHullInset::draw(Painter & pain, int x, int y) const ++void MathHullInset::draw(MathPainterInfo & pain, int x, int y) const + { + MathGridInset::draw(pain, x, y); + +Index: math_hullinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_hullinset.h,v +retrieving revision 1.10 +diff -u -p -r1.10 math_hullinset.h +--- math_hullinset.h 21 Mar 2002 17:42:56 -0000 1.10 ++++ math_hullinset.h 25 Mar 2002 12:01:57 -0000 +@@ -29,7 +29,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + //void metricsT(TextMetricsInfo const & st) const; + /// +Index: math_inset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_inset.C,v +retrieving revision 1.79 +diff -u -p -r1.79 math_inset.C +--- math_inset.C 21 Mar 2002 17:42:56 -0000 1.79 ++++ math_inset.C 25 Mar 2002 12:01:57 -0000 +@@ -194,7 +194,7 @@ void MathInset::metrics(MathMetricsInfo + } + + +-void MathInset::draw(Painter &, int, int) const ++void MathInset::draw(MathPainterInfo &, int, int) const + { + lyxerr << "MathInset::draw() called directly!\n"; + } +Index: math_inset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_inset.h,v +retrieving revision 1.108 +diff -u -p -r1.108 math_inset.h +--- math_inset.h 21 Mar 2002 17:42:56 -0000 1.108 ++++ math_inset.h 25 Mar 2002 12:01:57 -0000 +@@ -107,7 +107,7 @@ public: + // updates the (xo,yo)-caches of all contained cells + virtual void metrics(MathMetricsInfo const & st) const; + /// draw the object +- virtual void draw(Painter &, int x, int y) const; ++ virtual void draw(MathPainterInfo &, int x, int y) const; + /// the ascent of the inset above the baseline + /// compute the size of the object for text based drawing + virtual void metricsT(TextMetricsInfo const & st) const; +Index: math_kerninset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_kerninset.C,v +retrieving revision 1.9 +diff -u -p -r1.9 math_kerninset.C +--- math_kerninset.C 21 Mar 2002 17:42:56 -0000 1.9 ++++ math_kerninset.C 25 Mar 2002 12:01:57 -0000 +@@ -31,7 +31,7 @@ MathInset * MathKernInset::clone() const + } + + +-void MathKernInset::draw(Painter &, int, int) const ++void MathKernInset::draw(MathPainterInfo &, int, int) const + {} + + +Index: math_kerninset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_kerninset.h,v +retrieving revision 1.4 +diff -u -p -r1.4 math_kerninset.h +--- math_kerninset.h 9 Nov 2001 08:35:56 -0000 1.4 ++++ math_kerninset.h 25 Mar 2002 12:01:57 -0000 +@@ -23,7 +23,7 @@ public: + /// + MathInset * clone() const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void write(WriteStream & os) const; + /// +Index: math_lefteqninset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_lefteqninset.C,v +retrieving revision 1.6 +diff -u -p -r1.6 math_lefteqninset.C +--- math_lefteqninset.C 3 Jan 2002 12:02:54 -0000 1.6 ++++ math_lefteqninset.C 25 Mar 2002 12:01:57 -0000 +@@ -27,7 +27,7 @@ void MathLefteqnInset::metrics(MathMetri + } + + +-void MathLefteqnInset::draw(Painter & pain, int x, int y) const ++void MathLefteqnInset::draw(MathPainterInfo & pain, int x, int y) const + { + xcell(0).draw(pain, x + 2, y); + //mathed_draw_framebox(pain, x, y, this); +Index: math_lefteqninset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_lefteqninset.h,v +retrieving revision 1.4 +diff -u -p -r1.4 math_lefteqninset.h +--- math_lefteqninset.h 9 Nov 2001 08:35:56 -0000 1.4 ++++ math_lefteqninset.h 25 Mar 2002 12:01:57 -0000 +@@ -17,7 +17,7 @@ public: + /// + MathInset * clone() const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void write(WriteStream & os) const; + /// +Index: math_limitopinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_limitopinset.C,v +retrieving revision 1.5 +diff -u -p -r1.5 math_limitopinset.C +--- math_limitopinset.C 21 Mar 2002 17:42:56 -0000 1.5 ++++ math_limitopinset.C 25 Mar 2002 12:01:58 -0000 +@@ -37,7 +37,7 @@ void MathLimitOpInset::metrics(MathMetri + } + + +-void MathLimitOpInset::draw(Painter &, int, int) const ++void MathLimitOpInset::draw(MathPainterInfo &, int, int) const + { + lyxerr << "should not happen\n"; + } +Index: math_limitopinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_limitopinset.h,v +retrieving revision 1.1 +diff -u -p -r1.1 math_limitopinset.h +--- math_limitopinset.h 9 Nov 2001 14:23:44 -0000 1.1 ++++ math_limitopinset.h 25 Mar 2002 12:01:58 -0000 +@@ -16,7 +16,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void write(WriteStream & os) const; + /// +Index: math_macro.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macro.C,v +retrieving revision 1.99 +diff -u -p -r1.99 math_macro.C +--- math_macro.C 21 Mar 2002 17:42:56 -0000 1.99 ++++ math_macro.C 25 Mar 2002 12:01:58 -0000 +@@ -27,7 +27,6 @@ + #include "support/lstrings.h" + #include "support/LAssert.h" + #include "debug.h" +-#include "Painter.h" + #include "LaTeXFeatures.h" + + +@@ -109,7 +108,7 @@ void MathMacro::metrics(MathMetricsInfo + } + + +-void MathMacro::draw(Painter & pain, int x, int y) const ++void MathMacro::draw(MathPainterInfo & pain, int x, int y) const + { + metrics(mi_); + +Index: math_macro.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macro.h,v +retrieving revision 1.70 +diff -u -p -r1.70 math_macro.h +--- math_macro.h 21 Mar 2002 17:42:56 -0000 1.70 ++++ math_macro.h 25 Mar 2002 12:01:58 -0000 +@@ -42,7 +42,7 @@ public: + /// + MathMacro(MathMacro const &); + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void metrics(MathMetricsInfo const & st) const; + /// +Index: math_macroarg.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macroarg.C,v +retrieving revision 1.36 +diff -u -p -r1.36 math_macroarg.C +--- math_macroarg.C 21 Mar 2002 17:42:56 -0000 1.36 ++++ math_macroarg.C 25 Mar 2002 12:01:58 -0000 +@@ -4,7 +4,6 @@ + + #include "math_macroarg.h" + #include "math_macro.h" +-#include "math_defs.h" + #include "math_mathmlstream.h" + #include "math_support.h" + #include "debug.h" +@@ -13,8 +12,8 @@ + using std::endl; + + +-MathMacroArgument::MathMacroArgument(int n, MathTextCodes code) +- : MathNestInset(1), number_(n), expanded_(false), code_(code) ++MathMacroArgument::MathMacroArgument(int n) ++ : MathNestInset(1), number_(n), expanded_(false) + { + if (n < 1 || n > 9) { + lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: " +@@ -34,10 +33,7 @@ MathInset * MathMacroArgument::clone() c + + void MathMacroArgument::write(WriteStream & os) const + { +- if (code_ == LM_TC_MIN) +- os << str_; +- else +- os << '\\' << math_font_name(code_) << '{' << str_ << '}'; ++ os << str_; + } + + +@@ -54,7 +50,7 @@ void MathMacroArgument::metrics(MathMetr + } + + +-void MathMacroArgument::draw(Painter & pain, int x, int y) const ++void MathMacroArgument::draw(MathPainterInfo & pain, int x, int y) const + { + if (expanded_) + xcell(0).draw(pain, x, y); +@@ -72,8 +68,5 @@ void MathMacroArgument::normalize(Normal + void MathMacroArgument::substitute(MathMacro const & m) + { + cell(0) = m.cell(number_ - 1); +- if (code_ != LM_TC_MIN) +- for (MathArray::iterator it = cell(0).begin(); it != cell(0).end(); ++it) +- it->nucleus()->handleFont(code_); + expanded_ = true; + } +Index: math_macroarg.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macroarg.h,v +retrieving revision 1.25 +diff -u -p -r1.25 math_macroarg.h +--- math_macroarg.h 19 Mar 2002 16:55:58 -0000 1.25 ++++ math_macroarg.h 25 Mar 2002 12:01:58 -0000 +@@ -14,7 +14,7 @@ + class MathMacroArgument : public MathNestInset { + public: + /// +- explicit MathMacroArgument(int, MathTextCodes = LM_TC_MIN); ++ explicit MathMacroArgument(int); + /// + MathInset * clone() const; + /// +@@ -22,7 +22,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void substitute(MathMacro const & macro); + +@@ -40,8 +40,6 @@ private: + bool expanded_; + /// + mutable LyXFont font_; +- /// +- MathTextCodes code_; + }; + + #endif +Index: math_macrotemplate.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macrotemplate.C,v +retrieving revision 1.43 +diff -u -p -r1.43 math_macrotemplate.C +--- math_macrotemplate.C 16 Feb 2002 15:59:54 -0000 1.43 ++++ math_macrotemplate.C 25 Mar 2002 12:01:58 -0000 +@@ -59,10 +59,10 @@ void MathMacroTemplate::metrics(MathMetr + } + + +-void MathMacroTemplate::draw(Painter & pain, int x, int y) const ++void MathMacroTemplate::draw(MathPainterInfo & pain, int x, int y) const + { + xcell(0).draw(pain, x + 2, y + 1); +- pain.rectangle(x, y - ascent(), width(), height(), LColor::blue); ++ pain.pain.rectangle(x, y - ascent(), width(), height(), LColor::blue); + } + + +Index: math_macrotemplate.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macrotemplate.h,v +retrieving revision 1.29 +diff -u -p -r1.29 math_macrotemplate.h +--- math_macrotemplate.h 21 Mar 2002 17:42:56 -0000 1.29 ++++ math_macrotemplate.h 25 Mar 2002 12:01:58 -0000 +@@ -33,7 +33,7 @@ public: + /// + string const & name() const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void metrics(MathMetricsInfo const & st) const; + /// identifies macro templates +Index: math_metricsinfo.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_metricsinfo.C,v +retrieving revision 1.1 +diff -u -p -r1.1 math_metricsinfo.C +--- math_metricsinfo.C 19 Oct 2001 17:46:13 -0000 1.1 ++++ math_metricsinfo.C 25 Mar 2002 12:01:58 -0000 +@@ -0,0 +1,12 @@ ++ ++#include ++ ++#include "math_metricsinfo.h" ++#include "math_support.h" ++ ++ ++MathPainterInfo::MathPainterInfo(Painter & p) ++ : pain(p), style(LM_ST_TEXT), code(LM_TC_MIN) ++{ ++ //whichFont(font, LM_TC_MIN); ++} +Index: math_metricsinfo.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_metricsinfo.h,v +retrieving revision 1.6 +diff -u -p -r1.6 math_metricsinfo.h +--- math_metricsinfo.h 21 Mar 2002 06:57:13 -0000 1.6 ++++ math_metricsinfo.h 25 Mar 2002 12:01:58 -0000 +@@ -2,8 +2,10 @@ + #define MATH_METRICSINFO_H + + #include "lyxfont.h" ++#include "math_defs.h" + + class BufferView; ++class Painter; + class MathNestInset; + + +@@ -23,13 +25,13 @@ enum MathStyles { + struct MathMetricsInfo { + /// + MathMetricsInfo() +- : view(0), font(), style(LM_ST_TEXT), ++ : view(0), font(), style(LM_ST_TEXT), code(LM_TC_MIN), + inset(0), idx(0), + fullredraw(false) + {} + /// + MathMetricsInfo(BufferView * v, LyXFont const & f, MathStyles s) +- : view(v), font(f), style(s), ++ : view(v), font(f), style(s), code(LM_TC_MIN), + inset(0), idx(0), + fullredraw(false) + {} +@@ -40,6 +42,8 @@ struct MathMetricsInfo { + LyXFont font; + /// + MathStyles style; ++ /// ++ MathTextCodes code; + /// used to pass some info down + MathNestInset const * inset; + /// +@@ -54,5 +58,24 @@ struct TextMetricsInfo { + TextMetricsInfo() + {} + }; ++ ++ ++ ++struct MathPainterInfo { ++ /// ++ MathPainterInfo(Painter & p); ++ /// ++ void draw(int x, int y, char c); ++ ++ /// ++ Painter & pain; ++ /// ++ LyXFont font; ++ /// ++ MathStyles style; ++ /// ++ MathTextCodes code; ++}; ++ + + #endif +Index: math_notinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_notinset.C,v +retrieving revision 1.12 +diff -u -p -r1.12 math_notinset.C +--- math_notinset.C 21 Mar 2002 17:42:56 -0000 1.12 ++++ math_notinset.C 25 Mar 2002 12:01:58 -0000 +@@ -40,7 +40,7 @@ void MathNotInset::metrics(MathMetricsIn + } + + +-void MathNotInset::draw(Painter & pain, int x, int y) const ++void MathNotInset::draw(MathPainterInfo & pain, int x, int y) const + { + if (math_font_available(LM_TC_CMSY)) + drawChar(pain, font_, x, y, 54); +Index: math_notinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_notinset.h,v +retrieving revision 1.7 +diff -u -p -r1.7 math_notinset.h +--- math_notinset.h 19 Mar 2002 16:55:58 -0000 1.7 ++++ math_notinset.h 25 Mar 2002 12:01:58 -0000 +@@ -19,7 +19,7 @@ public: + /// + void metrics(MathMetricsInfo const & mi) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + private: + /// + mutable LyXFont font_; +Index: math_parser.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_parser.C,v +retrieving revision 1.189 +diff -u -p -r1.189 math_parser.C +--- math_parser.C 21 Mar 2002 17:42:56 -0000 1.189 ++++ math_parser.C 25 Mar 2002 12:01:58 -0000 +@@ -101,9 +101,9 @@ bool stared(string const & s) + } + + +-void add(MathArray & ar, char c, MathTextCodes code) ++void add(MathArray & ar, char c) + { +- ar.push_back(MathAtom(new MathCharInset(c, code))); ++ ar.push_back(MathAtom(new MathCharInset(c))); + } + + +@@ -252,7 +252,7 @@ public: + /// + bool parse_normal(MathAtom &); + /// +- void parse_into(MathArray & array, unsigned flags, MathTextCodes = LM_TC_MIN); ++ void parse_into(MathArray & array, unsigned flags); + /// + int lineno() const { return lineno_; } + /// +@@ -260,7 +260,7 @@ public: + + private: + /// +- void parse_into1(MathArray & array, unsigned flags, MathTextCodes); ++ void parse_into1(MathArray & array, unsigned flags); + /// + string getArg(char lf, char rf); + /// +@@ -888,9 +888,9 @@ bool Parser::parse_normal(MathAtom & mat + } + + +-void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code) ++void Parser::parse_into(MathArray & array, unsigned flags) + { +- parse_into1(array, flags, code); ++ parse_into1(array, flags); + // remove 'unnecessary' braces: + if (array.size() == 1 && array.back()->asBraceInset()) { + lyxerr << "extra braces removed\n"; +@@ -899,7 +899,7 @@ void Parser::parse_into(MathArray & arra + } + + +-void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code) ++void Parser::parse_into1(MathArray & array, unsigned flags) + { + bool panic = false; + int limits = 0; +@@ -959,14 +959,14 @@ void Parser::parse_into1(MathArray & arr + } + + else if (t.cat() == catLetter) +- add(array, t.character(), code); ++ add(array, t.character()); + +- else if (t.cat() == catSpace && code == LM_TC_TEXTRM) +- add(array, t.character(), code); ++ else if (t.cat() == catSpace) //&& code == LM_TC_TEXTRM ++ add(array, t.character()); + + else if (t.cat() == catParameter) { + Token const & n = getToken(); +- array.push_back(MathAtom(new MathMacroArgument(n.character()-'0', code))); ++ array.push_back(MathAtom(new MathMacroArgument(n.character()-'0'))); + } + + else if (t.cat() == catBegin) { +@@ -994,13 +994,13 @@ void Parser::parse_into1(MathArray & arr + lyxerr << "found '}' unexpectedly, array: '" << array << "'\n"; + //lyxerr << "found '}' unexpectedly\n"; + lyx::Assert(0); +- add(array, '}', LM_TC_TEX); ++ add(array, '}'); //, LM_TC_TEX); + } + + else if (t.cat() == catAlign) { + lyxerr << "found tab unexpectedly, array: '" << array << "'\n"; + //lyxerr << "found tab unexpectedly\n"; +- add(array, '&', LM_TC_TEX); ++ add(array, '&'); //, LM_TC_TEX; + } + + else if (t.cat() == catSuper || t.cat() == catSub) { +@@ -1022,7 +1022,7 @@ void Parser::parse_into1(MathArray & arr + return; + + else if (t.cat() == catOther) +- add(array, t.character(), code); ++ add(array, t.character()); + + // + // control sequences +@@ -1134,7 +1134,7 @@ void Parser::parse_into1(MathArray & arr + else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") { + MathAtom p = createMathInset(t.cs()); + array.swap(p->cell(0)); +- parse_into(p->cell(1), flags, code); ++ parse_into(p->cell(1), flags); + array.push_back(p); + return; + } +@@ -1195,34 +1195,37 @@ void Parser::parse_into1(MathArray & arr + if (l) { + if (l->token == LM_TK_FONT) { + //lyxerr << "starting font\n"; +- //CatCode catSpaceSave = theCatcode[' ']; +- //if (l->id == LM_TC_TEXTRM) { +- // // temporarily change catcode +- // theCatcode[' '] = catLetter; +- //} +- +- MathArray ar; +- parse_into(ar, FLAG_ITEM, static_cast(l->id)); +- array.push_back(ar); ++ CatCode catSpaceSave = theCatcode[' ']; ++ if (l->id == LM_TC_TEXTRM) { ++ // temporarily change catcode ++ theCatcode[' '] = catLetter; ++ } ++ ++ MathAtom p = createMathInset(t.cs()); ++ parse_into(p->cell(0), FLAG_ITEM); ++ array.push_back(p); + + // undo catcode changes +- ////theCatcode[' '] = catSpaceSave; +- //lyxerr << "ending font\n"; ++ theCatcode[' '] = catSpaceSave; ++ lyxerr << "ending font\n"; + } + + else if (l->token == LM_TK_OLDFONT) { +- code = static_cast(l->id); ++ MathAtom p = createMathInset(t.cs()); ++ parse_into(p->cell(0), flags); ++ array.push_back(p); ++ return; + } + + else if (l->token == LM_TK_BOX) { + MathAtom p = createMathInset(t.cs()); +- parse_into(p->cell(0), FLAG_ITEM | FLAG_BOX, LM_TC_BOX); ++ parse_into(p->cell(0), FLAG_ITEM | FLAG_BOX); + array.push_back(p); + } + + else if (l->token == LM_TK_STY) { + MathAtom p = createMathInset(t.cs()); +- parse_into(p->cell(0), flags, code); ++ parse_into(p->cell(0), flags); + array.push_back(p); + return; + } +Index: math_rootinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_rootinset.C,v +retrieving revision 1.20 +diff -u -p -r1.20 math_rootinset.C +--- math_rootinset.C 21 Mar 2002 17:42:56 -0000 1.20 ++++ math_rootinset.C 25 Mar 2002 12:01:58 -0000 +@@ -43,7 +43,7 @@ void MathRootInset::metrics(MathMetricsI + } + + +-void MathRootInset::draw(Painter & pain, int x, int y) const ++void MathRootInset::draw(MathPainterInfo & pain, int x, int y) const + { + int const w = xcell(0).width(); + // the "exponent" +@@ -59,7 +59,7 @@ void MathRootInset::draw(Painter & pain, + xp[2] = x + w; yp[2] = y + d; + xp[3] = x + w - 2; yp[3] = y + (d - a)/2 + 2; + xp[4] = x; yp[4] = y + (d - a)/2 + 2; +- pain.lines(xp, yp, 5, LColor::math); ++ pain.pain.lines(xp, yp, 5, LColor::math); + } + + +Index: math_rootinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_rootinset.h,v +retrieving revision 1.15 +diff -u -p -r1.15 math_rootinset.h +--- math_rootinset.h 21 Mar 2002 17:42:56 -0000 1.15 ++++ math_rootinset.h 25 Mar 2002 12:01:58 -0000 +@@ -36,7 +36,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + + /// + void write(WriteStream & os) const; +Index: math_scriptinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_scriptinset.C,v +retrieving revision 1.51 +diff -u -p -r1.51 math_scriptinset.C +--- math_scriptinset.C 21 Mar 2002 17:42:56 -0000 1.51 ++++ math_scriptinset.C 25 Mar 2002 12:01:58 -0000 +@@ -198,7 +198,7 @@ void MathScriptInset::metrics(MathInset + } + + +-void MathScriptInset::draw(Painter & pain, int x, int y) const ++void MathScriptInset::draw(MathPainterInfo & pain, int x, int y) const + { + //lyxerr << "unexpected call to MathScriptInset::draw()\n"; + draw(0, pain, x, y); +@@ -226,7 +226,7 @@ void MathScriptInset::metricsT(MathInset + } + + +-void MathScriptInset::draw(MathInset const * nuc, Painter & pain, ++void MathScriptInset::draw(MathInset const * nuc, MathPainterInfo & pain, + int x, int y) const + { + if (nuc) +Index: math_scriptinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_scriptinset.h,v +retrieving revision 1.34 +diff -u -p -r1.34 math_scriptinset.h +--- math_scriptinset.h 21 Mar 2002 17:42:56 -0000 1.34 ++++ math_scriptinset.h 25 Mar 2002 12:01:58 -0000 +@@ -27,7 +27,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void metricsT(TextMetricsInfo const & st) const; + /// +@@ -36,7 +36,7 @@ public: + /// + void metrics(MathInset const * nuc, MathMetricsInfo const & st) const; + /// +- void draw(MathInset const * nuc, Painter &, int x, int y) const; ++ void draw(MathInset const * nuc, MathPainterInfo &, int x, int y) const; + /// + void metricsT(MathInset const * nuc, TextMetricsInfo const & st) const; + /// +Index: math_sizeinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_sizeinset.C,v +retrieving revision 1.20 +diff -u -p -r1.20 math_sizeinset.C +--- math_sizeinset.C 3 Jan 2002 12:02:54 -0000 1.20 ++++ math_sizeinset.C 25 Mar 2002 12:01:58 -0000 +@@ -22,7 +22,7 @@ MathInset * MathSizeInset::clone() const + } + + +-void MathSizeInset::draw(Painter & pain, int x, int y) const ++void MathSizeInset::draw(MathPainterInfo & pain, int x, int y) const + { + xcell(0).draw(pain, x + 1, y); + mathed_draw_framebox(pain, x, y, this); +Index: math_sizeinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_sizeinset.h,v +retrieving revision 1.14 +diff -u -p -r1.14 math_sizeinset.h +--- math_sizeinset.h 21 Mar 2002 17:42:56 -0000 1.14 ++++ math_sizeinset.h 25 Mar 2002 12:01:58 -0000 +@@ -24,7 +24,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + bool needsBraces() const { return false; } + +Index: math_spaceinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_spaceinset.C,v +retrieving revision 1.27 +diff -u -p -r1.27 math_spaceinset.C +--- math_spaceinset.C 21 Mar 2002 17:42:56 -0000 1.27 ++++ math_spaceinset.C 25 Mar 2002 12:01:58 -0000 +@@ -34,7 +34,7 @@ void MathSpaceInset::metrics(MathMetrics + } + + +-void MathSpaceInset::draw(Painter & pain, int x, int y) const ++void MathSpaceInset::draw(MathPainterInfo & pain, int x, int y) const + { + + // XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}}; +@@ -49,7 +49,7 @@ void MathSpaceInset::draw(Painter & pain + xp[2] = x + width_ - 2; yp[2] = y; + xp[3] = x + width_ - 2; yp[3] = y - 3; + +- pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math); ++ pain.pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math); + } + + +Index: math_spaceinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_spaceinset.h,v +retrieving revision 1.20 +diff -u -p -r1.20 math_spaceinset.h +--- math_spaceinset.h 15 Nov 2001 14:14:37 -0000 1.20 ++++ math_spaceinset.h 25 Mar 2002 12:01:58 -0000 +@@ -25,7 +25,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + + /// + void normalize(NormalStream &) const; +Index: math_specialcharinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_specialcharinset.C,v +retrieving revision 1.10 +diff -u -p -r1.10 math_specialcharinset.C +--- math_specialcharinset.C 21 Mar 2002 17:42:56 -0000 1.10 ++++ math_specialcharinset.C 25 Mar 2002 12:01:58 -0000 +@@ -42,7 +42,7 @@ void MathSpecialCharInset::metrics(MathM + } + + +-void MathSpecialCharInset::draw(Painter & pain, int x, int y) const ++void MathSpecialCharInset::draw(MathPainterInfo & pain, int x, int y) const + { + drawChar(pain, font_, x, y, char_); + } +Index: math_specialcharinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_specialcharinset.h,v +retrieving revision 1.7 +diff -u -p -r1.7 math_specialcharinset.h +--- math_specialcharinset.h 21 Mar 2002 17:42:56 -0000 1.7 ++++ math_specialcharinset.h 25 Mar 2002 12:01:58 -0000 +@@ -22,7 +22,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void write(WriteStream & os) const; + /// +Index: math_sqrtinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_sqrtinset.C,v +retrieving revision 1.31 +diff -u -p -r1.31 math_sqrtinset.C +--- math_sqrtinset.C 21 Mar 2002 17:42:56 -0000 1.31 ++++ math_sqrtinset.C 25 Mar 2002 12:01:58 -0000 +@@ -29,7 +29,7 @@ void MathSqrtInset::metrics(MathMetricsI + } + + +-void MathSqrtInset::draw(Painter & pain, int x, int y) const ++void MathSqrtInset::draw(MathPainterInfo & pain, int x, int y) const + { + xcell(0).draw(pain, x + 10, y); + int const a = ascent_; +@@ -40,7 +40,7 @@ void MathSqrtInset::draw(Painter & pain, + xp[1] = x + 8; yp[1] = y - a + 1; + xp[2] = x + 5; yp[2] = y + d - 1; + xp[3] = x; yp[3] = y + (d - a)/2; +- pain.lines(xp, yp, 4, LColor::math); ++ pain.pain.lines(xp, yp, 4, LColor::math); + } + + +Index: math_sqrtinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_sqrtinset.h,v +retrieving revision 1.18 +diff -u -p -r1.18 math_sqrtinset.h +--- math_sqrtinset.h 21 Mar 2002 06:57:13 -0000 1.18 ++++ math_sqrtinset.h 25 Mar 2002 12:01:58 -0000 +@@ -18,7 +18,7 @@ public: + /// + MathInset * clone() const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void metrics(MathMetricsInfo const & mi) const; + /// +Index: math_stackrelinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_stackrelinset.C,v +retrieving revision 1.11 +diff -u -p -r1.11 math_stackrelinset.C +--- math_stackrelinset.C 21 Mar 2002 17:42:56 -0000 1.11 ++++ math_stackrelinset.C 25 Mar 2002 12:01:58 -0000 +@@ -32,7 +32,7 @@ void MathStackrelInset::metrics(MathMetr + } + + +-void MathStackrelInset::draw(Painter & pain, int x, int y) const ++void MathStackrelInset::draw(MathPainterInfo & pain, int x, int y) const + { + int m = x + width() / 2; + int yo = y - xcell(1).ascent() - xcell(0).descent() - 1; +Index: math_stackrelinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_stackrelinset.h,v +retrieving revision 1.5 +diff -u -p -r1.5 math_stackrelinset.h +--- math_stackrelinset.h 21 Mar 2002 17:42:56 -0000 1.5 ++++ math_stackrelinset.h 25 Mar 2002 12:01:58 -0000 +@@ -20,7 +20,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + + /// + void write(WriteStream & os) const; +Index: math_stringinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_stringinset.C,v +retrieving revision 1.14 +diff -u -p -r1.14 math_stringinset.C +--- math_stringinset.C 21 Mar 2002 17:42:56 -0000 1.14 ++++ math_stringinset.C 25 Mar 2002 12:01:58 -0000 +@@ -8,21 +8,18 @@ + #include "math_mathmlstream.h" + #include "math_streamstr.h" + #include "LColor.h" +-#include "Painter.h" + #include "math_support.h" + #include "math_parser.h" + #include "LaTeXFeatures.h" + #include "debug.h" + +-#include +- + + MathStringInset::MathStringInset() +- : str_(), code_(LM_TC_MIN) ++ : str_() + {} + +-MathStringInset::MathStringInset(string const & s, MathTextCodes t) +- : str_(s), code_(t) ++MathStringInset::MathStringInset(string const & s) ++ : str_(s) + {} + + +@@ -32,42 +29,16 @@ MathInset * MathStringInset::clone() con + } + + +-int MathStringInset::ascent() const +-{ +- return mathed_string_ascent(font_, str_); +-} +- +- +-int MathStringInset::descent() const +-{ +- return mathed_string_descent(font_, str_); +-} +- +- +-int MathStringInset::width() const +-{ +- return mathed_string_width(font_, str_); +-} +- +- +-void MathStringInset::validate(LaTeXFeatures & features) const +-{ +- //lyxerr << "stringinset amssymb" << endl; +- if (code_ == LM_TC_MSA || code_ == LM_TC_MSB) +- features.require("amssymb"); +-} +- +- + void MathStringInset::metrics(MathMetricsInfo const & mi) const + { +- whichFont(font_, code_, mi); ++ mathed_string_dim(mi.font, str_, ascent_, descent_, width_); + } + + +-void MathStringInset::draw(Painter & pain, int x, int y) const ++void MathStringInset::draw(MathPainterInfo & pain, int x, int y) const + { + //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl; +- drawStr(pain, font_, x, y, str_); ++ drawStr(pain, pain.font, x, y, str_); + } + + +@@ -79,7 +50,7 @@ void MathStringInset::normalize(NormalSt + + void MathStringInset::maplize(MapleStream & os) const + { +- if (code_ != LM_TC_VAR || str_.size() <= 1) { ++ if (/*code_ != LM_TC_VAR || */ str_.size() <= 1) { + os << ' ' << str_ << ' '; + return; + } +@@ -93,7 +64,7 @@ void MathStringInset::maplize(MapleStrea + + void MathStringInset::octavize(OctaveStream & os) const + { +- if (code_ != LM_TC_VAR || str_.size() <= 1) { ++ if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) { + os << ' ' << str_ << ' '; + return; + } +@@ -107,6 +78,7 @@ void MathStringInset::octavize(OctaveStr + + void MathStringInset::mathmlize(MathMLStream & os) const + { ++/* + if (code_ == LM_TC_VAR) + os << " " << str_ << " "; + else if (code_ == LM_TC_CONST) +@@ -114,14 +86,12 @@ void MathStringInset::mathmlize(MathMLSt + else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM) + os << " " << str_ << " "; + else ++*/ + os << str_; + } + + + void MathStringInset::write(WriteStream & os) const + { +- if (math_font_name(code_)) +- os << '\\' << math_font_name(code_) << '{' << str_ << '}'; +- else +- os << str_; ++ os << str_; + } +Index: math_stringinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_stringinset.h,v +retrieving revision 1.11 +diff -u -p -r1.11 math_stringinset.h +--- math_stringinset.h 21 Mar 2002 17:42:56 -0000 1.11 ++++ math_stringinset.h 25 Mar 2002 12:01:58 -0000 +@@ -2,7 +2,7 @@ + #ifndef MATH_STRINGINSET_H + #define MATH_STRINGINSET_H + +-#include "math_inset.h" ++#include "math_diminset.h" + + #ifdef __GNUG__ + #pragma interface +@@ -12,30 +12,22 @@ + \author André Pönitz + */ + +-class MathStringInset : public MathInset { ++class MathStringInset : public MathDimInset { + public: + /// + MathStringInset(); + /// +- MathStringInset(string const & s, MathTextCodes t = LM_TC_TEXTRM); ++ explicit MathStringInset(string const & s); + /// + MathInset * clone() const; + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; +- /// +- int ascent() const; +- /// +- int descent() const; +- /// +- int width() const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + string str() const { return str_; } + /// + MathStringInset * asStringInset() { return this; } +- /// request "external features" +- void validate(LaTeXFeatures & features) const; + + /// + void normalize(NormalStream &) const; +@@ -51,9 +43,5 @@ public: + public: + /// the string + string str_; +- /// the font to be used on screen +- MathTextCodes code_; +- /// +- mutable LyXFont font_; + }; + #endif +Index: math_support.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_support.C,v +retrieving revision 1.28 +diff -u -p -r1.28 math_support.C +--- math_support.C 21 Mar 2002 17:42:56 -0000 1.28 ++++ math_support.C 25 Mar 2002 12:01:58 -0000 +@@ -611,11 +611,11 @@ int mathed_string_descent(LyXFont const + + + +-void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, ++void mathed_draw_deco(MathPainterInfo & pain, int x, int y, int w, int h, + const string & name) + { + if (name == ".") { +- pain.line(x + w/2, y, x + w/2, y + h, ++ pain.pain.line(x + w/2, y, x + w/2, y + h, + LColor::mathcursor, Painter::line_onoffdash); + return; + } +@@ -655,7 +655,7 @@ void mathed_draw_deco(Painter & pain, in + else + mt.transform(xx, yy); + mt.transform(x2, y2); +- pain.line(x + int(xx), y + int(yy), x + int(x2), y + int(y2), ++ pain.pain.line(x + int(xx), y + int(yy), x + int(x2), y + int(y2), + LColor::math); + } else { + int xp[32]; +@@ -673,31 +673,31 @@ void mathed_draw_deco(Painter & pain, in + yp[j] = y + int(yy); + // lyxerr << "P[" << j " " << xx << " " << yy << " " << x << " " << y << "]"; + } +- pain.lines(xp, yp, n, LColor::math); ++ pain.pain.lines(xp, yp, n, LColor::math); + } + } + } + + +-void mathed_draw_framebox(Painter & pain, int x, int y, MathInset const * p) ++void mathed_draw_framebox(MathPainterInfo & pain, int x, int y, MathInset const * p) + { + if (mathcursor && mathcursor->isInside(p)) +- pain.rectangle(x, y - p->ascent(), p->width(), p->height(), ++ pain.pain.rectangle(x, y - p->ascent(), p->width(), p->height(), + LColor::mathframe); + } + + + // In the future maybe we use a better fonts renderer +-void drawStr(Painter & pain, LyXFont const & font, ++void drawStr(MathPainterInfo & pain, LyXFont const & font, + int x, int y, string const & str) + { +- pain.text(x, y, str, font); ++ pain.pain.text(x, y, str, font); + } + + +-void drawChar(Painter & pain, LyXFont const & font, int x, int y, char c) ++void drawChar(MathPainterInfo & pain, LyXFont const & font, int x, int y, char c) + { +- pain.text(x, y, c, font); ++ pain.pain.text(x, y, c, font); + } + + +Index: math_support.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_support.h,v +retrieving revision 1.6 +diff -u -p -r1.6 math_support.h +--- math_support.h 20 Mar 2002 07:30:32 -0000 1.6 ++++ math_support.h 25 Mar 2002 12:01:58 -0000 +@@ -6,7 +6,7 @@ + #include "math_defs.h" + #include "LString.h" + +-class Painter; ++class MathPainterInfo; + class TextPainter; + class latexkeys; + class MathMetricsInfo; +@@ -21,10 +21,10 @@ int mathed_char_width(LyXFont const &, u + int mathed_char_ascent(LyXFont const &, unsigned char c); + int mathed_char_descent(LyXFont const &, unsigned char c); + +-void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, ++void mathed_draw_deco(MathPainterInfo & pain, int x, int y, int w, int h, + string const & name); + +-void mathed_draw_framebox(Painter & pain, int x, int y, MathInset const *); ++void mathed_draw_framebox(MathPainterInfo & pain, int x, int y, MathInset const *); + + void mathed_string_dim(LyXFont const &, + string const & s, int & asc, int & des, int & wid); +@@ -33,8 +33,8 @@ int mathed_string_width(LyXFont const &, + int mathed_string_ascent(LyXFont const &, string const & s); + int mathed_string_descent(LyXFont const &, string const & s); + +-void drawStr(Painter & pain, LyXFont const &, int x, int y, string const & s); +-void drawChar(Painter & pain, LyXFont const & font, int x, int y, char c); ++void drawStr(MathPainterInfo & pain, LyXFont const &, int x, int y, string const & s); ++void drawChar(MathPainterInfo & pain, LyXFont const & font, int x, int y, char c); + + void math_font_max_dim(LyXFont const &, int & asc, int & desc); + +Index: math_symbolinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_symbolinset.C,v +retrieving revision 1.34 +diff -u -p -r1.34 math_symbolinset.C +--- math_symbolinset.C 21 Mar 2002 17:42:56 -0000 1.34 ++++ math_symbolinset.C 25 Mar 2002 12:01:58 -0000 +@@ -97,7 +97,7 @@ void MathSymbolInset::metrics(MathMetric + } + + +-void MathSymbolInset::draw(Painter & pain, int x, int y) const ++void MathSymbolInset::draw(MathPainterInfo & pain, int x, int y) const + { + if (isRelOp()) + x += 3; +Index: math_symbolinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_symbolinset.h,v +retrieving revision 1.22 +diff -u -p -r1.22 math_symbolinset.h +--- math_symbolinset.h 1 Feb 2002 10:21:29 -0000 1.22 ++++ math_symbolinset.h 25 Mar 2002 12:01:58 -0000 +@@ -22,7 +22,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + bool isRelOp() const; + /// do we take scripts? +Index: math_undersetinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_undersetinset.C,v +retrieving revision 1.3 +diff -u -p -r1.3 math_undersetinset.C +--- math_undersetinset.C 21 Mar 2002 17:42:56 -0000 1.3 ++++ math_undersetinset.C 25 Mar 2002 12:01:58 -0000 +@@ -32,7 +32,7 @@ void MathUndersetInset::metrics(MathMetr + } + + +-void MathUndersetInset::draw(Painter & pain, int x, int y) const ++void MathUndersetInset::draw(MathPainterInfo & pain, int x, int y) const + { + int m = x + width() / 2; + int yo = y + xcell(1).descent() + xcell(0).ascent() + 1; +Index: math_undersetinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_undersetinset.h,v +retrieving revision 1.2 +diff -u -p -r1.2 math_undersetinset.h +--- math_undersetinset.h 21 Mar 2002 17:42:56 -0000 1.2 ++++ math_undersetinset.h 25 Mar 2002 12:01:58 -0000 +@@ -20,7 +20,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + + /// + void write(WriteStream & os) const; +Index: math_unknowninset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_unknowninset.C,v +retrieving revision 1.5 +diff -u -p -r1.5 math_unknowninset.C +--- math_unknowninset.C 21 Mar 2002 17:42:56 -0000 1.5 ++++ math_unknowninset.C 25 Mar 2002 12:01:58 -0000 +@@ -6,7 +6,6 @@ + + #include "math_unknowninset.h" + #include "font.h" +-#include "Painter.h" + #include "math_support.h" + #include "math_mathmlstream.h" + #include "math_streamstr.h" +@@ -64,7 +63,7 @@ void MathUnknownInset::metrics(MathMetri + } + + +-void MathUnknownInset::draw(Painter & pain, int x, int y) const ++void MathUnknownInset::draw(MathPainterInfo & pain, int x, int y) const + { + drawStr(pain, font_, x, y, name_); + } +Index: math_unknowninset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_unknowninset.h,v +retrieving revision 1.3 +diff -u -p -r1.3 math_unknowninset.h +--- math_unknowninset.h 19 Mar 2002 16:55:58 -0000 1.3 ++++ math_unknowninset.h 25 Mar 2002 12:01:58 -0000 +@@ -21,7 +21,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + string const & name() const; + /// identifies UnknownInsets +Index: math_xarrowinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_xarrowinset.C,v +retrieving revision 1.2 +diff -u -p -r1.2 math_xarrowinset.C +--- math_xarrowinset.C 21 Mar 2002 17:42:56 -0000 1.2 ++++ math_xarrowinset.C 25 Mar 2002 12:01:58 -0000 +@@ -33,7 +33,7 @@ void MathXArrowInset::metrics(MathMetric + } + + +-void MathXArrowInset::draw(Painter & pain, int x, int y) const ++void MathXArrowInset::draw(MathPainterInfo & pain, int x, int y) const + { + xcell(0).draw(pain, x + 5, y - 10); + mathed_draw_deco(pain, x + 1, y - 7, width_ - 2, 5, name_); +Index: math_xarrowinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_xarrowinset.h,v +retrieving revision 1.1 +diff -u -p -r1.1 math_xarrowinset.h +--- math_xarrowinset.h 5 Feb 2002 13:27:34 -0000 1.1 ++++ math_xarrowinset.h 25 Mar 2002 12:01:58 -0000 +@@ -20,7 +20,7 @@ public: + /// + MathInset * clone() const; + /// +- void draw(Painter &, int x, int y) const; ++ void draw(MathPainterInfo &, int x, int y) const; + /// + void write(WriteStream & os) const; + /// +Index: math_xdata.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_xdata.C,v +retrieving revision 1.19 +diff -u -p -r1.19 math_xdata.C +--- math_xdata.C 21 Mar 2002 17:42:56 -0000 1.19 ++++ math_xdata.C 25 Mar 2002 12:01:58 -0000 +@@ -72,7 +72,7 @@ void MathXArray::metrics(MathMetricsInfo + } + + +-void MathXArray::draw(Painter & pain, int x, int y) const ++void MathXArray::draw(MathPainterInfo & pain, int x, int y) const + { + //if (drawn_ && x == xo_ && y == yo_) + // return; +@@ -85,17 +85,17 @@ void MathXArray::draw(Painter & pain, in + + if (y + descent_ <= 0) // don't draw above the workarea + return; +- if (y - ascent_ >= pain.paperHeight()) // don't draw below the workarea ++ if (y - ascent_ >= pain.pain.paperHeight()) // don't draw below the workarea + return; + if (x + width_ <= 0) // don't draw left of workarea + return; +- if (x >= pain.paperWidth()) // don't draw right of workarea ++ if (x >= pain.pain.paperWidth()) // don't draw right of workarea + return; + + const_iterator it = begin(), et = end(); + + if (it == et) { +- pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline); ++ pain.pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline); + return; + } + +Index: math_xdata.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_xdata.h,v +retrieving revision 1.11 +diff -u -p -r1.11 math_xdata.h +--- math_xdata.h 21 Mar 2002 17:42:56 -0000 1.11 ++++ math_xdata.h 25 Mar 2002 12:01:58 -0000 +@@ -12,7 +12,7 @@ + #pragma interface + #endif + +-class Painter; ++class MathPainterInfo; + class TextPainter; + + +@@ -32,7 +32,7 @@ public: + /// rebuild cached metrics information + void metrics(MathMetricsInfo const & st) const; + /// redraw cell using cache metrics information +- void draw(Painter & pain, int x, int y) const; ++ void draw(MathPainterInfo & pain, int x, int y) const; + /// rebuild cached metrics information + void metricsT(TextMetricsInfo const & st) const; + /// redraw cell using cache metrics information +Index: math_xyarrowinset.C +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_xyarrowinset.C,v +retrieving revision 1.7 +diff -u -p -r1.7 math_xyarrowinset.C +--- math_xyarrowinset.C 21 Mar 2002 17:42:56 -0000 1.7 ++++ math_xyarrowinset.C 25 Mar 2002 12:01:58 -0000 +@@ -85,7 +85,7 @@ void MathXYArrowInset::metrics(MathMetri + } + + +-void MathXYArrowInset::draw(Painter & pain, int x, int y) const ++void MathXYArrowInset::draw(MathPainterInfo & pain, int x, int y) const + { + metrics(mi_); + +@@ -109,7 +109,7 @@ void MathXYArrowInset::draw(Painter & pa + //drawStr(pain, font_, x, y, "X"); + MathXArray const & s = sourceCell(); + MathXArray const & t = targetCell(); +- pain.line(s.xm(), s.ym(), t.xm(), t.ym(), LColor::math); ++ pain.pain.line(s.xm(), s.ym(), t.xm(), t.ym(), LColor::math); + xcell(1).draw(pain, (s.xm() + t.xm())/2, (s.ym() + t.ym())/2); + + } +Index: math_xyarrowinset.h +=================================================================== +RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_xyarrowinset.h,v +retrieving revision 1.5 +diff -u -p -r1.5 math_xyarrowinset.h +--- math_xyarrowinset.h 21 Mar 2002 17:42:56 -0000 1.5 ++++ math_xyarrowinset.h 25 Mar 2002 12:01:58 -0000 +@@ -21,7 +21,7 @@ public: + /// + void metrics(MathMetricsInfo const & st) const; + /// +- void draw(Painter & pain, int x, int y) const; ++ void draw(MathPainterInfo & pain, int x, int y) const; + /// + MathXYArrowInset * asXYArrowInset() { return this; } + diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 3b7d102fe8..a58b4911dc 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -278,16 +278,17 @@ Inset * InsetFormula::clone(Buffer const &, bool) const } -void InsetFormula::write(Buffer const * buf, ostream & os) const +void InsetFormula::write(Buffer const *, ostream & os) const { os << "Formula "; - latex(buf, os, false, false); + WriteStream wi(os, false, false); + par_->write(wi); } -int InsetFormula::latex(Buffer const *, ostream & os, bool fragil, bool) const +int InsetFormula::latex(Buffer const *, ostream & os, bool fragile, bool) const { - WriteStream wi(os, fragil); + WriteStream wi(os, fragile, true); par_->write(wi); return wi.line(); } diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 8b02a47154..19ea21e686 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -933,7 +933,7 @@ void mathDispatchMathMacro(BufferView * bv, string const & arg) if (arg.empty()) bv->owner()->getLyXFunc()->setErrorMessage(N_("Missing argument")); else { - string s(arg); + string s = arg; string const s1 = token(s, ' ', 1); int const na = s1.empty() ? 0 : lyx::atoi(s1); openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na)); diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 764321417b..3d048a5b79 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -71,7 +71,7 @@ Inset * InsetFormulaMacro::clone(Buffer const &, bool) const void InsetFormulaMacro::write(Buffer const *, ostream & os) const { os << "FormulaMacro "; - WriteStream wi(os, false); + WriteStream wi(os, false, false); par()->write(wi); } @@ -79,7 +79,7 @@ void InsetFormulaMacro::write(Buffer const *, ostream & os) const int InsetFormulaMacro::latex(Buffer const *, ostream & os, bool fragile, bool /*free_spacing*/) const { - WriteStream wi(os, fragile); + WriteStream wi(os, fragile, true); par()->write(wi); return 2; } @@ -87,7 +87,7 @@ int InsetFormulaMacro::latex(Buffer const *, ostream & os, bool fragile, int InsetFormulaMacro::ascii(Buffer const *, ostream & os, int) const { - WriteStream wi(os, false); + WriteStream wi(os, false, true); par()->write(wi); return 0; } diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 86a3b12da8..1a2842ad69 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -133,15 +133,25 @@ struct Selection cursor.insert(data_.cell(0)); } else { // mulitple cells - idx_type idx; + idx_type idx; // index of upper left cell MathGridInset * p = cursor.enclosingGrid(idx); col_type const numcols = min(data_.ncols(), p->ncols() - p->col(idx)); row_type const numrows = min(data_.nrows(), p->nrows() - p->row(idx)); - for (row_type row = 0; row < numrows; ++row) + for (row_type row = 0; row < numrows; ++row) { for (col_type col = 0; col < numcols; ++col) { idx_type i = p->index(row + p->row(idx), col + p->col(idx)); p->cell(i).push_back(data_.cell(data_.index(row, col))); } + // append the left over horizontal cells to the last column + idx_type i = p->index(row + p->row(idx), p->ncols() - 1); + for (col_type col = numcols; col < data_.ncols(); ++col) + p->cell(i).push_back(data_.cell(data_.index(row, col))); + } + // append the left over vertical cells to the last _cell_ + idx_type i = p->nargs() - 1; + for (row_type row = numrows; row < data_.nrows(); ++row) + for (col_type col = 0; col < data_.ncols(); ++col) + p->cell(i).push_back(data_.cell(data_.index(row, col))); } } @@ -537,19 +547,17 @@ void MathCursor::erase() return; } - // delete empty cells if necessary - if (array().empty()) { - bool popit; - bool removeit; - par()->idxDelete(idx(), popit, removeit); - if (popit && popLeft() && removeit) - plainErase(); + // delete empty cells if possible + if (array().empty()) + if (par()->idxDelete(idx())) + return; + + // old behaviour when in last position of cell + if (pos() == size()) { + par()->idxGlue(idx()); return; } - if (pos() == size()) - return; - MathScriptInset * p = nextAtom()->asScriptInset(); if (p) { p->removeScript(p->hasUp()); @@ -957,7 +965,7 @@ void MathCursor::normalize() lyxerr << "this should not really happen - 2: " << pos() << " " << size() << " in idx: " << idx() << " in atom: '"; - WriteStream wi(lyxerr, false); + WriteStream wi(lyxerr, false, true); par()->write(wi); lyxerr << "\n"; dump("error 4"); diff --git a/src/mathed/math_extern.C b/src/mathed/math_extern.C index 3cf02b2bd2..e957386630 100644 --- a/src/mathed/math_extern.C +++ b/src/mathed/math_extern.C @@ -204,6 +204,17 @@ bool extractNumber(MathArray const & ar, int & i) } +bool extractNumber(MathArray const & ar, double & i) +{ + string s; + MathTextCodes c; + charSequence(ar.begin(), ar.end(), s, c); + istringstream is(s.c_str()); + is >> i; + return is; +} + + bool testString(MathInset * p, const string & str) { string s; diff --git a/src/mathed/math_extern.h b/src/mathed/math_extern.h index 134561cf5f..6e7270e8ef 100644 --- a/src/mathed/math_extern.h +++ b/src/mathed/math_extern.h @@ -14,4 +14,7 @@ void maplize(MathArray const &, MapleStream &); void mathmlize(MathArray const &, MathMLStream &); void octavize(MathArray const &, OctaveStream &); +bool extractNumber(MathArray const & ar, int & i); +bool extractNumber(MathArray const & ar, double & i); + #endif diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index 8aec0d4313..4a966d99e0 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -52,8 +52,6 @@ MathAtom createMathInset(latexkeys const * l) return MathAtom(new MathStackrelInset); case LM_TK_UNDERSET: return MathAtom(new MathUndersetInset); - case LM_TK_KERN: - return MathAtom(new MathKernInset); case LM_TK_BINOM: case LM_TK_CHOOSE: return MathAtom(new MathBinomInset); @@ -98,6 +96,9 @@ MathAtom createMathInset(string const & s) && s[2] >= '1' && s[2] <= '9') return MathAtom(new MathMacroArgument(s[2] - '0')); + if (s == "lyxkern") + return MathAtom(new MathKernInset); + if (s == "xymatrix") return MathAtom(new MathXYMatrixInset); diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index 31143b20c2..6b3d4d35f7 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -697,19 +697,16 @@ bool MathGridInset::idxEnd(idx_type & idx, pos_type & pos) const } -void MathGridInset::idxDelete(idx_type & idx, bool & popit, bool & deleteit) +bool MathGridInset::idxDelete(idx_type & idx) { - popit = false; - deleteit = false; - // nothing to do if we are in the middle of the last row of the inset if (idx + ncols() > nargs()) - return; + return false; // try to delete entire sequence of ncols() empty cells if possible for (idx_type i = idx; i < idx + ncols(); ++i) if (cell(i).size()) - return; + return false; // move cells if necessary for (idx_type i = index(row(idx), 0); i < idx; ++i) @@ -723,6 +720,29 @@ void MathGridInset::idxDelete(idx_type & idx, bool & popit, bool & deleteit) // undo effect of Ctrl-Tab (i.e. pull next cell) //if (idx + 1 != nargs()) // cell(idx).swap(cell(idx + 1)); + + // we handled the event.. + return true; +} + + +// reimplement old behaviour when pressing Delete in the last position +// of a cell +void MathGridInset::idxGlue(idx_type idx) +{ + col_type c = col(idx); + if (c + 1 == ncols()) { + if (row(idx) + 1 != nrows()) { + for (col_type cc = 0; cc < ncols(); ++cc) + cell(idx).push_back(cell(idx + cc + 1)); + delRow(row(idx) + 1); + } + } else { + cell(idx).push_back(cell(idx + 1)); + for (col_type cc = c + 2; cc < ncols(); ++cc) + cell(idx - c + cc - 1) = cell(idx - c + cc); + cell(idx - c + ncols() - 1).erase(); + } } diff --git a/src/mathed/math_gridinset.h b/src/mathed/math_gridinset.h index 58d6af14b6..b31cafae4f 100644 --- a/src/mathed/math_gridinset.h +++ b/src/mathed/math_gridinset.h @@ -130,7 +130,9 @@ public: /// bool idxEnd(idx_type &, pos_type &) const; /// - void idxDelete(idx_type &, bool &, bool &); + bool idxDelete(idx_type &); + /// pulls cell after pressing erase + void idxGlue(idx_type idx); /// virtual void addRow(row_type); diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index 62047308db..dcc7643a13 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -84,7 +84,6 @@ key_type wordlist_array[] = {"inf", LM_TK_FUNCLIM, 0}, {"it", LM_TK_OLDFONT, LM_TC_IT}, {"ker", LM_TK_FUNC, 0}, - {"kern", LM_TK_KERN, 0}, {"label", LM_TK_LABEL, 0}, {"lefteqn", LM_TK_LEFTEQN, 1}, {"ldots", LM_TK_DOTS, 0}, @@ -97,6 +96,7 @@ key_type wordlist_array[] = {"ln", LM_TK_FUNC, 0}, {"log", LM_TK_FUNC, 0}, {"lyxbox", LM_TK_BOX, 0}, + {"lyxnegspace", LM_TK_SPACE, 6}, {"mathbb", LM_TK_FONT, LM_TC_BB}, {"mathbf", LM_TK_FONT, LM_TC_BF}, {"mathcal", LM_TK_FONT, LM_TC_CAL}, diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index ef12d2c77b..87af584c5c 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -40,7 +40,7 @@ int MathInset::height() const ostream & operator<<(ostream & os, MathInset const & inset) { - WriteStream wi(os, false); + WriteStream wi(os, false, false); inset.write(wi); return os; } @@ -149,17 +149,10 @@ bool MathInset::idxEnd(idx_type &, pos_type &) const } -void MathInset::idxDelete(idx_type &, bool & popit, bool & deleteit) -{ - popit = false; - deleteit = false; -} - - void MathInset::normalize(NormalStream & os) const { os << "[unknown "; - WriteStream wi(os.os(), false); + WriteStream wi(os.os(), false, true); write(wi); os << "] "; } @@ -168,7 +161,7 @@ void MathInset::normalize(NormalStream & os) const void MathInset::dump() const { lyxerr << "---------------------------------------------\n"; - WriteStream wi(lyxerr, false); + WriteStream wi(lyxerr, false, true); write(wi); lyxerr << "\n---------------------------------------------\n"; } diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 6cbcf808f9..fce522e195 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -145,9 +145,9 @@ public: virtual bool idxEnd(idx_type & idx, pos_type & pos) const; /// Delete a cell and move cursor - // the return value indicates whether the cursor should leave the inset - // and/or the whole inset should be deleted - virtual void idxDelete(idx_type & idx, bool & popit, bool & deleteit); + virtual bool idxDelete(idx_type &) { return false; } + /// pulls cell after pressing erase + virtual void idxGlue(idx_type) {} // returns list of cell indices that are "between" from and to for // selection purposes virtual std::vector idxBetween(idx_type from, idx_type to) const; diff --git a/src/mathed/math_kerninset.C b/src/mathed/math_kerninset.C index 42b5514ba2..91701166a8 100644 --- a/src/mathed/math_kerninset.C +++ b/src/mathed/math_kerninset.C @@ -5,23 +5,15 @@ #endif #include "math_kerninset.h" +#include "math_extern.h" #include "math_mathmlstream.h" #include "math_streamstr.h" #include "math_support.h" -#include "lyxrc.h" +#include "font.h" MathKernInset::MathKernInset() -{} - - -MathKernInset::MathKernInset(LyXLength const & w) - : wid_(w) -{} - - -MathKernInset::MathKernInset(string const & s) - : wid_(s) + : MathNestInset(1) {} @@ -31,31 +23,29 @@ MathInset * MathKernInset::clone() const } +void MathKernInset::metrics(MathMetricsInfo const & mi) const +{ + LyXFont font; + whichFont(font, LM_TC_TEXTRM, mi); + double t; + extractNumber(cell(0), t); + width_ = int(t * lyxfont::width('m', font)); + ascent_ = 0; + descent_ = 0; +} + + void MathKernInset::draw(Painter &, int, int) const {} -void MathKernInset::metrics(MathMetricsInfo const &) const -{ - ascent_ = 0; - descent_ = 0; -#ifdef WITH_WARNINGS -#warning fix this once the interface to LyXLength has improved -#endif - // this uses the numerical valu in pixels, even if the unit is cm or ex! - width_ = static_cast(wid_.value()); - width_ = (width_*static_cast(lyxrc.zoom))/150; - //cerr << "handling kern of width " << wid_.value() << "\n"; -} - - void MathKernInset::write(WriteStream & os) const { - os << "\\kern" << wid_.asLatexString() << " "; + os << "\\lyxkern" << cell(0) << "em "; } void MathKernInset::normalize(NormalStream & os) const { - os << "[kern " << wid_.asLatexString() << "]"; + os << "[lyxkern " << cell(0) << "em]"; } diff --git a/src/mathed/math_kerninset.h b/src/mathed/math_kerninset.h index d6c65e4213..69da69f961 100644 --- a/src/mathed/math_kerninset.h +++ b/src/mathed/math_kerninset.h @@ -2,36 +2,27 @@ #ifndef MATH_CHEATINSET_H #define MATH_CHEATINSET_H -#include "math_diminset.h" -#include "vspace.h" -#include "LString.h" +#include "math_nestinset.h" #ifdef __GNUG__ #pragma interface #endif -/// The \kern primitive +/// Some hack for visual effects -class MathKernInset : public MathDimInset { +class MathKernInset : public MathNestInset { public: /// MathKernInset(); /// - explicit MathKernInset(LyXLength const & wid); - /// - explicit MathKernInset(string const & wid); - /// MathInset * clone() const; /// void draw(Painter &, int x, int y) const; /// void write(WriteStream & os) const; /// - void normalize(NormalStream &) const; + void normalize(NormalStream & ns) const; /// - void metrics(MathMetricsInfo const & st) const; -private: - /// width in em - LyXLength wid_; + void metrics(MathMetricsInfo const &cwmist) const; }; #endif diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index b1360a33a5..3cf76db27b 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -66,6 +66,12 @@ bool MathMacro::defining() const } +void MathMacro::expand() const +{ + expanded_ = tmplate_->xcell(tmplate_->cell(1).empty() ? 0 : 1); +} + + void MathMacro::metrics(MathMetricsInfo const & mi) const { whichFont(font_, LM_TC_TEX, mi); @@ -77,7 +83,7 @@ void MathMacro::metrics(MathMetricsInfo const & mi) const } if (editing()) { - expanded_ = tmplate_->xcell(0); + expand(); expanded_.metrics(mi_); width_ = expanded_.width() + 4; ascent_ = expanded_.ascent() + 2; @@ -100,7 +106,7 @@ void MathMacro::metrics(MathMetricsInfo const & mi) const return; } - expanded_ = tmplate_->xcell(0); + expand(); expanded_.data_.substitute(*this); expanded_.metrics(mi_); width_ = expanded_.width(); @@ -232,6 +238,6 @@ void MathMacro::write(WriteStream & os) const void MathMacro::updateExpansion() const { - expanded_ = tmplate_->xcell(0); + expand(); expanded_.data_.substitute(*this); } diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index cf1b593206..ee8059c03d 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -84,6 +84,8 @@ private: bool defining() const; /// void updateExpansion() const; + /// + void expand() const; /// MathAtom & tmplate_; diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index f98f6c8265..9d373a71d3 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -56,10 +56,12 @@ void MathMacroTable::create(string const & name, int na, string const & text) -void MathMacroTable::create(string const & name, int na, MathArray const & ar) +void MathMacroTable::create + (string const & name, int na, MathArray const & ar1, MathArray const & ar2) { MathAtom t(new MathMacroTemplate(name, na)); - t->cell(0) = ar; + t->cell(0) = ar1; + t->cell(1) = ar2; macro_table[name] = t; } diff --git a/src/mathed/math_macrotable.h b/src/mathed/math_macrotable.h index 44f59c1357..098a85c148 100644 --- a/src/mathed/math_macrotable.h +++ b/src/mathed/math_macrotable.h @@ -18,7 +18,7 @@ public: /// static void create(string const &, int, string const &); /// - static void create(string const &, int, MathArray const &); + static void create(string const &, int, MathArray const &, MathArray const &); /// static MathAtom & provide(string const &); /// diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index d4f97a21d7..6ba92c30d3 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -8,20 +8,17 @@ #include "debug.h" -using std::endl; - - MathMacroTemplate::MathMacroTemplate() - : MathNestInset(1), numargs_(0), name_() + : MathNestInset(2), numargs_(0), name_() {} MathMacroTemplate::MathMacroTemplate(string const & nm, int numargs) - : MathNestInset(1), numargs_(numargs), name_(nm) + : MathNestInset(2), numargs_(numargs), name_(nm) { if (numargs_ > 9) lyxerr << "MathMacroTemplate::MathMacroTemplate: wrong # of arguments: " - << numargs_ << endl; + << numargs_ << std::endl; } @@ -53,23 +50,39 @@ string const & MathMacroTemplate::name() const void MathMacroTemplate::metrics(MathMetricsInfo const & mi) const { xcell(0).metrics(mi); - width_ = xcell(0).width() + 4; - ascent_ = xcell(0).ascent() + 2; - descent_ = xcell(0).descent() + 2; + xcell(1).metrics(mi); + width_ = xcell(0).width() + xcell(1).width() + 10; + ascent_ = std::max(xcell(0).ascent(), xcell(1).ascent()) + 2; + descent_ = std::max(xcell(0).descent(), xcell(1).descent()) + 2; } void MathMacroTemplate::draw(Painter & pain, int x, int y) const { + int const w0 = xcell(0).width(); + int const w1 = xcell(1).width(); xcell(0).draw(pain, x + 2, y + 1); - pain.rectangle(x, y - ascent(), width(), height(), LColor::blue); + pain.rectangle(x, y - ascent() + 1, w0 + 4, height(), LColor::blue); + xcell(1).draw(pain, x + 8 + w0, y + 1); + pain.rectangle(x + w0 + 6 , y - ascent() + 1, w1 + 4, height(), LColor::blue); } void MathMacroTemplate::write(WriteStream & os) const { - os << "\n\\newcommand{\\" << name_.c_str() << '}'; - if (numargs_ > 0) - os << '[' << numargs_ << ']'; - os << '{' << cell(0) << "}\n"; + if (os.latex()) { + os << "\n\\newcommand{\\" << name_.c_str() << '}'; + if (numargs_ > 0) + os << '[' << numargs_ << ']'; + os << '{' << cell(0) << "}\n"; + } else { + // writing .lyx + os << "\n\\newcommand{\\" << name_.c_str() << '}'; + if (numargs_ > 0) + os << '[' << numargs_ << ']'; + os << '{' << cell(0) << '}'; + // write special .tex export only if necessary + if (!cell(1).empty()) + os << "\n{" << cell(1) << '}'; + } } diff --git a/src/mathed/math_mathmlstream.C b/src/mathed/math_mathmlstream.C index bb87b1d232..9f9c1dc7d5 100644 --- a/src/mathed/math_mathmlstream.C +++ b/src/mathed/math_mathmlstream.C @@ -187,13 +187,13 @@ NormalStream & operator<<(NormalStream & ns, char c) ////////////////////////////////////////////////////////////////////// -WriteStream::WriteStream(ostream & os, bool fragile) - : os_(os), fragile_(fragile), firstitem_(false), line_(0) +WriteStream::WriteStream(ostream & os, bool fragile, bool latex) + : os_(os), fragile_(fragile), latex_(latex), firstitem_(false), line_(0) {} WriteStream::WriteStream(ostream & os) - : os_(os), fragile_(false), firstitem_(false), line_(0) + : os_(os), fragile_(false), latex_(false), firstitem_(false), line_(0) {} diff --git a/src/mathed/math_mathmlstream.h b/src/mathed/math_mathmlstream.h index bdcf4751ca..364e5c1077 100644 --- a/src/mathed/math_mathmlstream.h +++ b/src/mathed/math_mathmlstream.h @@ -160,7 +160,7 @@ OctaveStream & operator<<(OctaveStream &, char); class WriteStream { public: /// - WriteStream(std::ostream & os, bool fragile); + WriteStream(std::ostream & os, bool fragile, bool latex); /// explicit WriteStream(std::ostream & os_); /// @@ -168,6 +168,8 @@ public: /// bool fragile() const { return fragile_; } /// + bool latex() const { return latex_; } + /// std::ostream & os() { return os_; } /// bool & firstitem() { return firstitem_; } @@ -178,6 +180,8 @@ private: std::ostream & os_; /// bool fragile_; + /// are we writing to .tex? + int latex_; /// are we at the beginning of an MathArray? bool firstitem_; /// diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index f7cead75b0..afee0c7c5e 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -757,18 +757,21 @@ bool Parser::parse_macro(string & name) return false; } - MathArray ar; - parse_into(ar, FLAG_BRACE_LAST); + MathArray ar1; + parse_into(ar1, FLAG_BRACE_LAST); // we cannot handle recursive stuff at all MathArray test; test.push_back(createMathInset(name)); - if (ar.contains(test)) { + if (ar1.contains(test)) { lyxerr << "we cannot handle recursive macros at all.\n"; return false; } - MathMacroTable::create(name, narg, ar); + MathArray ar2; + parse_into(ar2, FLAG_ITEM); + + MathMacroTable::create(name, narg, ar1, ar2); return true; } @@ -1109,6 +1112,7 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code) lyxerr << "unknow math inset begin '" << name << "'\n"; } +/* else if (t.cs() == "kern") { #ifdef WITH_WARNINGS #warning A hack... @@ -1125,6 +1129,12 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code) break; } array.push_back(MathAtom(new MathKernInset(s))); +*/ + + else if (t.cs() == "lyxkern") { + MathAtom p = createMathInset(t.cs()); + parse_into(p->cell(0), flags, code); + array.push_back(p); } else if (t.cs() == "label") { diff --git a/src/mathed/math_parser.h b/src/mathed/math_parser.h index 847accc2a6..0b51edbec1 100644 --- a/src/mathed/math_parser.h +++ b/src/mathed/math_parser.h @@ -108,8 +108,6 @@ enum MathTokenEnum /// LM_TK_NOT, /// - LM_TK_KERN, - /// LM_TK_UNDERSET, /// LM_TK_STACK diff --git a/src/mathed/math_spaceinset.C b/src/mathed/math_spaceinset.C index 01c50b98b0..d6da0ed575 100644 --- a/src/mathed/math_spaceinset.C +++ b/src/mathed/math_spaceinset.C @@ -9,6 +9,11 @@ #include "math_mathmlstream.h" +char const * latex_mathspace[] = { + "!", ",", ":", ";", "quad", "qquad", "lyxnegspace" +}; + + MathSpaceInset::MathSpaceInset(int sp) : space_(sp) @@ -23,12 +28,16 @@ MathInset * MathSpaceInset::clone() const void MathSpaceInset::metrics(MathMetricsInfo const &) const { - width_ = space_ ? space_ * 2 : 2; - if (space_ > 3) - width_ *= 2; - if (space_ == 5) - width_ *= 2; - width_ += 4; + switch (space_) { + case 0: width_ = 6; break; + case 1: width_ = 6; break; + case 2: width_ = 8; break; + case 3: width_ = 10; break; + case 4: width_ = 20; break; + case 5: width_ = 40; break; + case 6: width_ = -2; break; + default: width_ = 6; break; + } ascent_ = 4; descent_ = 0; } @@ -37,9 +46,10 @@ void MathSpaceInset::metrics(MathMetricsInfo const &) const void MathSpaceInset::draw(Painter & pain, int x, int y) const { -// XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}}; - // 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) + return; int xp[4]; int yp[4]; @@ -79,6 +89,6 @@ void MathSpaceInset::normalize(NormalStream & os) const void MathSpaceInset::write(WriteStream & os) const { - if (space_ >= 0 && space_ < 6) + if (space_ >= 0 && space_ < 7) os << '\\' << latex_mathspace[space_] << ' '; } diff --git a/src/mathed/math_support.C b/src/mathed/math_support.C index 29b9f171eb..b13212770e 100644 --- a/src/mathed/math_support.C +++ b/src/mathed/math_support.C @@ -730,12 +730,6 @@ void math_font_max_dim(LyXFont const & font, int & asc, int & des) } -char const * latex_mathspace[] = { - "!", ",", ":", ";", "quad", "qquad" -}; - - - char const * math_font_name(MathTextCodes code) { static char const * theFontNames[] = { diff --git a/src/mathed/math_support.h b/src/mathed/math_support.h index 7538175671..abe0a39e83 100644 --- a/src/mathed/math_support.h +++ b/src/mathed/math_support.h @@ -13,8 +13,6 @@ class MathMetricsInfo; class MathInset; class LyXFont; -extern char const * latex_mathspace[]; - void mathed_char_dim(LyXFont const &, unsigned char c, int & asc, int & des, int & wid); int mathed_char_width(LyXFont const &, unsigned char c);