]> git.lyx.org Git - features.git/commitdiff
most of the so far unapplied stuff from porto including proper support for
authorAndré Pönitz <poenitz@gmx.net>
Mon, 24 Jun 2002 15:37:14 +0000 (15:37 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 24 Jun 2002 15:37:14 +0000 (15:37 +0000)
\fbox and a few bugfixes (and quite probable lots of new bugs)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4466 a592a061-630c-0410-9148-cb99ea01b6c8

27 files changed:
src/mathed/Makefile.am
src/mathed/formula.C
src/mathed/formulabase.C
src/mathed/math_amsarrayinset.h
src/mathed/math_boxinset.C
src/mathed/math_boxinset.h
src/mathed/math_braceinset.h
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_decorationinset.C
src/mathed/math_decorationinset.h
src/mathed/math_defs.h
src/mathed/math_factory.C
src/mathed/math_fboxinset.C [new file with mode: 0644]
src/mathed/math_fboxinset.h [new file with mode: 0644]
src/mathed/math_fontinset.C
src/mathed/math_hullinset.C
src/mathed/math_hullinset.h
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_macro.C
src/mathed/math_macrotemplate.C
src/mathed/math_nestinset.C
src/mathed/math_nestinset.h
src/mathed/math_parser.C
src/mathed/math_support.C
src/mathed/preview.C

index e5ce335e4f6c3d260ea36063d48e32129f8cd741..cec9303eb347c65f3ad9bbd0045deb13cc1fd59d 100644 (file)
@@ -58,6 +58,8 @@ libmathed_la_SOURCES = \
        math_exintinset.h \
        math_factory.C \
        math_factory.h \
+       math_fboxinset.C \
+       math_fboxinset.h \
        math_fontinset.C \
        math_fontinset.h \
        math_fracinset.C \
index 12dc32de3beb7ff8ee1b7d1ea34a509fdb906cfd..9c9b57e3183ae3ea037efcbd1ef1478e441c4aa5 100644 (file)
@@ -380,6 +380,7 @@ bool InsetFormula::insetAllowed(Inset::Code code) const
 {
        return
                (code == Inset::LABEL_CODE && display())
+               || code == Inset::REF_CODE      
                || code == Inset::ERT_CODE;
 }
 
index b05790d9cafc354e4369705a03616a628fb0ba8a..008a131bd4c196bc14aa77c79128568ad011106b 100644 (file)
@@ -38,6 +38,7 @@
 #include "frontends/mouse_state.h"
 #include "Lsstream.h"
 #include "math_arrayinset.h"
+#include "math_boxinset.h"
 #include "math_charinset.h"
 #include "math_cursor.h"
 #include "math_factory.h"
@@ -52,6 +53,7 @@
 #include "textpainter.h"
 #include "frontends/Dialogs.h"
 #include "intl.h"
+#include "../insets/insetcommand.h"
 
 using std::endl;
 using std::ostream;
@@ -126,8 +128,7 @@ void InsetFormulaBase::handleFont
        if (sel)
                updateLocal(bv, true);
        mathcursor->handleNest(new MathFontInset(font));
-  for (string::const_iterator it = arg.begin(); it != arg.end(); ++it)
-    mathcursor->insert(*it);
+       mathcursor->insert(arg);
        if (!sel)
                updateLocal(bv, false);
 }
@@ -303,7 +304,7 @@ void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
 
 
 bool InsetFormulaBase::insetButtonRelease(BufferView * bv,
-                                         int /*x*/, int /*y*/, mouse_button::state button)
+       int /*x*/, int /*y*/, mouse_button::state button)
 {
        //lyxerr << "insetButtonRelease: " << x << " " << y << "\n";
 
@@ -314,6 +315,10 @@ bool InsetFormulaBase::insetButtonRelease(BufferView * bv,
        bv->updateInset(this, false);
 
        if (button == mouse_button::button3) {
+               // try to dispatch to enclosed insets first
+               if (mathcursor->dispatch("mouse 3"))
+                       return true;
+
                // launch math panel for right mouse button
                bv->owner()->getDialogs()->showMathPanel();
                return true;
@@ -430,7 +435,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
 
        switch (action) {
 
-               // --- Cursor Movements ---------------------------------------------
+       // --- Cursor Movements ---------------------------------------------
 
        case LFUN_RIGHTSEL:
                sel = true; // fall through...
@@ -750,6 +755,32 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
                updateLocal(bv, true);
                break;
 
+       case LFUN_REF_INSERT:
+               //if (argument.empty()) {
+               //      InsetCommandParams p("ref");
+               //      owner_->getDialogs()->createRef(p.getAsString());
+               //} else {
+               //      InsetCommandParams p;
+               //      p.setFromString(argument);
+
+               //      InsetRef * inset = new InsetRef(p, *buffer_);
+               //      if (!insertInset(inset))
+               //              delete inset;
+               //      else
+               //              updateInset(inset, true);
+               //}
+               //
+               if (arg.empty()) {
+                       InsetCommandParams p("ref");
+                       bv->owner()->getDialogs()->createRef(p.getAsString());
+               } else {
+                       //mathcursor->handleNest(new RefInset);
+                       //mathcursor->insert(arg);
+                       mathcursor->insert(MathAtom(new RefInset(arg)));
+               }
+               updateLocal(bv, true);
+               break;
+
        default:
                result = UNDISPATCHED;
        }
@@ -913,7 +944,7 @@ void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
 
                InsetFormulaBase * f;
                if (sel.empty()) {
-                       f = new InsetFormula;
+                       f = new InsetFormula(LM_OT_SIMPLE);
                        if (openNewInset(bv, f)) {
                                // don't do that also for LFUN_MATH_MODE unless you want end up with
                                // always changing to mathrm when opening an inlined inset
@@ -979,7 +1010,7 @@ void mathDispatchMathMacro(BufferView * bv, string const & arg)
 void mathDispatchMathDelim(BufferView * bv, string const & arg)
 {
        if (bv->available()) {
-               if (openNewInset(bv, new InsetFormula))
+               if (openNewInset(bv, new InsetFormula(LM_OT_SIMPLE)))
                        bv->theLockingInset()->localDispatch(bv, LFUN_MATH_DELIM, arg);
        }
 }
@@ -988,7 +1019,7 @@ void mathDispatchMathDelim(BufferView * bv, string const & arg)
 void mathDispatchInsertMatrix(BufferView * bv, string const & arg)
 {
        if (bv->available()) {
-               if (openNewInset(bv, new InsetFormula))
+               if (openNewInset(bv, new InsetFormula(LM_OT_SIMPLE)))
                        bv->theLockingInset()->localDispatch(bv, LFUN_INSERT_MATRIX, arg);
        }
 }
@@ -1013,7 +1044,7 @@ void mathDispatchInsertMath(BufferView * bv, string const & arg)
 void mathDispatchGreek(BufferView * bv, string const & arg)
 {
        if (bv->available()) {
-               InsetFormula * f = new InsetFormula;
+               InsetFormula * f = new InsetFormula(LM_OT_SIMPLE);
                if (openNewInset(bv, f)) {
                        bv->theLockingInset()->localDispatch(bv, LFUN_GREEK, arg);
                        bv->unlockInset(f);
index eb24eff9fead6babd0a2011d34657c041f4d288b..4c45fe2d49967290437db9266bde463274cae08e 100644 (file)
@@ -12,9 +12,9 @@
 class MathAMSArrayInset : public MathGridInset {
 public:
        ///
-       MathAMSArrayInset(string const & name_, int m, int n);
+       MathAMSArrayInset(string const & name, int m, int n);
        ///
-       MathAMSArrayInset(string const & name_);
+       MathAMSArrayInset(string const & name);
        ///
        MathInset * clone() const;
        ///
index 3d5f14b6adc567282a8dd5dc285795b90172d518..f9d527c16121f2a23bb11eedae58cb1afd15f0a7 100644 (file)
@@ -9,6 +9,203 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 
+#include "math_cursor.h"
+#include "commandtags.h"
+#include "formulabase.h"
+#include "BufferView.h"
+#include "frontends/LyXView.h"
+#include "frontends/Painter.h"
+#include "frontends/Dialogs.h"
+#include "lyxfunc.h"
+#include "gettext.h"
+#include "LaTeXFeatures.h"
+
+
+ButtonInset::ButtonInset()
+       : MathNestInset(2)
+{}
+
+
+void ButtonInset::metrics(MathMetricsInfo & mi) const
+{
+       MathFontSetChanger dummy(mi.base, "textnormal");
+       if (editing()) {
+               MathNestInset::metrics(mi);
+               width_   = xcell(0).width() + xcell(1).width() + 4;
+               ascent_  = max(xcell(0).ascent(), xcell(1).ascent());
+               descent_ = max(xcell(0).descent(), xcell(1).descent());
+       } else {
+               string s = screenLabel();
+               mathed_string_dim(mi.base.font,
+                                s, ascent_, descent_, width_);
+               width_ += 10;
+       }
+}
+
+
+void ButtonInset::draw(MathPainterInfo & pi, int x, int y) const
+{
+       MathFontSetChanger dummy(pi.base, "textnormal");
+       if (editing()) {
+               xcell(0).draw(pi, x, y);
+               xcell(1).draw(pi, x + xcell(0).width() + 2, y);
+               mathed_draw_framebox(pi, x, y, this);
+       } else {
+               pi.pain.buttonText(x + 2, y, screenLabel(),
+                       pi.base.font);
+       }
+}
+
+
+////////////////////////////////
+
+CommandInset::CommandInset(string const & data)
+{
+       lock_ = true;
+
+       string::size_type idx0 = data.find("|++|");
+       name_ = data.substr(0, idx0);
+       if (idx0 == string::npos)
+               return;
+       idx0 += 4;
+       string::size_type idx1 = data.find("|++|", idx0);
+       cell(0) = asArray(data.substr(idx0, idx1 - idx0));
+       if (idx1 == string::npos)
+               return;
+       cell(1) = asArray(data.substr(idx1 + 4));
+}
+
+
+MathInset * CommandInset::clone() const
+{
+       return new CommandInset(*this);
+}
+
+
+void CommandInset::write(WriteStream & os) const
+{
+       os << "\\" << name_;
+       if (cell(1).size())
+               os << "[" << cell(1) << "]";
+       os << "{" << cell(0) << "}";
+}
+
+
+string CommandInset::screenLabel() const
+{
+       return name_;
+}
+
+////////////////////////////////
+
+RefInset::RefInset()
+       : CommandInset("ref")
+{}
+
+
+RefInset::RefInset(string const & data)
+       : CommandInset(data)
+{}
+
+
+MathInset * RefInset::clone() const
+{
+       return new RefInset(*this);
+}
+
+
+void RefInset::infoize(std::ostream & os) const
+{
+       os << "Ref: " << cell(0);
+}
+
+
+int RefInset::dispatch(string const & cmd, idx_type, pos_type) 
+{
+       if (cmd == "mouse 3") {
+               cerr << "trying to goto ref" << cell(0) << "\n";
+               mathcursor->formula()->view()->owner()->getLyXFunc()->
+                       dispatch(LFUN_REF_GOTO, asString(cell(0)));
+               return 1; // dispatched
+       }
+       
+       if (cmd == "mouse 1") {
+               cerr << "trying to open ref" << cell(0) << "\n";
+               // Eventually trigger dialog with button 3 not 1
+//             mathcursor->formula()->view()->owner()->getDialogs()
+//                     ->showRef(this);
+               return 1; // dispatched
+       }
+
+       return 0; // undispatched
+}
+
+
+string RefInset::screenLabel() const
+{
+       string str;
+       for (int i = 0; !types[i].latex_name.empty(); ++i)
+               if (name_ == types[i].latex_name) {
+                       str = _(types[i].short_gui_name);
+                       break;
+               }
+       str += asString(cell(0));
+
+       //if (/* !isLatex && */ !cell(0).empty()) {
+       //      str += "||";
+       //      str += asString(cell(1));
+       //}
+       return str;
+}
+
+
+void RefInset::validate(LaTeXFeatures & features) const
+{
+       if (name_ == "vref" || name_ == "vpageref")
+               features.require("varioref");
+       else if (name_ == "prettyref")
+               features.require("prettyref");
+}
+
+
+int RefInset::ascii(std::ostream & os, int) const
+{
+       os << "[" << asString(cell(0)) << "]";
+       return 0;
+}
+
+
+int RefInset::linuxdoc(std::ostream & os) const
+{
+       os << "<ref id=\"" << asString(cell(0))
+          << "\" name=\"" << asString(cell(1)) << "\" >";
+       return 0;
+}
+
+
+int RefInset::docbook(std::ostream & os, bool) const
+{
+       if (cell(1).empty()) {
+               os << "<xref linkend=\"" << asString(cell(0)) << "\">";
+       } else {
+               os << "<link linkend=\"" << asString(cell(0))
+                  << "\">" << asString(cell(1)) << "</link>";
+       }
+
+       return 0;
+}
+
+RefInset::type_info RefInset::types[] = {
+       { "ref",        N_("Standard"),                 N_("Ref: ")},
+       { "pageref",    N_("Page Number"),              N_("Page: ")},
+       { "vpageref",   N_("Textual Page Number"),      N_("TextPage: ")},
+       { "vref",       N_("Standard+Textual Page"),    N_("Ref+Text: ")},
+       { "prettyref",  N_("PrettyRef"),                N_("PrettyRef: ")},
+       { "", "", "" }
+};
+
+///////////////////////////////////
+
 
 MathBoxInset::MathBoxInset(string const & name)
        : MathGridInset(1, 1), name_(name)
index cbf358edd8e3c30dc80c256ac29d055a55795757..52054662a6c9794c1f0e63d3d10551845dfffde3 100644 (file)
 
 class LyXFont;
 
+// Try to implement the reference inset "natively" for mathed.
+// This is here temporarily until I can do cvs add again.
+
+class ButtonInset: public MathNestInset {
+public:
+       ///
+       ButtonInset();
+       ///
+       void metrics(MathMetricsInfo & mi) const;
+       ///
+       void draw(MathPainterInfo & pi, int x, int y) const;
+
+protected:
+       /// This should provide the text for the button
+       virtual string screenLabel() const = 0;
+};
+
+
+// for things like \name[options]{contents}
+class CommandInset : public ButtonInset {
+public:
+       /// name, contents, options deliminited by '|++|'
+       explicit CommandInset(string const & data);
+       ///
+       MathInset * clone() const;
+       ///
+       void write(WriteStream & os) const;
+       ///
+       //void infoize(std::ostream & os) const;
+       ///
+       //int dispatch(string const & cmd, idx_type idx, pos_type pos);
+       ///
+       string screenLabel() const;
+public:
+       string name_;
+};
+
+
+// for \ref 
+class RefInset : public CommandInset {
+public:
+       ///
+       RefInset();
+       ///
+       explicit RefInset(string const & data);
+       ///
+       MathInset * clone() const;
+       ///
+       //void write(WriteStream & os) const;
+       ///
+       void infoize(std::ostream & os) const;
+       ///
+       int dispatch(string const & cmd, idx_type idx, pos_type pos);
+       ///
+       string screenLabel() const;
+       ///
+       void validate(LaTeXFeatures & features) const;
+
+       /// plain ascii output
+       int ascii(std::ostream & os, int) const;
+       /// linuxdoc output
+       int linuxdoc(std::ostream & os) const;
+       /// docbook output
+       int docbook(std::ostream & os, bool) const;
+
+
+       struct type_info {
+               ///
+               string latex_name;
+               ///
+               string gui_name;
+               ///
+               string short_gui_name;
+       };
+       static type_info types[];
+       ///
+       static int getType(string const & name);
+       ///
+       static string const & getName(int type);
+};
+
+
 /// Support for \\mbox
 
 class MathBoxInset : public MathGridInset {
@@ -40,4 +122,6 @@ private:
        ///
        string name_;
 };
+
+
 #endif
index d53af2dc350d64010a034272306fafa3d0851c6f..a240999731713eb09e54e35863d3c4d2f9a37d04 100644 (file)
@@ -26,9 +26,9 @@ public:
        ///
        void write(WriteStream & os) const;
        /// write normalized content
-       void normalize(NormalStream &) const;
+       void normalize(NormalStream & ns) const;
        ///
-       void metrics(MathMetricsInfo & st) const;
+       void metrics(MathMetricsInfo & mi) const;
 
 private:
        /// width of brace character
index 0f95d7d18200583066e603af4a69a9f60e80f44b..54d0fdcc23e1f78a5e8d2f6e6f6ca1a4f60a421e 100644 (file)
@@ -38,6 +38,7 @@
 #include "math_deliminset.h"
 #include "math_extern.h"
 #include "math_factory.h"
+#include "math_fboxinset.h"
 #include "math_hullinset.h"
 #include "math_iterator.h"
 #include "math_macroarg.h"
@@ -327,6 +328,15 @@ void MathCursor::plainInsert(MathAtom const & t)
 }
 
 
+void MathCursor::insert(string const & str)
+{
+       //lyxerr << "inserting '" << str << "'\n";
+       selClearOrDel();
+       for (string::const_iterator it = str.begin(); it != str.end(); ++it)
+               plainInsert(MathAtom(new MathCharInset(*it)));
+}
+
+
 void MathCursor::insert(char c)
 {
        //lyxerr << "inserting '" << c << "'\n";
@@ -1354,7 +1364,13 @@ bool MathCursor::script(bool up)
 
 bool MathCursor::inMathMode() const
 {
-       return !par()->asBoxInset();
+       if (par()->asBoxInset())
+               return false;
+       if (par()->asFboxInset())
+               return false;
+       if (par()->asParInset())
+               return false;
+       return true;
 }
 
 
@@ -1415,7 +1431,7 @@ bool MathCursor::interpret(char c)
                return true;
        }
 
-       // just clear selection on pressing the space par
+       // just clear selection on pressing the space bar
        if (selection_ && c == ' ') {
                selection_ = false;
                return true;
@@ -1522,8 +1538,14 @@ void MathCursor::setSelection(cursor_type const & where, size_type n)
 
 void MathCursor::insetToggle()
 {
-       if (hasNextAtom())
+       if (hasNextAtom()) {
+               // toggle next inset ...
+               nextAtom()->lock(!nextAtom()->lock());
+       } else if (popLeft() && hasNextAtom()) {
+               // ... or enclosing inset if we are in the last inset position
                nextAtom()->lock(!nextAtom()->lock());
+               posRight();
+       }
 }
 
 
@@ -1716,3 +1738,14 @@ void MathCursor::handleExtern(const string & arg)
        }
 
 }
+
+
+int MathCursor::dispatch(string const & cmd)
+{
+       for (int i = Cursor_.size() - 1; i >= 0; --i) {
+               MathCursorPos & pos = Cursor_[i];
+               if (int res = pos.par_-> dispatch(cmd, pos.idx_, pos.pos_))
+                       return res;
+       }
+       return 0;
+}
index f6bad5629b27696c6a74b025197a2e33550e2d44..aa9a15554da3eb2a31c32a8261fd07f3c3022aa2 100644 (file)
@@ -238,6 +238,8 @@ public:
        /// how deep are we nested?
        unsigned depth() const;
 
+       /// local dispatcher
+       int dispatch(string const & cmd);
        /// describe the situation
        string info() const;
        /// dump selection information for debugging
@@ -247,7 +249,9 @@ public:
        /// moves on
        void setSelection(cursor_type const & where, size_type n);
        ///
-       void insert(char);
+       void insert(char c);
+       ///
+       void insert(string const & str);
        /// lock/unlock inset
        void insetToggle();
 
index cccbed283951e539965a2989f4851559fc1ec831..03657b13bc3db686aefe9771c856bf5a1c081c28 100644 (file)
@@ -81,7 +81,7 @@ void MathDecorationInset::metrics(MathMetricsInfo & mi) const
        ascent_  = xcell(0).ascent();
        descent_ = xcell(0).descent();
 
-       dh_ = 6; //mathed_char_height(LM_TC_VAR, mi(), 'I', ascent_, descent_);
+       dh_ = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
        dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
 
        if (upper()) {
@@ -91,16 +91,21 @@ void MathDecorationInset::metrics(MathMetricsInfo & mi) const
                dy_ = descent_ + 1;
                descent_ += dh_ + 2;
        }
+
+       // for the angular markers
+       descent_ += 2;
+       width_   += 2;
 }
 
 
-void MathDecorationInset::draw(MathPainterInfo & pain, int x, int y) const
+void MathDecorationInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       xcell(0).draw(pain, x, y);
+       xcell(0).draw(pi, x + 1, y);
        if (wide())
-               mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
+               mathed_draw_deco(pi, x + 1, y + dy_, width_, dh_, name_);
        else
-               mathed_draw_deco(pain, x + (width_ - dw_) / 2, y + dy_, dw_, dh_, name_);
+               mathed_draw_deco(pi, x + 1 + (width_ - dw_) / 2, y + dy_, dw_, dh_, name_);
+       drawMarkers(pi, x, y);
 }
 
 
@@ -116,3 +121,9 @@ void MathDecorationInset::normalize(NormalStream & os) const
 {
        os << "[deco " << name_ << ' ' <<  cell(0) << ']';
 }
+
+
+void MathDecorationInset::infoize(std::ostream & os) const
+{
+       os << "Deco: " << name_;
+}
index 1c98714183194881cae434ecf4eaff4c11190ac2..e0e03650cfd0031cc475a9045112ca8b2b69dd0e 100644 (file)
@@ -24,10 +24,12 @@ public:
        ///
        void write(WriteStream & os) const;
        ///
-       void metrics(MathMetricsInfo & st) const;
+       void metrics(MathMetricsInfo & mi) const;
        ///
        void normalize(NormalStream & os) const;
        ///
+       void infoize(std::ostream & os) const;
+       ///
        bool isScriptable() const;
 
 private:
index 284d61a41149fc509b432fa0e223fe793ac20ccc..955516e32aa833a192d8d23fab768091aafad9f7 100644 (file)
@@ -28,7 +28,9 @@
 /// Types of lyx-math insets
 enum MathInsetTypes  {
        ///
-       LM_OT_SIMPLE = 0,
+       LM_OT_NONE = 0,
+       ///
+       LM_OT_SIMPLE,
        ///
        LM_OT_EQUATION,
        ///
@@ -45,13 +47,11 @@ enum MathInsetTypes  {
        LM_OT_MULTLINE,
        ///
        LM_OT_GATHER,
-       /// An array
+       /// an array
        LM_OT_MATRIX,
 
-       /// A LaTeX macro
-       LM_OT_MACRO,
-       ///
-       LM_OT_NONE
+       /// a LaTeX macro
+       LM_OT_MACRO
 };
 
 #endif
index 954c3f7652b2e8ee5110e5a07d2286acab0dc360..dc32859eb66a36d697a90880bfa51276ae817309 100644 (file)
@@ -8,6 +8,7 @@
 #include "math_casesinset.h"
 #include "math_decorationinset.h"
 #include "math_dotsinset.h"
+#include "math_fboxinset.h"
 #include "math_fontinset.h"
 #include "math_fracinset.h"
 #include "math_kerninset.h"
@@ -54,95 +55,103 @@ struct key_type {
        ///
        string inset;
        ///
-       int id;
+       string extra;
 };
 
 
 key_type wordlist_array[] =
 {
-       {"!",  "space", 0},
-       {"(",  "begin", LM_OT_SIMPLE},
-       {")",  "end", LM_OT_SIMPLE},
-       {",",  "space", 1},
-       {":",  "space", 2},
-       {";",  "space", 3},
-       {"[",  "begin", LM_OT_EQUATION},
-       {"]",  "end", LM_OT_EQUATION},
-       {"acute",  "decoration", 0},
-       {"bar",  "decoration", 0},
-       {"begin",  "begin", 0},
-       {"bf",  "oldfont", 0},
-       {"breve",  "decoration", 0},
-       {"cal",  "oldfont", 0},
-       {"cdots",  "dots", 0},
-       {"check",  "decoration", 0},
-       {"ddot",  "decoration", 0},
-       {"dddot",  "decoration", 0},
-       {"ddots",  "dots", 0},
-       {"displaystyle",  "style", LM_ST_DISPLAY},
-       {"dot",  "decoration", 0},
-       {"dotsb",  "dots", 0},
-       {"dotsc",  "dots", 0},
-       {"dotsi",  "dots", 0},
-       {"dotsm",  "dots", 0},
-       {"dotso",  "dots", 0},
-       {"end",  "end", 0},
-       {"frak",  "font", 0},
-       {"grave",  "decoration", 0},
-       {"hat",  "decoration", 0},
-       {"it",  "oldfont", 0},
-       {"label",  "label", 0},
-       {"ldots",  "dots", 0},
-       {"left",  "left", 0},
-       {"limits",  "limit", 1 },
-       {"lyxbox",  "box", 0},
-       {"lyxnegspace",  "space", 6},
-       {"mathbb",  "font", 0},
-       {"mathbf",  "font", 0},
-       {"mathcal",  "font", 0},
-       {"mathfrak",  "font", 0},
-       {"mathit",  "font", 0},
-       {"mathnormal",  "font", 0},
-       {"mathring",  "decoration", 0},
-       {"mathrm",  "font", 0},
-       {"mathsf",  "font", 0},
-       {"mathtt",  "font", 0},
-       {"mbox",  "box", 0},
-       {"newcommand",  "newcommand", 0 },
-       {"nolimits",  "limit", -1},
-       {"nonumber",  "nonum", 0},
-       {"overbrace",  "decoration", 0},
-       {"overleftarrow",  "decoration", 0},
-       {"overline",  "decoration", 0},
-       {"overrightarrow",  "decoration", 0},
-       {"overleftrightarrow", "decoration", 0},
-       {"protect",  "protect", 0},
-       {"qquad",  "space", 5},
-       {"quad",  "space", 4},
-       {"right",  "right", 0},
-       {"rm",  "oldfont", 0},
-       {"scriptscriptstyle",  "style", LM_ST_SCRIPTSCRIPT},
-       {"scriptstyle",  "style", LM_ST_SCRIPT},
-       {"textbf",  "font", 1},
-       {"textit",  "font", 1},
-       {"textmd",  "font", 1},
-       {"textrm",  "font", 1},
-       {"textsl",  "font", 1},
-       {"textup",  "font", 1},
-       {"textstyle",  "style", LM_ST_TEXT},
-       {"tilde",  "decoration", 0},
-       {"tt",  "oldfont", 0},
-       {"underbar",  "decoration", 0},
-       {"underbrace",  "decoration", 0},
-       {"underleftarrow", "decoration", 0},
-       {"underline",  "decoration", 0},
-       {"underrightarrow", "decoration", 0},
-       {"underleftrightarrow", "decoration", 0},
-       {"underset",  "underset", 0},
-       {"vdots",  "dots", 0},
-       {"vec",  "decoration", 0},
-       {"widehat",  "decoration", 0},
-       {"widetilde",  "decoration", 0}
+       {"!",  "space", ""},
+       //{"(",  "begin", ""},
+       //{")",  "end", ""},
+       {",",  "space", ""},
+       {":",  "space", ""},
+       {";",  "space", ""},
+       //{"[",  "begin", ""},
+       //{"]",  "end", ""},
+       {"Vmatrix",  "matrix", ""},
+       {"acute",  "decoration", ""},
+       {"bar",  "decoration", ""},
+       {"begin",  "begin", ""},
+       {"bf",  "oldfont", ""},
+       {"bmatrix",  "matrix", ""},
+       {"acute",  "decoration", ""},
+       {"breve",  "decoration", ""},
+       {"cal",  "oldfont", ""},
+       {"cdots",  "dots", ""},
+       {"check",  "decoration", ""},
+       {"ddot",  "decoration", ""},
+       {"dddot",  "decoration", ""},
+       {"ddots",  "dots", ""},
+       {"displaystyle",  "style", ""},
+       {"dot",  "decoration", ""},
+       {"dotsb",  "dots", ""},
+       {"dotsc",  "dots", ""},
+       {"dotsi",  "dots", ""},
+       {"dotsm",  "dots", ""},
+       {"dotso",  "dots", ""},
+       {"end",  "end", ""},
+       {"fbox",  "fbox", ""},
+       {"frak",  "font", ""},
+       {"grave",  "decoration", ""},
+       {"hat",  "decoration", ""},
+       {"it",  "oldfont", ""},
+       {"label",  "label", ""},
+       {"ldots",  "dots", ""},
+       {"left",  "left", ""},
+       {"limits",  "limit", ""},
+       {"lyxbox",  "box", ""},
+       {"lyxnegspace",  "space", ""},
+       {"lyxposspace",  "space", ""},
+       {"mathbb",  "font", ""},
+       {"mathbf",  "font", ""},
+       {"mathcal",  "font", ""},
+       {"mathfrak",  "font", ""},
+       {"mathit",  "font", ""},
+       {"mathnormal",  "font", ""},
+       {"mathring",  "decoration", ""},
+       {"mathrm",  "font", ""},
+       {"mathsf",  "font", ""},
+       {"mathtt",  "font", ""},
+       {"matrix",  "matrix", ""},
+       {"mbox",  "box", ""},
+       {"newcommand",  "newcommand", ""},
+       {"nolimits",  "limit", ""},
+       {"nonumber",  "nonum", ""},
+       {"overbrace",  "decoration", ""},
+       {"overleftarrow",  "decoration", ""},
+       {"overline",  "decoration", ""},
+       {"overrightarrow",  "decoration", ""},
+       {"overleftrightarrow", "decoration", ""},
+       {"pmatrix",  "matrix", ""},
+       {"protect",  "protect", ""},
+       {"qquad",  "space", ""},
+       {"quad",  "space", ""},
+       {"right",  "right", ""},
+       {"rm",  "oldfont", ""},
+       {"scriptscriptstyle",  "style", ""},
+       {"scriptstyle",  "style", ""},
+       {"textbf",  "font", "mathtext"},
+       {"textit",  "font", "mathtext"},
+       {"textmd",  "font", "mathtext"},
+       {"textrm",  "font", "mathtext"},
+       {"textsl",  "font", "mathtext"},
+       {"textup",  "font", "mathtext"},
+       {"textstyle",  "style", ""},
+       {"tilde",  "decoration", ""},
+       {"tt",  "oldfont", ""},
+       {"underbar",  "decoration", ""},
+       {"underbrace",  "decoration", ""},
+       {"underleftarrow", "decoration", ""},
+       {"underline",  "decoration", ""},
+       {"underrightarrow", "decoration", ""},
+       {"underleftrightarrow", "decoration", ""},
+       {"underset",  "underset", ""},
+       {"vdots",  "dots", ""},
+       {"vec",  "decoration", ""},
+       {"vmatrix",  "matrix", ""},
+       {"widehat",  "decoration", ""},
+       {"widetilde",  "decoration", ""}
 };
 
 
@@ -161,7 +170,7 @@ bool math_font_available(string & name)
                return true;
        }
 
-       lyxerr << "font " << name << " not available and I can't fake it\n";
+       lyxerr[Debug::MATHED] << "font " << name << " not available and I can't fake it\n";
        return false;
 }
 
@@ -203,7 +212,7 @@ void readSymbols(string const & filename)
                } else {
                        lyxerr[Debug::MATHED] << "faking " << tmp.name << "\n";
                        tmp.draw = tmp.name;
-                       tmp.inset = "lyxredtext";
+                       tmp.inset = "lyxtex";
                }
 
                if (theWordList.find(tmp.name) != theWordList.end())
@@ -282,9 +291,6 @@ MathAtom createMathInset(string const & s)
                return MathAtom(new MathSubstackInset);
        if (s == "subarray" || s == "array")
                return MathAtom(new MathArrayInset(s, 1, 1));
-       if (s == "pmatrix" || s == "bmatrix" || s == "vmatrix" || s == "Vmatrix" ||
-                 s == "matrix")
-               return MathAtom(new MathAMSArrayInset(s));
        if (s == "sqrt")
                return MathAtom(new MathSqrtInset);
        if (s == "root")
@@ -301,6 +307,9 @@ MathAtom createMathInset(string const & s)
                return MathAtom(new MathNotInset);
        if (s == "lefteqn")
                return MathAtom(new MathLefteqnInset);
+       if (s == "ref")
+               return MathAtom(new RefInset);
+
 
        latexkeys const * l = in_word_set(s);
        if (l) {
@@ -316,12 +325,16 @@ MathAtom createMathInset(string const & s)
                        return MathAtom(new MathDotsInset(l->name));
                if (inset == "box")
                        return MathAtom(new MathBoxInset(l->name));
+               if (inset == "fbox")
+                       return MathAtom(new MathFboxInset);
                if (inset == "style")
                        return MathAtom(new MathSizeInset(l));
                if (inset == "font")
                        return MathAtom(new MathFontInset(l->name));
                if (inset == "oldfont")
                        return MathAtom(new MathFontInset(l->name));
+               if (inset == "matrix")
+                       return MathAtom(new MathAMSArrayInset(s));
                return MathAtom(new MathSymbolInset(l));
        }
 
diff --git a/src/mathed/math_fboxinset.C b/src/mathed/math_fboxinset.C
new file mode 100644 (file)
index 0000000..2305092
--- /dev/null
@@ -0,0 +1,53 @@
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_fboxinset.h"
+#include "math_support.h"
+#include "math_mathmlstream.h"
+#include "frontends/Painter.h"
+
+
+
+MathFboxInset::MathFboxInset()
+       : MathNestInset(1)
+{}
+
+
+MathInset * MathFboxInset::clone() const
+{
+       return new MathFboxInset(*this);
+}
+
+
+void MathFboxInset::metrics(MathMetricsInfo & mi) const
+{
+       MathFontSetChanger dummy(mi.base, "textnormal");
+       xcell(0).metrics(mi);
+       ascent_  = xcell(0).ascent()  + 5;
+       descent_ = xcell(0).descent() + 5;
+       width_   = xcell(0).width()   + 10;
+}
+
+
+void MathFboxInset::draw(MathPainterInfo & pi, int x, int y) const
+{
+       MathFontSetChanger dummy(pi.base, "textnormal");
+       pi.pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2,
+                       LColor::black);
+       xcell(0).draw(pi, x + 5, y);
+}
+
+
+void MathFboxInset::write(WriteStream & os) const
+{
+       os << "\\fbox{" << cell(0) << '}';
+}
+
+
+void MathFboxInset::normalize(NormalStream & os) const
+{
+       os << "[fbox " << cell(0) << ']';
+}
diff --git a/src/mathed/math_fboxinset.h b/src/mathed/math_fboxinset.h
new file mode 100644 (file)
index 0000000..0af5bc9
--- /dev/null
@@ -0,0 +1,34 @@
+// -*- C++ -*-
+#ifndef MATH_FBOXINSET_H
+#define MATH_FBOXINSET_H
+
+#include "math_nestinset.h"
+#include "math_metricsinfo.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+/** Extra nesting
+    \author André Pönitz
+*/
+
+class MathFboxInset : public MathNestInset {
+public:
+       ///
+       MathFboxInset();
+       ///
+       MathInset * clone() const;
+       ///
+       MathFboxInset * asFboxInset() { return this; }
+       ///
+       void metrics(MathMetricsInfo & mi) const;
+       ///
+       void draw(MathPainterInfo &, int x, int y) const;
+       ///
+       void write(WriteStream & os) const;
+       /// write normalized content
+       void normalize(NormalStream & ns) const;
+};
+
+#endif
index 2d225665411e198a17ab7ed279a9e9361680b2e9..a1e3bea0025b0a4198876a2fb2a725ce554535b3 100644 (file)
@@ -45,14 +45,7 @@ void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
        //MathNestInset::draw(pi, x, y);
        MathFontSetChanger dummy(pi.base, name_.c_str());
        xcell(0).draw(pi, x + 1, y);
-       if (editing()) {
-               int t = x + width() - 1;
-               int d = y + descent();
-               pi.pain.line(x, d - 3, x, d, LColor::mathframe); 
-               pi.pain.line(t, d - 3, t, d, LColor::mathframe); 
-               pi.pain.line(x, d, x + 3, d, LColor::mathframe); 
-               pi.pain.line(t - 2, d, t, d, LColor::mathframe); 
-       }
+       drawMarkers(pi, x, y);
 }
 
 
index ac79102345e6eac485d14d02284dc1809bd805d4..9ffe0ad39210623194a2cc9033b0c0b92c875c8b 100644 (file)
@@ -57,7 +57,8 @@ namespace {
 
        MathInsetTypes typecode(string const & s)
        {
-               if (s == "none")      return LM_OT_NONE;
+               if (s == "inline")    return LM_OT_SIMPLE;
+               if (s == "simple")    return LM_OT_SIMPLE;
                if (s == "equation")  return LM_OT_EQUATION;
                if (s == "display")   return LM_OT_EQUATION;
                if (s == "eqnarray")  return LM_OT_EQNARRAY;
@@ -67,7 +68,7 @@ namespace {
                if (s == "xxalignat") return LM_OT_XXALIGNAT;
                if (s == "multline")  return LM_OT_MULTLINE;
                if (s == "gather")    return LM_OT_GATHER;
-               return LM_OT_SIMPLE;
+               return LM_OT_NONE;
        }
 
 
@@ -92,7 +93,7 @@ namespace {
 
 
 MathHullInset::MathHullInset()
-       : MathGridInset(1, 1), objtype_(LM_OT_SIMPLE), nonum_(1), label_(1)
+       : MathGridInset(1, 1), objtype_(LM_OT_NONE), nonum_(1), label_(1)
 {
        setDefaults();
 }
@@ -173,9 +174,17 @@ int MathHullInset::defaultColSpace(col_type col)
 }
 
 
+char const * MathHullInset::standardFont() const
+{
+       if (getType() == LM_OT_NONE)
+               return "lyxnochange";
+       return "mathnormal";
+}
+
+
 void MathHullInset::metrics(MathMetricsInfo & mi) const
 {
-       MathFontSetChanger dummy(mi.base, "mathnormal");
+       MathFontSetChanger dummy(mi.base, standardFont());
 
        // let the cells adjust themselves
        MathGridInset::metrics(mi);
@@ -206,14 +215,15 @@ void MathHullInset::metrics(MathMetricsInfo & mi) const
 
 void MathHullInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       MathFontSetChanger dummy(pi.base, "mathnormal");
+       MathFontSetChanger dummy(pi.base, standardFont());
        MathGridInset::draw(pi, x, y);
 
        if (numberedType()) {
                int const xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
                for (row_type row = 0; row < nrows(); ++row) {
                        int const yy = y + rowinfo_[row].offset_;
-                       drawStrBlack(pi, xx, yy, nicelabel(row));
+                       MathFontSetChanger dummy(pi.base, "mathrm");
+                       drawStr(pi, pi.base.font, xx, yy, nicelabel(row));
                }
        }
 }
@@ -293,7 +303,7 @@ bool MathHullInset::ams() const
 
 bool MathHullInset::display() const
 {
-       return getType() != LM_OT_SIMPLE;
+       return getType() != LM_OT_SIMPLE && getType() != LM_OT_NONE;
 }
 
 
@@ -309,7 +319,11 @@ vector<string> const MathHullInset::getLabelList() const
 
 bool MathHullInset::numberedType() const
 {
-       if (getType() == LM_OT_SIMPLE || getType() == LM_OT_XXALIGNAT)
+       if (getType() == LM_OT_NONE)
+               return false;
+       if (getType() == LM_OT_SIMPLE)
+               return false;
+       if (getType() == LM_OT_XXALIGNAT)
                return false;
        for (row_type row = 0; row < nrows(); ++row)
                if (!nonum_[row])
@@ -341,6 +355,9 @@ void MathHullInset::header_write(WriteStream & os) const
        bool n = numberedType();
 
        switch (getType()) {
+               case LM_OT_NONE:
+                       break;
+
                case LM_OT_SIMPLE:
                        os << '$';
                        if (cell(0).empty())
@@ -385,9 +402,6 @@ void MathHullInset::header_write(WriteStream & os) const
                        os << "\\begin{gather}\n";
                        break;
 
-               case LM_OT_NONE:
-                       break;
-
                default:
                        os << "\\begin{unknown" << star(n) << "}";
        }
@@ -399,6 +413,10 @@ void MathHullInset::footer_write(WriteStream & os) const
        bool n = numberedType();
 
        switch (getType()) {
+               case LM_OT_NONE:
+                       os << "\n";
+                       break;
+
                case LM_OT_SIMPLE:
                        os << '$';
                        break;
@@ -438,10 +456,6 @@ void MathHullInset::footer_write(WriteStream & os) const
                        os << "\n\\end{gather}\n";
                        break;
 
-               case LM_OT_NONE:
-                       os << "\n";
-                       break;
-
                default:
                        os << "\\end{unknown" << star(n) << "}";
        }
@@ -562,16 +576,30 @@ void MathHullInset::mutate(MathInsetTypes newtype)
                return;
 
        switch (getType()) {
-               case LM_OT_SIMPLE:
-                       setType(LM_OT_EQUATION);
+               case LM_OT_NONE:
+                       setType(LM_OT_SIMPLE);
                        numbered(0, false);
                        mutate(newtype);
                        break;
 
+               case LM_OT_SIMPLE:
+                       switch (newtype) {
+                               case LM_OT_NONE:
+                                       setType(LM_OT_NONE);
+                                       break;
+                               default:
+                                       setType(LM_OT_EQUATION);
+                                       numbered(0, false);
+                                       mutate(newtype);
+                       }
+                       break;
+
                case LM_OT_EQUATION:
                        switch (newtype) {
+                               case LM_OT_NONE:
                                case LM_OT_SIMPLE:
                                        setType(LM_OT_SIMPLE);
+                                       mutate(newtype);
                                        break;
 
                                case LM_OT_ALIGN:
@@ -752,11 +780,53 @@ void MathHullInset::mathmlize(MathMLStream & os) const
 
 void MathHullInset::infoize(std::ostream & os) const
 {
-       os << normalName(getType());
+       os << "Type: " << normalName(getType());
 }
 
+
 void MathHullInset::check() const
 {
        lyx::Assert(nonum_.size() == nrows());
        lyx::Assert(label_.size() == nrows());
 }
+
+
+
+
+
+//
+// MathParInset
+//
+
+MathParInset::MathParInset()
+{
+       lyxerr << "constructing MathParInset\n";
+}
+
+
+void MathParInset::metrics(MathMetricsInfo & mi) const
+{
+       MathFontSetChanger dummy(mi.base, "textnormal");
+       MathGridInset::metrics(mi);
+}
+
+
+void MathParInset::draw(MathPainterInfo & pi, int x, int y) const
+{
+       MathFontSetChanger dummy(pi.base, "textnormal");
+       MathGridInset::draw(pi, x, y);
+}
+
+
+void MathParInset::write(WriteStream & os) const
+{
+       for (idx_type i = 0; i < nargs(); ++i)
+               os << cell(i) << "\n";
+}
+
+
+void MathParInset::infoize(std::ostream & os) const
+{
+       os << "Type: Paragraph ";
+}
+
index c9d90deb1cb6919d88ce39806a9fedcb372fa505..7c7916316fc2290a15553c849dfd11b41a313bc4 100644 (file)
@@ -27,11 +27,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo & st) const;
+       void metrics(MathMetricsInfo & mi) const;
        ///
        void draw(MathPainterInfo &, int x, int y) const;
        ///
-       void metricsT(TextMetricsInfo const & st) const;
+       void metricsT(TextMetricsInfo const & mi) const;
        ///
        void drawT(TextPainter &, int x, int y) const;
        ///
@@ -101,9 +101,11 @@ private:
        ///
        void footer_write(WriteStream &) const;
        ///
+       string nicelabel(row_type row) const;
+       ///
        void glueall();
        ///
-       string nicelabel(row_type row) const;
+       char const * standardFont() const;
        /// consistency check
        void check() const;
 
@@ -115,4 +117,25 @@ private:
        std::vector<string> label_;
 };
 
+
+class MathParInset : public MathHullInset {
+public:
+       ///
+       MathParInset();
+       ///
+       MathParInset * asParInset() { return this; }
+       ///
+       void metrics(MathMetricsInfo & mi) const;
+       ///
+       void draw(MathPainterInfo &, int x, int y) const;
+       ///
+       void infoize(std::ostream & os) const;
+       ///
+       void write(WriteStream & os) const;
+private:
+       ///
+       void rebreak();
+};
+
+
 #endif
index c137de313afdde05694c7f755168085020d83295..044ef6c1a0ab7bd0170dbcbabba6b18dad828c57 100644 (file)
@@ -24,6 +24,7 @@
 #include "Lsstream.h"
 #include "math_inset.h"
 #include "math_scriptinset.h"
+#include "math_charinset.h"
 #include "math_mathmlstream.h"
 #include "debug.h"
 
@@ -244,3 +245,46 @@ void MathInset::mathmlize(MathMLStream & os) const
        NormalStream ns(os.os());
        normalize(ns);
 }
+
+
+int MathInset::ascii(std::ostream &, int) const
+{
+       return 0;
+}
+
+
+int MathInset::linuxdoc(std::ostream &) const
+{
+       return 0;
+}
+
+
+int MathInset::docbook(std::ostream &, bool) const
+{
+       return 0;
+}
+
+
+int MathInset::dispatch(string const &, idx_type, pos_type) 
+{
+       return 0; // undispatched
+}
+
+
+string asString(MathArray const & ar)
+{
+       string res;
+       for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
+               if ((*it)->getChar())
+                       res += (*it)->getChar();
+       return res;
+}
+
+
+MathArray asArray(string const & str)
+{
+       MathArray ar;
+       for (string::const_iterator it = str.begin(); it != str.end(); ++it)
+               ar.push_back(MathAtom(new MathCharInset(*it)));
+       return ar;
+}
index 30396bad669026250e78c76510856d7eec479675..47f9b8bb9e275d34b2876c172f3fccac6bddb109 100644 (file)
@@ -53,12 +53,14 @@ class MathBraceInset;
 class MathBoxInset;
 class MathCharInset;
 class MathDelimInset;
+class MathFboxInset;
 class MathFontInset;
 class MathGridInset;
 class MathFracInset;
 class MathHullInset;
 class MathMatrixInset;
 class MathNestInset;
+class MathParInset;
 class MathScriptInset;
 class MathStringInset;
 class MathSpaceInset;
@@ -192,6 +194,7 @@ public:
        virtual MathCharInset const    * asCharInset() const    { return 0; }
        virtual MathDelimInset         * asDelimInset()         { return 0; }
        virtual MathDelimInset const   * asDelimInset() const   { return 0; }
+       virtual MathFboxInset          * asFboxInset()          { return 0; }
        virtual MathFontInset const    * asFontInset() const    { return 0; }
        virtual MathFracInset          * asFracInset()          { return 0; }
        virtual MathGridInset          * asGridInset()          { return 0; }
@@ -200,6 +203,7 @@ public:
        virtual MathMacroTemplate      * asMacroTemplate()      { return 0; }
        virtual MathMatrixInset const  * asMatrixInset() const  { return 0; }
        virtual MathNestInset          * asNestInset()          { return 0; }
+       virtual MathParInset           * asParInset()           { return 0; }
        virtual MathScriptInset        * asScriptInset()        { return 0; }
        virtual MathScriptInset const  * asScriptInset() const  { return 0; }
        virtual MathSpaceInset         * asSpaceInset()         { return 0; }
@@ -253,12 +257,23 @@ public:
        virtual void octavize(OctaveStream &) const;
        /// describe content
        virtual void infoize(std::ostream &) const {}
+       /// plain ascii output
+       virtual int ascii(std::ostream & os, int) const;
+       /// linuxdoc output
+       virtual int linuxdoc(std::ostream & os) const;
+       /// docbook output
+       virtual int docbook(std::ostream & os, bool) const;
 
        /// dump content to stderr for debugging
        virtual void dump() const;
+       /// local dispatcher
+       virtual int dispatch(string const & cmd, idx_type idx, pos_type pos);
 };
 
 std::ostream & operator<<(std::ostream &, MathInset const &);
 std::ostream & operator<<(std::ostream &, MathAtom const &);
 
+string asString(MathArray const & ar);
+MathArray asArray(string const & str);
+
 #endif
index 0ee956ed1335d543dcdf4bf4d7f8dcc8060afa67..bb0fc39a85a707e8451e20112f42d0501f62887b 100644 (file)
@@ -115,7 +115,7 @@ void MathMacro::metrics(MathMetricsInfo & mi) const
 }
 
 
-void MathMacro::draw(MathPainterInfo & pain, int x, int y) const
+void MathMacro::draw(MathPainterInfo & pi, int x, int y) const
 {
        metrics(mi_);
 
@@ -123,16 +123,16 @@ void MathMacro::draw(MathPainterInfo & pain, int x, int y) const
        augmentFont(texfont, "lyxtex");
 
        if (defining()) {
-               drawStr(pain, texfont, x, y, name());
+               drawStr(pi, texfont, x, y, name());
                return;
        }
 
        if (editing()) {
                int h = y - ascent() + 2 + expanded_.ascent();
-               drawStr(pain, font_, x + 3, h, name());
+               drawStr(pi, font_, x + 3, h, name());
 
                int const w = mathed_string_width(font_, name());
-               expanded_.draw(pain, x + w + 12, h);
+               expanded_.draw(pi, x + w + 12, h);
                h += expanded_.descent();
 
                int lasc;
@@ -143,16 +143,16 @@ void MathMacro::draw(MathPainterInfo & pain, int x, int y) const
                for (idx_type i = 0; i < nargs(); ++i) {
                        MathXArray const & c = xcell(i);
                        h += max(c.ascent(), lasc) + 5;
-                       c.draw(pain, x + lwid, h);
+                       c.draw(pi, x + lwid, h);
                        char str[] = "#1:";
                        str[1] += static_cast<char>(i);
-                       drawStr(pain, texfont, x + 3, h, str);
+                       drawStr(pi, texfont, x + 3, h, str);
                        h += max(c.descent(), ldes) + 5;
                }
                return;
        }
 
-       expanded_.draw(pain, x, y);
+       expanded_.draw(pi, x, y);
 }
 
 
index 04c96f11f8ff3470d4acad28e46be9d02e50734b..22186a52ee52fff2d81898f46f026ba39f9957a9 100644 (file)
@@ -57,14 +57,16 @@ void MathMacroTemplate::metrics(MathMetricsInfo & mi) const
 }
 
 
-void MathMacroTemplate::draw(MathPainterInfo & pain, int x, int y) const
+void MathMacroTemplate::draw(MathPainterInfo & pi, 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.pain.rectangle(x, y - ascent() + 1, w0 + 4, height(), LColor::blue);
-       xcell(1).draw(pain, x + 8 + w0, y + 1);
-       pain.pain.rectangle(x + w0 + 6 , y - ascent() + 1, w1 + 4, height(), LColor::blue);
+       xcell(0).draw(pi, x + 2, y + 1);
+       pi.pain.rectangle(x, y - ascent() + 1, w0 + 4, height(),
+                       LColor::blue);
+       xcell(1).draw(pi, x + 8 + w0, y + 1);
+       pi.pain.rectangle(x + w0 + 6 , y - ascent() + 1, w1 + 4,
+                       height(), LColor::blue);
 }
 
 
index b2d9655a433bf43b2c030ff03ae85b2567a1cadf..c67666853e32508dad00bc27d998d7d27efccd94 100644 (file)
@@ -156,6 +156,19 @@ void MathNestInset::draw(MathPainterInfo &, int, int) const
 }
 
 
+void MathNestInset::drawMarkers(MathPainterInfo & pi, int x, int y) const
+{
+       if (!editing())
+               return;
+       int t = x + width() - 1;
+       int d = y + descent();
+       pi.pain.line(x, d - 3, x, d, LColor::mathframe); 
+       pi.pain.line(t, d - 3, t, d, LColor::mathframe); 
+       pi.pain.line(x, d, x + 3, d, LColor::mathframe); 
+       pi.pain.line(t - 2, d, t, d, LColor::mathframe); 
+}
+
+
 void MathNestInset::validate(LaTeXFeatures & features) const
 {
        for (idx_type i = 0; i < nargs(); ++i)
index 5d49d39d2acf9236b985b36e14ba962e35c64f03..64caa87a8e1124ceae9228e63923affec1c66bbd 100644 (file)
@@ -24,6 +24,8 @@ public:
        void metrics(MathMetricsInfo const & mi) const;
        /// draw background if locked
        void draw(MathPainterInfo & pi, int x, int y) const;
+       /// draw angular markers
+       void drawMarkers(MathPainterInfo & pi, int x, int y) const;
        /// appends itself with macro arguments substituted
        void substitute(MathMacro const & macro);
        /// identifies NestInsets
index bce39fe1e86837be3453a5a76f9787170c858128..bdb32719e22f743bf3c40669c4a13f7eb5970e6e 100644 (file)
@@ -89,12 +89,6 @@ bool stared(string const & s)
 }
 
 
-void add(MathArray & ar, char c)
-{
-       ar.push_back(MathAtom(new MathCharInset(c)));
-}
-
-
 // These are TeX's catcodes
 enum CatCode {
        catEscape,     // 0    backslash
@@ -227,9 +221,9 @@ public:
        ///
        bool parse_macro(string & name);
        ///
-       bool parse_normal(MathAtom &);
+       bool parse_normal(MathAtom & at);
        ///
-       void parse_into(MathArray & array, unsigned flags);
+       void parse_into(MathArray & array, unsigned flags, bool mathmode);
        ///
        int lineno() const { return lineno_; }
        ///
@@ -237,9 +231,9 @@ public:
 
 private:
        ///
-       void parse_into1(MathGridInset & grid, unsigned flags, bool numbered);
+       void parse_into1(MathGridInset & grid, unsigned flags, bool mathmode, bool numbered);
        ///
-       void parse_into2(MathAtom & at, unsigned flags, bool numbered);
+       void parse_into2(MathAtom & at, unsigned flags, bool mathmode, bool numbered);
        /// get arg delimited by 'left' and 'right'
        string getArg(char left, char right);
        ///
@@ -352,10 +346,8 @@ bool Parser::good() const
 
 char Parser::getChar()
 {
-       if (!good()) {
-               lyxerr << "The input stream is not well..." << endl;
-               dump();
-       }
+       if (!good())
+               error("The input stream is not well...");
        return tokens_[pos_++].character();
 }
 
@@ -519,15 +511,13 @@ bool Parser::parse_macro(string & name)
                        pars += getToken().cs();
 
                if (!good()) {
-                       lyxerr << "bad stream in parse_macro\n";
-                       dump();
+                       error("bad stream in parse_macro\n");
                        return false;
                }
 
                //lyxerr << "read \\def parameter list '" << pars << "'\n";
                if (!pars.empty()) {
-                       lyxerr << "can't handle non-empty parameter lists\n";
-                       dump();
+                       error("can't handle non-empty parameter lists\n");
                        return false;
                }
 
@@ -536,15 +526,14 @@ bool Parser::parse_macro(string & name)
                getToken();
 
                if (getToken().cat() != catBegin) {
-                       lyxerr << "'{' in \\newcommand expected (1) \n";
-                       dump();
+                       error("'{' in \\newcommand expected (1) \n");
                        return false;
                }
 
                name = getToken().cs();
 
                if (getToken().cat() != catEnd) {
-                       lyxerr << "'}' expected\n";
+                       error("'}' expected\n");
                        return false;
                }
 
@@ -564,7 +553,7 @@ bool Parser::parse_macro(string & name)
        }
 
        MathArray ar1;
-       parse_into(ar1, FLAG_BRACE_LAST);
+       parse_into(ar1, FLAG_BRACE_LAST, true);
 
        // we cannot handle recursive stuff at all
        MathArray test;
@@ -576,131 +565,32 @@ bool Parser::parse_macro(string & name)
 
        // is a version for display attached?
        MathArray ar2;
-       parse_into(ar2, FLAG_ITEM);
+       parse_into(ar2, FLAG_ITEM, true);
 
        MathMacroTable::create(name, nargs, ar1, ar2);
        return true;
 }
  
 
-bool Parser::parse_normal(MathAtom & matrix)
+bool Parser::parse_normal(MathAtom & at)
 {
-       skipSpaces();
-       Token const & t = getToken();
-
-       if (t.cs() == "(") {
-               matrix = MathAtom(new MathHullInset(LM_OT_SIMPLE));
-               parse_into2(matrix, FLAG_SIMPLE2, true);
-               return true;
-       }
-
-       if (t.cat() == catMath) {
-               Token const & n = getToken();
-               if (n.cat() == catMath) {
-                       // TeX's $$...$$ syntax for displayed math
-                       matrix = MathAtom(new MathHullInset(LM_OT_EQUATION));
-                       parse_into2(matrix, FLAG_SIMPLE, false);
-                       getToken(); // skip the second '$' token
-               } else {
-                       // simple $...$  stuff
-                       putback();
-                       matrix = MathAtom(new MathHullInset(LM_OT_SIMPLE));
-                       parse_into2(matrix, FLAG_SIMPLE, false);
-               }
+       MathArray ar;
+       parse_into(ar, false, false);
+       if (ar.size() != 1) {
+               lyxerr << "Unusual contents found: " << ar << endl;
+               at.reset(new MathParInset);
+               at->cell(0) = ar;
                return true;
        }
-
-       if (!t.cs().size()) {
-               lyxerr << "start of math expected, got '" << t << "'\n";
-               return false;
-       }
-
-       string const & cs = t.cs();
-
-       if (cs == "[") {
-               matrix = MathAtom(new MathHullInset(LM_OT_EQUATION));
-               parse_into2(matrix, FLAG_EQUATION, true);
-               return true;
-       }
-
-       if (cs != "begin") {
-               lyxerr[Debug::MATHED]
-                       << "'begin' of un-simple math expected, got '" << cs << "'\n";
-               return false;
-       }
-
-       string const name = getArg('{', '}');
-
-       if (name == "math") {
-               matrix = MathAtom(new MathHullInset(LM_OT_SIMPLE));
-               parse_into2(matrix, FLAG_SIMPLE, true);
-               return true;
-       }
-
-       if (name == "equation" || name == "equation*" || name == "displaymath") {
-               matrix = MathAtom(new MathHullInset(LM_OT_EQUATION));
-               parse_into2(matrix, FLAG_END, (name == "equation"));
-               return true;
-       }
-
-       if (name == "eqnarray" || name == "eqnarray*") {
-               matrix = MathAtom(new MathHullInset(LM_OT_EQNARRAY));
-               parse_into2(matrix, FLAG_END, !stared(name));
-               return true;
-       }
-
-       if (name == "align" || name == "align*") {
-               matrix = MathAtom(new MathHullInset(LM_OT_ALIGN));
-               parse_into2(matrix, FLAG_END, !stared(name));
-               return true;
-       }
-
-       if (name == "alignat" || name == "alignat*") {
-               // ignore this for a while
-               getArg('{', '}');
-               matrix = MathAtom(new MathHullInset(LM_OT_ALIGNAT));
-               parse_into2(matrix, FLAG_END, !stared(name));
-               return true;
-       }
-
-       if (name == "xalignat" || name == "xalignat*") {
-               // ignore this for a while
-               getArg('{', '}');
-               matrix = MathAtom(new MathHullInset(LM_OT_XALIGNAT));
-               parse_into2(matrix, FLAG_END, !stared(name));
-               return true;
-       }
-
-       if (name == "xxalignat") {
-               // ignore this for a while
-               getArg('{', '}');
-               matrix = MathAtom(new MathHullInset(LM_OT_XXALIGNAT));
-               parse_into2(matrix, FLAG_END, !stared(name));
-               return true;
-       }
-
-       if (name == "multline" || name == "multline*") {
-               matrix = MathAtom(new MathHullInset(LM_OT_MULTLINE));
-               parse_into2(matrix, FLAG_END, !stared(name));
-               return true;
-       }
-
-       if (name == "gather" || name == "gather*") {
-               matrix = MathAtom(new MathHullInset(LM_OT_GATHER));
-               parse_into2(matrix, FLAG_END, !stared(name));
-               return true;
-       }
-
-       lyxerr[Debug::MATHED] << "1: unknown math environment: " << name << "\n";
-       lyxerr << "1: unknown math environment: " << name << "\n";
-       return false;
+       at = ar[0];
+       return true;
 }
 
 
-void Parser::parse_into(MathArray & array, unsigned flags)
+void Parser::parse_into(MathArray & array, unsigned flags, bool mathmode)
 {
        MathGridInset grid(1, 1);
-       parse_into1(grid, flags, false);
+       parse_into1(grid, flags, mathmode, false);
        array = grid.cell(0);
        // remove 'unnecessary' braces:
        if (array.size() == 1 && array.back()->asBraceInset()) {
@@ -710,13 +600,15 @@ void Parser::parse_into(MathArray & array, unsigned flags)
 }
 
 
-void Parser::parse_into2(MathAtom & at, unsigned flags, bool numbered)
+void Parser::parse_into2(MathAtom & at, unsigned flags,
+       bool mathmode, bool numbered)
 {
-       parse_into1(*(at->asGridInset()), flags, numbered);
+       parse_into1(*(at->asGridInset()), flags, mathmode, numbered);
 }
 
 
-void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
+void Parser::parse_into1(MathGridInset & grid, unsigned flags,
+       bool mathmode, bool numbered)
 {
        int  limits = 0;
        MathGridInset::row_type cellrow = 0;
@@ -758,28 +650,38 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                // cat codes
                //
                if (t.cat() == catMath) {
-                       if (flags & FLAG_TEXTMODE) {
+                       if (!mathmode) {
                                // we are inside some text mode thingy, so opening new math is allowed
-                               MathAtom at(new MathHullInset(LM_OT_SIMPLE));
-                               parse_into2(at, FLAG_SIMPLE, false);
-                               cell->push_back(at);
+                               Token const & n = getToken();
+                               if (n.cat() == catMath) {
+                                       // TeX's $$...$$ syntax for displayed math
+                                       cell->push_back(MathAtom(new MathHullInset(LM_OT_EQUATION)));
+                                       parse_into2(cell->back(), FLAG_SIMPLE, true, false);
+                                       getToken(); // skip the second '$' token
+                               } else {
+                                       // simple $...$  stuff
+                                       putback();
+                                       cell->push_back(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
+                                       parse_into2(cell->back(), FLAG_SIMPLE, true, false);
+                               }
                        }
+
                        else if (flags & FLAG_SIMPLE) {
                                // this is the end of the formula
                                return;
                        }
+
                        else {
-                               dump();
-                               lyxerr << "something strange in the parser\n";
+                               error("something strange in the parser\n");
                                break;
                        }
                }
 
                else if (t.cat() == catLetter)
-                       add(*cell, t.character());
+                       cell->push_back(MathAtom(new MathCharInset(t.character())));
 
-               else if (t.cat() == catSpace && (flags & FLAG_TEXTMODE))
-                       add(*cell, t.character());
+               else if (t.cat() == catSpace && !mathmode)
+                       cell->push_back(MathAtom(new MathCharInset(t.character())));
 
                else if (t.cat() == catParameter) {
                        Token const & n = getToken();
@@ -788,15 +690,15 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
 
                else if (t.cat() == catBegin) {
                        MathArray ar;
-                       parse_into(ar, FLAG_BRACE_LAST);
+                       parse_into(ar, FLAG_BRACE_LAST, mathmode);
 #ifndef WITH_WARNINGS
 #warning this might be wrong in general!
 #endif
                        // ignore braces around simple items
                        if ((ar.size() == 1 && !ar.front()->needsBraces()
-       || (ar.size() == 2 && !ar.front()->needsBraces()
-                                           && ar.back()->asScriptInset()))
-       || (ar.size() == 0 && cell->size() == 0))
+                        || (ar.size() == 2 && !ar.front()->needsBraces()
+                                                       && ar.back()->asScriptInset()))
+                        || (ar.size() == 0 && cell->size() == 0))
                        {
                                cell->push_back(ar);
                        } else {
@@ -835,7 +737,7 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                                p = cell->back()->asScriptInset();
                        }
                        p->ensure(up);
-                       parse_into(p->cell(up), FLAG_ITEM);
+                       parse_into(p->cell(up), FLAG_ITEM, mathmode);
                        p->limits(limits);
                        limits = 0;
                }
@@ -847,13 +749,23 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                        return;
 
                else if (t.cat() == catOther)
-                       add(*cell, t.character());
+                       cell->push_back(MathAtom(new MathCharInset(t.character())));
 
                //
                // control sequences
                //
+               else if (t.cs() == "(") {
+                       cell->push_back(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
+                       parse_into2(cell->back(), FLAG_SIMPLE2, true, true);
+               }
+
+               else if (t.cs() == "[") {
+                       cell->push_back(MathAtom(new MathHullInset(LM_OT_EQUATION)));
+                       parse_into2(cell->back(), FLAG_EQUATION, true, true);
+               }
+
                else if (t.cs() == "protect")
-                       // ignore \\protect, will be re-added during output
+                       // ignore \\protect, will hopefully be re-added during output
                        ;
 
                else if (t.cs() == "end") {
@@ -889,7 +801,7 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                else if (t.cs() == "multicolumn") {
                        // extract column count and insert dummy cells
                        MathArray count;
-                       parse_into(count, FLAG_ITEM);
+                       parse_into(count, FLAG_ITEM, mathmode);
                        int cols = 1;
                        if (!extractNumber(count, cols)) {
                                lyxerr << " can't extract number of cells from " << count << "\n";
@@ -910,11 +822,11 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
 
                        // read special alignment
                        MathArray align;
-                       parse_into(align, FLAG_ITEM);
+                       parse_into(align, FLAG_ITEM, mathmode);
                        //grid.cellinfo(grid.index(cellrow, cellcol)).align_ = extractString(align);
 
                        // parse the remaining contents into the "real" cell
-                       parse_into(*cell, FLAG_ITEM);
+                       parse_into(*cell, FLAG_ITEM, mathmode);
                }
 #endif
 
@@ -943,30 +855,39 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                        char c = getChar();
                        if (c == '[') {
                                cell->push_back(MathAtom(new MathRootInset));
-                               parse_into(cell->back()->cell(0), FLAG_BRACK_END);
-                               parse_into(cell->back()->cell(1), FLAG_ITEM);
+                               parse_into(cell->back()->cell(0), FLAG_BRACK_END, mathmode);
+                               parse_into(cell->back()->cell(1), FLAG_ITEM, mathmode);
                        } else {
                                putback();
                                cell->push_back(MathAtom(new MathSqrtInset));
-                               parse_into(cell->back()->cell(0), FLAG_ITEM);
+                               parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
                        }
                }
 
+               else if (t.cs() == "ref") {
+                       cell->push_back(MathAtom(new RefInset));
+                       char c = getChar();
+                       if (c == '[') 
+                               parse_into(cell->back()->cell(1), FLAG_BRACK_END, mathmode);
+                       else 
+                               putback();
+                       parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
+               }
+
                else if (t.cs() == "left") {
                        string l = getToken().asString();
                        MathArray ar;
-                       parse_into(ar, FLAG_RIGHT);
+                       parse_into(ar, FLAG_RIGHT, mathmode);
                        string r = getToken().asString();
-                       MathAtom dl(new MathDelimInset(l, r));
-                       dl->cell(0) = ar;
-                       cell->push_back(dl);
+                       cell->push_back(MathAtom(new MathDelimInset(l, r)));
+                       cell->back()->cell(0) = ar;
                }
 
                else if (t.cs() == "right") {
-                       if (!(flags & FLAG_RIGHT)) {
-                               //lyxerr << "got so far: '" << cell << "'\n";
-                               error("Unmatched right delimiter");
-                       }
+                       if (flags & FLAG_RIGHT)
+                               return;
+                       //lyxerr << "got so far: '" << cell << "'\n";
+                       error("Unmatched right delimiter");
                        return;
                }
 
@@ -976,17 +897,78 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                                string const valign = getArg('[', ']') + 'c';
                                string const halign = getArg('{', '}');
                                cell->push_back(MathAtom(new MathArrayInset(name, valign[0], halign)));
-                               parse_into2(cell->back(), FLAG_END, false);
-                       } else if (name == "split" || name == "cases" ||
+                               parse_into2(cell->back(), FLAG_END, mathmode, false);
+                       }
+
+                       else if (name == "split" || name == "cases" ||
                                         name == "gathered" || name == "aligned") {
                                cell->push_back(createMathInset(name));
-                               parse_into2(cell->back(), FLAG_END, false);
-                       } else if (name == "matrix"  || name == "pmatrix" || name == "bmatrix" ||
-                                        name == "vmatrix" || name == "Vmatrix") {
-                               cell->push_back(createMathInset(name));
-                               parse_into2(cell->back(), FLAG_END, false);
-                       } else
-                               lyxerr << "unknow math inset begin '" << name << "'\n";
+                               parse_into2(cell->back(), FLAG_END, mathmode, false);
+                       }
+
+                       else if (name == "math") {
+                               cell->push_back(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
+                               parse_into2(cell->back(), FLAG_SIMPLE, true, true);
+                       }
+
+                       else if (name == "equation" || name == "equation*"
+                                       || name == "displaymath") {
+                               cell->push_back(MathAtom(new MathHullInset(LM_OT_EQUATION)));
+                               parse_into2(cell->back(), FLAG_END, true, (name == "equation"));
+                       }
+
+                       else if (name == "eqnarray" || name == "eqnarray*") {
+                               cell->push_back(MathAtom(new MathHullInset(LM_OT_EQNARRAY)));
+                               parse_into2(cell->back(), FLAG_END, true, !stared(name));
+                       }
+
+                       else if (name == "align" || name == "align*") {
+                               cell->push_back(MathAtom(new MathHullInset(LM_OT_ALIGN)));
+                               parse_into2(cell->back(), FLAG_END, true, !stared(name));
+                       }
+
+                       else if (name == "alignat" || name == "alignat*") {
+                               // ignore this for a while
+                               getArg('{', '}');
+                               cell->push_back(MathAtom(new MathHullInset(LM_OT_ALIGNAT)));
+                               parse_into2(cell->back(), FLAG_END, true, !stared(name));
+                       }
+
+                       else if (name == "xalignat" || name == "xalignat*") {
+                               // ignore this for a while
+                               getArg('{', '}');
+                               cell->push_back(MathAtom(new MathHullInset(LM_OT_XALIGNAT)));
+                               parse_into2(cell->back(), FLAG_END, true, !stared(name));
+                       }
+
+                       else if (name == "xxalignat") {
+                               // ignore this for a while
+                               getArg('{', '}');
+                               cell->push_back(MathAtom(new MathHullInset(LM_OT_XXALIGNAT)));
+                               parse_into2(cell->back(), FLAG_END, true, !stared(name));
+                       }
+
+                       else if (name == "multline" || name == "multline*") {
+                               cell->push_back(MathAtom(new MathHullInset(LM_OT_MULTLINE)));
+                               parse_into2(cell->back(), FLAG_END, true, !stared(name));
+                       }
+
+                       else if (name == "gather" || name == "gather*") {
+                               cell->push_back(MathAtom(new MathHullInset(LM_OT_GATHER)));
+                               parse_into2(cell->back(), FLAG_END, true, !stared(name));
+                       }
+
+                       else {
+                               latexkeys const * l = in_word_set(name);
+                               if (l) {
+                                       if (l->inset == "matrix") {
+                                               cell->push_back(createMathInset(name));
+                                               parse_into2(cell->back(), FLAG_END, mathmode, false);
+                                       }
+                               } else {
+                                       lyxerr << "unknow math inset begin '" << name << "'\n";
+                               }
+                       }
                }
 
                else if (t.cs() == "kern") {
@@ -1015,19 +997,19 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") {
                        MathAtom p = createMathInset(t.cs());
                        cell->swap(p->cell(0));
-                       parse_into(p->cell(1), flags);
+                       parse_into(p->cell(1), flags, mathmode);
                        cell->push_back(p);
                        return;
                }
 
                else if (t.cs() == "substack") {
                        cell->push_back(createMathInset(t.cs()));
-                       parse_into2(cell->back(), FLAG_ITEM, false);
+                       parse_into2(cell->back(), FLAG_ITEM, mathmode, false);
                }
 
                else if (t.cs() == "xymatrix") {
                        cell->push_back(createMathInset(t.cs()));
-                       parse_into2(cell->back(), FLAG_ITEM, false);
+                       parse_into2(cell->back(), FLAG_ITEM, mathmode, false);
                }
 
 #if 0
@@ -1038,7 +1020,7 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                        // try to read target
                        char c = getChar();
                        if (c == '[') {
-                               parse_into(p->cell(0), FLAG_BRACK_END);
+                               parse_into(p->cell(0), FLAG_BRACK_END, mathmode);
                                //lyxerr << "read target: " << p->cell(0) << "\n";
                        } else {
                                putback();
@@ -1048,7 +1030,7 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                        if (nextToken().cat() == catSuper || nextToken().cat() == catSub) {
                                p->up_ = nextToken().cat() == catSuper;
                                getToken();
-                               parse_into(p->cell(1), FLAG_ITEM);
+                               parse_into(p->cell(1), FLAG_ITEM, mathmode);
                                //lyxerr << "read label: " << p->cell(1) << "\n";
                        }
 
@@ -1064,35 +1046,33 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                                        lyxerr << "starting font " << t.cs() << "\n";
                                        MathAtom p = createMathInset(t.cs());
                                        bool textmode = (t.cs()[0] == 't');
-                                       parse_into(p->cell(0), FLAG_ITEM | (textmode ? FLAG_TEXTMODE : 0));
+                                       parse_into(p->cell(0), FLAG_ITEM, !textmode);
                                        cell->push_back(p);
                                        //lyxerr << "ending font\n";
                                }
 
                                else if (l->inset == "oldfont") {
-                                       MathAtom p = createMathInset(t.cs());
-                                       parse_into(p->cell(0), flags);
-                                       cell->push_back(p);
+                                       cell->push_back(createMathInset(t.cs()));
+                                       parse_into(cell->back()->cell(0), flags, l->extra == "mathmode");
                                        return;
                                }
 
                                else if (l->inset == "box") {
-                                       MathAtom p = createMathInset(t.cs());
-                                       parse_into(p->cell(0), FLAG_ITEM | FLAG_TEXTMODE);
-                                       cell->push_back(p);
+                                       // switch to text mode
+                                       cell->push_back(createMathInset(t.cs()));
+                                       parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
                                }
 
                                else if (l->inset == "style") {
-                                       MathAtom p = createMathInset(t.cs());
-                                       parse_into(p->cell(0), flags);
-                                       cell->push_back(p);
+                                       cell->push_back(createMathInset(t.cs()));
+                                       parse_into(cell->back()->cell(0), flags, mathmode);
                                        return;
                                }
 
                                else {
                                        MathAtom p = createMathInset(t.cs());
                                        for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
-                                               parse_into(p->cell(i), FLAG_ITEM);
+                                               parse_into(p->cell(i), FLAG_ITEM, l->extra == "mathmode");
                                        cell->push_back(p);
                                }
                        }
@@ -1100,7 +1080,7 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                        else {
                                MathAtom p = createMathInset(t.cs());
                                for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
-                                       parse_into(p->cell(i), FLAG_ITEM);
+                                       parse_into(p->cell(i), FLAG_ITEM, mathmode);
                                cell->push_back(p);
                        }
                }
@@ -1127,7 +1107,7 @@ void mathed_parse_cell(MathArray & ar, string const & str)
 
 void mathed_parse_cell(MathArray & ar, istream & is)
 {
-       Parser(is).parse_into(ar, 0);
+       Parser(is).parse_into(ar, 0, true);
 }
 
 
index 3cd524e0593e0100c3f702ce1cc9f8b6b60037cd..3cc23305b809115f17410d614d32a9741d61c077 100644 (file)
@@ -230,7 +230,7 @@ double const  Vert[] = {
 
 double const tilde[] = {
        2, 4,
-       0.05, 0.8,  0.25, 0.2,  0.75, 0.8,  0.95, 0.2,
+       0.00, 0.8,  0.25, 0.2,  0.75, 0.8,  1.00, 0.2,
        0
 };
 
@@ -556,47 +556,46 @@ struct fontinfo {
 };
 
 
-LyXFont::FONT_FAMILY const def_family = LyXFont::INHERIT_FAMILY;
-LyXFont::FONT_SERIES const def_series = LyXFont::INHERIT_SERIES;
-LyXFont::FONT_SHAPE  const def_shape  = LyXFont::INHERIT_SHAPE; 
+LyXFont::FONT_FAMILY const inh_family = LyXFont::INHERIT_FAMILY;
+LyXFont::FONT_SERIES const inh_series = LyXFont::INHERIT_SERIES;
+LyXFont::FONT_SHAPE  const inh_shape  = LyXFont::INHERIT_SHAPE; 
 
 
 
 fontinfo fontinfos[] = {
-       {"cmex",   LyXFont::CMEX_FAMILY, def_series, def_shape, LColor::math},
-       {"cmm",    LyXFont::CMM_FAMILY, def_series, def_shape, LColor::math},
-       {"cmr",    LyXFont::CMR_FAMILY, def_series, def_shape, LColor::math},
-       {"cmsy",   LyXFont::CMSY_FAMILY, def_series, def_shape, LColor::math},
-       {"eufrak", LyXFont::EUFRAK_FAMILY, def_series, def_shape, LColor::math},
-       {"mathbf", def_family, LyXFont::BOLD_SERIES, def_shape, LColor::math},
-       {"mathcal",LyXFont::CMSY_FAMILY, def_series, def_shape, LColor::math},
-       {"mathfrak", LyXFont::EUFRAK_FAMILY, def_series, def_shape, LColor::math},
-       {"mathnormal", def_family,def_series, LyXFont::UP_SHAPE, LColor::math},
-       {"mathrm", LyXFont::ROMAN_FAMILY, def_series, def_shape, LColor::math},
-       {"mathsf", LyXFont::SANS_FAMILY, def_series, def_shape, LColor::math},
-       {"msa",    LyXFont::MSA_FAMILY, def_series, def_shape, LColor::math},
-       {"msb",    LyXFont::MSB_FAMILY, def_series, def_shape, LColor::math},
-       {"textbf", def_family, LyXFont::BOLD_SERIES, def_shape, LColor::black},
-       {"textit", def_family, def_series, LyXFont::ITALIC_SHAPE, LColor::black},
-       {"textmd", def_family, LyXFont::MEDIUM_SERIES, def_shape, LColor::black},
-       {"textnormal", def_family, def_series, LyXFont::UP_SHAPE, LColor::black},
-       {"textrm", LyXFont::ROMAN_FAMILY, def_series,LyXFont::UP_SHAPE,LColor::black},
-       {"textsc", def_family, def_series, LyXFont::SMALLCAPS_SHAPE, LColor::black},
-       {"textsf", LyXFont::SANS_FAMILY, def_series, def_shape, LColor::black},
-       {"textsl", def_family, def_series, LyXFont::SLANTED_SHAPE, LColor::black},
-       {"texttt", LyXFont::TYPEWRITER_FAMILY, def_series, def_shape, LColor::black},
-       {"textup", def_family, def_series, LyXFont::UP_SHAPE, LColor::black},
-
-       {"lyxtex", def_family, def_series, def_shape, LColor::latex},
-       {"lyxsymbol", LyXFont::SYMBOL_FAMILY, def_series, def_shape, LColor::math},
+       {"cmex",   LyXFont::CMEX_FAMILY, inh_series, inh_shape, LColor::math},
+       {"cmm",    LyXFont::CMM_FAMILY, inh_series, inh_shape, LColor::math},
+       {"cmr",    LyXFont::CMR_FAMILY, inh_series, inh_shape, LColor::math},
+       {"cmsy",   LyXFont::CMSY_FAMILY, inh_series, inh_shape, LColor::math},
+       {"eufrak", LyXFont::EUFRAK_FAMILY, inh_series, inh_shape, LColor::math},
+       {"mathbf", inh_family, LyXFont::BOLD_SERIES, inh_shape, LColor::math},
+       {"mathcal",LyXFont::CMSY_FAMILY, inh_series, inh_shape, LColor::math},
+       {"mathfrak", LyXFont::EUFRAK_FAMILY, inh_series, inh_shape, LColor::math},
+       {"mathnormal", inh_family,inh_series, LyXFont::UP_SHAPE, LColor::math},
+       {"mathrm", LyXFont::ROMAN_FAMILY, inh_series, inh_shape, LColor::math},
+       {"mathsf", LyXFont::SANS_FAMILY, inh_series, inh_shape, LColor::math},
+       {"msa",    LyXFont::MSA_FAMILY, inh_series, inh_shape, LColor::math},
+       {"msb",    LyXFont::MSB_FAMILY, inh_series, inh_shape, LColor::math},
+       {"textbf", inh_family, LyXFont::BOLD_SERIES, inh_shape, LColor::black},
+       {"textit", inh_family, inh_series, LyXFont::ITALIC_SHAPE, LColor::black},
+       {"textmd", inh_family, LyXFont::MEDIUM_SERIES, inh_shape, LColor::black},
+       {"textnormal", inh_family, inh_series, LyXFont::UP_SHAPE, LColor::black},
+       {"textrm", LyXFont::ROMAN_FAMILY, inh_series,LyXFont::UP_SHAPE,LColor::black},
+       {"textsc", inh_family, inh_series, LyXFont::SMALLCAPS_SHAPE, LColor::black},
+       {"textsf", LyXFont::SANS_FAMILY, inh_series, inh_shape, LColor::black},
+       {"textsl", inh_family, inh_series, LyXFont::SLANTED_SHAPE, LColor::black},
+       {"texttt", LyXFont::TYPEWRITER_FAMILY, inh_series, inh_shape, LColor::black},
+       {"textup", inh_family, inh_series, LyXFont::UP_SHAPE, LColor::black},
+
+       {"lyxtex", inh_family, inh_series, inh_shape, LColor::latex},
+       {"lyxsymbol", LyXFont::SYMBOL_FAMILY, inh_series, inh_shape, LColor::math},
        {"lyxboldsymbol",
-               LyXFont::SYMBOL_FAMILY, LyXFont::BOLD_SERIES, def_shape, LColor::math},
+               LyXFont::SYMBOL_FAMILY, LyXFont::BOLD_SERIES, inh_shape, LColor::math},
        {"lyxitsymbol", LyXFont::SYMBOL_FAMILY,
-               def_series, LyXFont::ITALIC_SHAPE, LColor::math},
-       {"lyxredtext", LyXFont::ROMAN_FAMILY,
-               LyXFont::MEDIUM_SERIES, LyXFont::UP_SHAPE, LColor::red},
+               inh_series, LyXFont::ITALIC_SHAPE, LColor::math},
        {"lyxblacktext", LyXFont::ROMAN_FAMILY,
                LyXFont::MEDIUM_SERIES, LyXFont::UP_SHAPE, LColor::black},
+       {"lyxnochange", inh_family, inh_series, inh_shape, LColor::black},
 
        {"lyxfakebb", LyXFont::TYPEWRITER_FAMILY, LyXFont::BOLD_SERIES,
                LyXFont::UP_SHAPE, LColor::math},
@@ -655,11 +654,11 @@ void augmentFont(LyXFont & font, string const & name)
                        fakeFont("mathcal", "lyxfakecal");
        }
        fontinfo * info = searchFont(name);
-       if (info->family_ != def_family)
+       if (info->family_ != inh_family)
                font.setFamily(info->family_);
-       if (info->series_ != def_series)
+       if (info->series_ != inh_series)
                font.setSeries(info->series_);
-       if (info->shape_ != def_shape)
+       if (info->shape_ != inh_shape)
                font.setShape(info->shape_);
        if (info->color_ != LColor::none)
                font.setColor(info->color_);
index 55018fb50d9f59d5b1e59bb609e07fa3cf5ea77e..f5cdf86f29a561aacf05ce9368bb53a3227ea89e 100644 (file)
@@ -128,5 +128,6 @@ grfx::ImagePtr preview(string const & str)
 
        return im;
 #endif
+       return it->second;      
 }