]> git.lyx.org Git - features.git/commitdiff
fixes for \xxalignat and old style font changes
authorAndré Pönitz <poenitz@gmx.net>
Wed, 17 Jul 2002 10:25:33 +0000 (10:25 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 17 Jul 2002 10:25:33 +0000 (10:25 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4673 a592a061-630c-0410-9148-cb99ea01b6c8

18 files changed:
src/mathed/Makefile.am
src/mathed/formulabase.C
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_decorationinset.C
src/mathed/math_decorationinset.h
src/mathed/math_dotsinset.C
src/mathed/math_dotsinset.h
src/mathed/math_factory.C
src/mathed/math_fontinset.C
src/mathed/math_fontinset.h
src/mathed/math_fontoldinset.C [new file with mode: 0644]
src/mathed/math_fontoldinset.h [new file with mode: 0644]
src/mathed/math_hullinset.C
src/mathed/math_inset.h
src/mathed/math_parboxinset.C
src/mathed/math_parboxinset.h
src/mathed/math_parser.C

index cad384f547813d137f65f7832101e763309de7f2..b8ecffc96fed1b4edf2bfd49189d5d8e87ddd65d 100644 (file)
@@ -63,6 +63,8 @@ libmathed_la_SOURCES = \
        math_fboxinset.h \
        math_fontinset.C \
        math_fontinset.h \
+       math_fontoldinset.C \
+       math_fontoldinset.h \
        math_fracinset.C \
        math_fracinset.h \
        math_fracbase.C \
index 345669b82867a87db2ebb8925787263d6567e8a5..f1f6c90ff7283c36ba6b9e3c234f3f9ca5d8e492 100644 (file)
@@ -40,7 +40,9 @@
 #include "Lsstream.h"
 #include "math_arrayinset.h"
 #include "math_charinset.h"
+#include "math_deliminset.h"
 #include "math_cursor.h"
+#include "math_factory.h"
 #include "math_fontinset.h"
 #include "math_hullinset.h"
 #include "math_iterator.h"
@@ -127,7 +129,7 @@ void InsetFormulaBase::handleFont
        bool sel = mathcursor->selection();
        if (sel)
                updateLocal(bv, true);
-       mathcursor->handleNest(new MathFontInset(font));
+       mathcursor->handleNest(createMathInset(font));
        mathcursor->insert(arg);
        if (!sel)
                updateLocal(bv, false);
@@ -665,7 +667,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
                        rs = ')';
 
                bv->lockedInsetStoreUndo(Undo::EDIT);
-               mathcursor->handleDelim(ls, rs);
+               mathcursor->handleNest(MathAtom(new MathDelimInset(ls, rs)));
                updateLocal(bv, true);
                break;
        }
index e8c887262dc901cd583ef733e349dd4f1ed20949..ee80f3786206f14c204c976c2a3bd773415dadae 100644 (file)
@@ -35,7 +35,6 @@
 #include "math_boxinset.h"
 #include "math_casesinset.h"
 #include "math_charinset.h"
-#include "math_deliminset.h"
 #include "math_extern.h"
 #include "math_factory.h"
 #include "math_fboxinset.h"
@@ -703,16 +702,10 @@ void MathCursor::drawSelection(MathPainterInfo & pain) const
 }
 
 
-void MathCursor::handleDelim(string const & l, string const & r)
+void MathCursor::handleNest(MathAtom const & at)
 {
-       handleNest(new MathDelimInset(l, r));
-}
-
-
-void MathCursor::handleNest(MathInset * p)
-{
-       p->cell(0) = grabAndEraseSelection().glue();
-       insert(MathAtom(p)); // this invalidates p!
+       at->cell(0) = grabAndEraseSelection().glue();
+       insert(at);
        pushRight(prevAtom());
 }
 
index 96d0348085baebb5a80f0bfa5afc51de198e5ad9..d00b294273e92c3c11904a20aeca32c80071a632 100644 (file)
@@ -165,9 +165,7 @@ public:
        ///
        void drawSelection(MathPainterInfo & pain) const;
        ///
-       void handleDelim(string const & l, string const & r);
-       ///
-       void handleNest(MathInset * p);
+       void handleNest(MathAtom const & at);
        /// splits cells and shifts right part to the next cell
        void splitCell();
        /// splits line and insert new row of cell
index e6982a3fd843944935220cadce0f82171ea30c38..ab9240d0e3ec87c4b6daf84d65a760c42016efd4 100644 (file)
@@ -12,8 +12,8 @@
 #include "support/LOstream.h"
 
 
-MathDecorationInset::MathDecorationInset(string const & name)
-       : MathNestInset(1), name_(name)
+MathDecorationInset::MathDecorationInset(latexkeys const * key)
+       : MathNestInset(1), key_(key)
 {}
 
 
@@ -25,53 +25,53 @@ MathInset * MathDecorationInset::clone() const
 
 bool MathDecorationInset::upper() const
 {
-       return name_.substr(0, 5) != "under";
+       return key_->name.substr(0, 5) != "under";
 }
 
 
 bool MathDecorationInset::isScriptable() const
 {
        return
-                       name_ == "overbrace" ||
-                       name_ == "underbrace" ||
-                       name_ == "overleftarrow" ||
-                       name_ == "overrightarrow" ||
-                       name_ == "overleftrightarrow" ||
-                       name_ == "underleftarrow" ||
-                       name_ == "underrightarrow" ||
-                       name_ == "underleftrightarrow";
+                       key_->name == "overbrace" ||
+                       key_->name == "underbrace" ||
+                       key_->name == "overleftarrow" ||
+                       key_->name == "overrightarrow" ||
+                       key_->name == "overleftrightarrow" ||
+                       key_->name == "underleftarrow" ||
+                       key_->name == "underrightarrow" ||
+                       key_->name == "underleftrightarrow";
 }
 
 
 bool MathDecorationInset::protect() const
 {
        return
-                       name_ == "overbrace" ||
-                       name_ == "underbrace" ||
-                       name_ == "overleftarrow" ||
-                       name_ == "overrightarrow" ||
-                       name_ == "overleftrightarrow" ||
-                       name_ == "underleftarrow" ||
-                       name_ == "underrightarrow" ||
-                       name_ == "underleftrightarrow";
+                       key_->name == "overbrace" ||
+                       key_->name == "underbrace" ||
+                       key_->name == "overleftarrow" ||
+                       key_->name == "overrightarrow" ||
+                       key_->name == "overleftrightarrow" ||
+                       key_->name == "underleftarrow" ||
+                       key_->name == "underrightarrow" ||
+                       key_->name == "underleftrightarrow";
 }
 
 
 bool MathDecorationInset::wide() const
 {
        return
-                       name_ == "overline" ||
-                       name_ == "underline" ||
-                       name_ == "overbrace" ||
-                       name_ == "underbrace" ||
-                       name_ == "overleftarrow" ||
-                       name_ == "overrightarrow" ||
-                       name_ == "overleftrightarrow" ||
-                       name_ == "widehat" ||
-                       name_ == "widetilde" ||
-                       name_ == "underleftarrow" ||
-                       name_ == "underrightarrow" ||
-                       name_ == "underleftrightarrow";
+                       key_->name == "overline" ||
+                       key_->name == "underline" ||
+                       key_->name == "overbrace" ||
+                       key_->name == "underbrace" ||
+                       key_->name == "overleftarrow" ||
+                       key_->name == "overrightarrow" ||
+                       key_->name == "overleftrightarrow" ||
+                       key_->name == "widehat" ||
+                       key_->name == "widetilde" ||
+                       key_->name == "underleftarrow" ||
+                       key_->name == "underrightarrow" ||
+                       key_->name == "underleftrightarrow";
 }
 
 
@@ -98,9 +98,9 @@ void MathDecorationInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        xcell(0).draw(pi, x + 1, y);
        if (wide())
-               mathed_draw_deco(pi, x + 1, y + dy_, width(), dh_, name_);
+               mathed_draw_deco(pi, x + 1, y + dy_, width(), dh_, key_->name);
        else
-               mathed_draw_deco(pi, x + 1 + (width() - dw_) / 2, y + dy_, dw_, dh_, name_);
+               mathed_draw_deco(pi, x + 1 + (width() - dw_) / 2, y + dy_, dw_, dh_, key_->name);
        drawMarkers(pi, x, y);
 }
 
@@ -109,17 +109,17 @@ void MathDecorationInset::write(WriteStream & os) const
 {
        if (os.fragile() && protect())
                os << "\\protect";
-       os << '\\' << name_ << '{' << cell(0) << '}';
+       os << '\\' << key_->name << '{' << cell(0) << '}';
 }
 
 
 void MathDecorationInset::normalize(NormalStream & os) const
 {
-       os << "[deco " << name_ << ' ' <<  cell(0) << ']';
+       os << "[deco " << key_->name << ' ' <<  cell(0) << ']';
 }
 
 
 void MathDecorationInset::infoize(std::ostream & os) const
 {
-       os << "Deco: " << name_;
+       os << "Deco: " << key_->name;
 }
index e0e03650cfd0031cc475a9045112ca8b2b69dd0e..da265685f30a5b2290ffb89f1d8496c916cd6ba1 100644 (file)
     \author Alejandro Aguilar Sierra
  */
 
+class latexkeys;
+
 class MathDecorationInset : public MathNestInset {
 public:
        ///
-       explicit MathDecorationInset(string const & name);
+       explicit MathDecorationInset(latexkeys const * key);
        ///
        MathInset * clone() const;
        ///
@@ -41,7 +43,7 @@ private:
        bool wide() const;
 
        ///
-       string const name_;
+       latexkeys const * key_;
        /// height cache of deco
        mutable int dh_;
        /// vertical offset cache of deco
index da83db317882a5a5c41fcf0583c871d299a08db0..83363d8bb03e0ab096a49eb8f8fd8f6cec8bfb6c 100644 (file)
@@ -8,10 +8,11 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 #include "math_support.h"
+#include "math_parser.h"
 
 
-MathDotsInset::MathDotsInset(string const & name)
-       : name_(name)
+MathDotsInset::MathDotsInset(latexkeys const * key)
+       : key_(key)
 {}
 
 
@@ -24,38 +25,38 @@ MathInset * MathDotsInset::clone() const
 void MathDotsInset::metrics(MathMetricsInfo & mi) const
 {
        mathed_char_dim(mi.base.font, 'M', dim_);
-       if (name_ == "ldots" || name_ == "dotsm") 
+       if (key_->name == "ldots" || key_->name == "dotsm") 
                dh_ = 0;
-       else if (name_ == "cdots" || name_ == "dotsb"
-                       || name_ == "dotsm" || name_ == "dotsi")
+       else if (key_->name == "cdots" || key_->name == "dotsb"
+                       || key_->name == "dotsm" || key_->name == "dotsi")
                dh_ = ascent() / 2;
-       else if (name_ == "dotsc")
+       else if (key_->name == "dotsc")
                dh_ = ascent() / 4;
-       else if (name_ == "vdots")
+       else if (key_->name == "vdots")
                dim_.w /= 2;
-       else if (name_ == "ddots")
+       else if (key_->name == "ddots")
                dh_ = ascent();
 }
 
 
 void MathDotsInset::draw(MathPainterInfo & pain, int x, int y) const
 {
-       mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), name_);
-       if (name_ == "vdots" || name_ == "ddots")
+       mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), key_->name);
+       if (key_->name == "vdots" || key_->name == "ddots")
                ++x;
-       if (name_ != "vdots")
+       if (key_->name != "vdots")
                --y;
-       mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), name_);
+       mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), key_->name);
 }
 
 
 void MathDotsInset::write(WriteStream & os) const
 {
-       os << '\\' << name_ << ' ';
+       os << '\\' << key_->name << ' ';
 }
 
 
 void MathDotsInset::normalize(NormalStream & os) const
 {
-       os << "[" << name_ << "] ";
+       os << "[" << key_->name << "] ";
 }
index be37fb641bbd7bb3d31095262a4cc9e01fad3f55..d0187a0804e32ae49e0a239f600eee600d26c6d7 100644 (file)
@@ -3,17 +3,18 @@
 #define MATH_DOTSINSET_H
 
 #include "math_diminset.h"
-#include "LString.h"
 
 #ifdef __GNUG__
 #pragma interface
 #endif
 
+class latexkeys;
+
 /// The different kinds of ellipsis
 class MathDotsInset : public MathDimInset {
 public:
        ///
-       explicit MathDotsInset(string const &);
+       explicit MathDotsInset(latexkeys const * l);
        ///
        MathInset * clone() const;
        ///
@@ -28,6 +29,6 @@ protected:
        /// cache for the thing's heigth
        mutable int dh_;
        ///
-       string const name_;
+       latexkeys const * key_;
 };
 #endif
index 18c2bd90bb0fff44dfde6efe38a8d2c0c3d86ee6..f328ed3a5709b994b19e29a79d3d06c3f47c1977 100644 (file)
@@ -10,6 +10,7 @@
 #include "math_dotsinset.h"
 #include "math_fboxinset.h"
 #include "math_fontinset.h"
+#include "math_fontoldinset.h"
 #include "math_fracinset.h"
 #include "math_kerninset.h"
 #include "math_lefteqninset.h"
@@ -222,11 +223,11 @@ MathAtom createMathInset(string const & s)
                if (inset == "underset")
                        return MathAtom(new MathUndersetInset);
                if (inset == "decoration")
-                       return MathAtom(new MathDecorationInset(l->name));
+                       return MathAtom(new MathDecorationInset(l));
                if (inset == "space")
                        return MathAtom(new MathSpaceInset(l->name));
                if (inset == "dots")
-                       return MathAtom(new MathDotsInset(l->name));
+                       return MathAtom(new MathDotsInset(l));
                if (inset == "mbox")
                        return MathAtom(new MathBoxInset(l->name));
                if (inset == "parbox")
@@ -236,9 +237,9 @@ MathAtom createMathInset(string const & s)
                if (inset == "style")
                        return MathAtom(new MathSizeInset(l));
                if (inset == "font")
-                       return MathAtom(new MathFontInset(l->name));
+                       return MathAtom(new MathFontInset(l));
                if (inset == "oldfont")
-                       return MathAtom(new MathFontInset(l->name));
+                       return MathAtom(new MathFontOldInset(l));
                if (inset == "matrix")
                        return MathAtom(new MathAMSArrayInset(s));
                return MathAtom(new MathSymbolInset(l));
index ceb1143760ef19cd552916032ef0121073909c32..9b1536ac91d7848d7da0de2efd63eb3c3a57f870 100644 (file)
@@ -9,14 +9,15 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 #include "math_support.h"
+#include "math_parser.h"
 #include "LaTeXFeatures.h"
 #include "textpainter.h"
 #include "frontends/Painter.h"
 
 
 
-MathFontInset::MathFontInset(string const & name)
-       : MathNestInset(1), name_(name)
+MathFontInset::MathFontInset(latexkeys const * key)
+       : MathNestInset(1), key_(key)
 {
        //lock(true);
 }
@@ -30,7 +31,7 @@ MathInset * MathFontInset::clone() const
 
 void MathFontInset::metrics(MathMetricsInfo & mi) const
 {
-       MathFontSetChanger dummy(mi.base, name_.c_str());
+       MathFontSetChanger dummy(mi.base, key_->name.c_str());
        dim_ = xcell(0).metrics(mi);
        metricsMarkers();
 }
@@ -40,7 +41,7 @@ void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        //lyxerr << "MathFontInset::draw\n";
        //MathNestInset::draw(pi, x, y);
-       MathFontSetChanger dummy(pi.base, name_.c_str());
+       MathFontSetChanger dummy(pi.base, key_->name.c_str());
        xcell(0).draw(pi, x + 1, y);
        drawMarkers(pi, x, y);
 }
@@ -61,13 +62,13 @@ void MathFontInset::drawT(TextPainter & pain, int x, int y) const
 
 void MathFontInset::write(WriteStream & os) const
 {
-       os << '\\' << name_ << '{' << cell(0) << '}';
+       os << '\\' << key_->name << '{' << cell(0) << '}';
 }
 
 
 void MathFontInset::normalize(NormalStream & os) const
 {
-       os << "[font_ " << name_ << " " << cell(0) << "]";
+       os << "[font " << key_->name << " " << cell(0) << "]";
 }
 
 
@@ -75,12 +76,12 @@ void MathFontInset::validate(LaTeXFeatures & features) const
 {
        // Make sure amssymb is put in preamble if Blackboard Bold or
        // Fraktur used:
-       if (name_ == "mathfrak" || name_ == "mathbb")
+       if (key_->name == "mathfrak" || key_->name == "mathbb")
                features.require("amssymb");
 }
 
 
 void MathFontInset::infoize(std::ostream & os) const
 {
-       os << "Font: " << name_;
+       os << "Font: " << key_->name;
 }
index a07f2ad02eaf2b7168e393f6b0ed2830d19485cc..5b0dfdd427309a5863af0280e24e45ddf77d6ca9 100644 (file)
@@ -3,21 +3,21 @@
 #define MATH_FONTINSET_H
 
 #include "math_nestinset.h"
-#include "LString.h"
-#include "lyxfont.h"
 
 #ifdef __GNUG__
 #pragma interface
 #endif
 
-/** The base character inset.
+/** Inset for font changes
     \author André Pönitz
  */
 
+class latexkeys;
+
 class MathFontInset : public MathNestInset {
 public:
        ///
-       explicit MathFontInset(string const & name);
+       explicit MathFontInset(latexkeys const * key);
        ///
        MathInset * clone() const;
        ///
@@ -32,8 +32,6 @@ public:
        void write(WriteStream & os) const;
        ///
        void normalize(NormalStream &) const;
-       /// identifies Fontinsets
-       MathFontInset const * asFontInset() const { return this; }
        ///
        void validate(LaTeXFeatures & features) const;
        ///
@@ -41,6 +39,6 @@ public:
 
 private:
        /// the font to be used on screen
-       string name_;
+       latexkeys const * key_;
 };
 #endif
diff --git a/src/mathed/math_fontoldinset.C b/src/mathed/math_fontoldinset.C
new file mode 100644 (file)
index 0000000..aa37571
--- /dev/null
@@ -0,0 +1,73 @@
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_fontoldinset.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+#include "math_support.h"
+#include "math_parser.h"
+#include "textpainter.h"
+#include "frontends/Painter.h"
+
+
+
+MathFontOldInset::MathFontOldInset(latexkeys const * key)
+       : MathNestInset(1), key_(key)
+{
+       //lock(true);
+}
+
+
+MathInset * MathFontOldInset::clone() const
+{
+       return new MathFontOldInset(*this);
+}
+
+
+void MathFontOldInset::metrics(MathMetricsInfo & mi) const
+{
+       MathFontSetChanger dummy(mi.base, key_->name.c_str());
+       dim_ = xcell(0).metrics(mi);
+       metricsMarkers();
+}
+
+
+void MathFontOldInset::draw(MathPainterInfo & pi, int x, int y) const
+{
+       MathFontSetChanger dummy(pi.base, key_->name.c_str());
+       xcell(0).draw(pi, x + 1, y);
+       drawMarkers(pi, x, y);
+}
+
+
+void MathFontOldInset::metricsT(TextMetricsInfo const & mi) const
+{
+       dim_ = xcell(0).metricsT(mi);
+}
+
+
+void MathFontOldInset::drawT(TextPainter & pain, int x, int y) const
+{
+       xcell(0).drawT(pain, x, y);
+}
+
+
+void MathFontOldInset::write(WriteStream & os) const
+{
+       os << "{\\" << key_->name << ' ' << cell(0) << '}';
+}
+
+
+void MathFontOldInset::normalize(NormalStream & os) const
+{
+       os << "[font " << key_->name << " " << cell(0) << "]";
+}
+
+
+void MathFontOldInset::infoize(std::ostream & os) const
+{
+       os << "Font: " << key_->name;
+}
diff --git a/src/mathed/math_fontoldinset.h b/src/mathed/math_fontoldinset.h
new file mode 100644 (file)
index 0000000..14a42cc
--- /dev/null
@@ -0,0 +1,44 @@
+// -*- C++ -*-
+#ifndef MATH_FONTOLDINSET_H
+#define MATH_FONTOLDINSET_H
+
+#include "math_nestinset.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+/** Old-style font changes
+    \author André Pönitz
+ */
+
+class latexkeys;
+
+class MathFontOldInset : public MathNestInset {
+public:
+       ///
+       explicit MathFontOldInset(latexkeys const * key);
+       ///
+       MathInset * clone() const;
+       /// we write extra braces in any case...
+       bool extraBraces() const { return true; }
+       ///
+       void metrics(MathMetricsInfo & mi) const;
+       ///
+       void draw(MathPainterInfo & pi, int x, int y) const;
+       ///
+       void metricsT(TextMetricsInfo const & mi) const;
+       ///
+       void drawT(TextPainter & pi, int x, int y) const;
+       ///
+       void write(WriteStream & os) const;
+       ///
+       void normalize(NormalStream &) const;
+       ///
+       void infoize(std::ostream & os) const;
+
+private:
+       /// the font to be used on screen
+       latexkeys const * key_;
+};
+#endif
index 63fb2495c2344a72b986f3d4afe7b3b9caa656b2..b51cc4760df52a44486d50266e7c1dd6ac3f7908 100644 (file)
@@ -352,11 +352,11 @@ void MathHullInset::header_write(WriteStream & os) const
        else if (type_ == "eqnarray" || type_ == "align")
                        os << "\\begin{" << type_ << star(n) << "}\n";
 
-       else if (type_ == "alignat" || type_ == "xalignat" || type_ == "xxalignat"
+       else if (type_ == "alignat" || type_ == "xalignat") 
                os << "\\begin{" << type_ << star(n) << "}"
                  << "{" << static_cast<unsigned int>(ncols()/2) << "}\n";
 
-       else if (type_ == "multline" || type_ == "gather") 
+       else if (type_ == "xxalignat" || type_ == "multline" || type_ == "gather") 
                os << "\\begin{" << type_ << "}\n";
 
        else 
index 5becf7ed11f9559f6f8597d72a46c58e9943dd04..3805e7c189d9036991974ddf49db8f9a14ffaf19 100644 (file)
@@ -53,7 +53,6 @@ class MathBoxInset;
 class MathCharInset;
 class MathDelimInset;
 class MathFboxInset;
-class MathFontInset;
 class MathGridInset;
 class MathFracInset;
 class MathHullInset;
@@ -203,7 +202,6 @@ public:
        virtual MathDelimInset         * asDelimInset()         { return 0; }
        virtual MathDelimInset const   * asDelimInset() const   { return 0; }
        virtual MathFboxInset          * asFboxInset()          { return 0; }
-       virtual MathFontInset const    * asFontInset() const    { return 0; }
        virtual MathFracInset          * asFracInset()          { return 0; }
        virtual MathGridInset          * asGridInset()          { return 0; }
        virtual MathHullInset          * asHullInset()          { return 0; }
index 60b748c19d7f7da98293b87ae984a6397c1bbd22..9e90e7e1897f621da12de4e6ed1e3d37d586e7cd 100644 (file)
@@ -34,16 +34,22 @@ void MathParboxInset::setWidth(string const & w)
 }
 
 
+int MathParboxInset::pos2row(pos_type pos) const
+{
+       for (int r = 0, n = rows_.size(); r < n; ++r) 
+               if (pos >= rows_[r].begin && pos < rows_[r].end)
+                       return r;
+       lyxerr << "illegal row for pos " << pos << "\n";
+       return 0;
+}
+
+
 void MathParboxInset::getPos(idx_type idx, pos_type pos, int & x, int & y) const
 {
-       for (int r = 0, n = rows_.size(); r < n; ++r) {
-               if (pos >= rows_[r].begin && pos < rows_[r].end) {
-                       //lyxerr << "found cursor at pos " << pos << " in row " << r << "\n";
-                       x = cells_[0].xo() + cells_[0].pos2x(rows_[r].begin, pos, rows_[r].glue);
-                       y = cells_[0].yo() + rows_[r].yo;
-                       break;
-               }
-       }
+       int const r = pos2row(pos);
+       //lyxerr << "found cursor at pos " << pos << " in row " << r << "\n";
+       x = cells_[0].xo() + cells_[0].pos2x(rows_[r].begin, pos, rows_[r].glue);
+       y = cells_[0].yo() + rows_[r].yo;
        // move cursor visually into empty cells ("blue rectangles");
        if (cell(0).empty())
                x += 2;
index f7305478cd21d924fc4352a967611be0ae35e449..389fe158b0bdca4359354273b961603d87d09a53 100644 (file)
@@ -26,6 +26,8 @@ public:
        ///
        void setPosition(string const & pos);
 private:
+       /// row corresponding to given position 
+       int pos2row(pos_type pos) const;
        /// width on screen
        int lyx_width_;
        /// width for TeX
index dc44e7a90e88befa0117e17bd77a8bd2df7490b8..0e1e94e335e1ace32b79c1bdd9dbd43911a2f622 100644 (file)
@@ -1026,12 +1026,8 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
                        latexkeys const * l = in_word_set(t.cs());
                        if (l) {
                                if (l->inset == "font") {
-                                       lyxerr << "starting font " << t.cs() << "\n";
-                                       MathAtom p = createMathInset(t.cs());
-                                       bool textmode = (t.cs()[0] == 't');
-                                       parse(p->cell(0), FLAG_ITEM, !textmode);
-                                       cell->push_back(p);
-                                       //lyxerr << "ending font\n";
+                                       cell->push_back(createMathInset(t.cs()));
+                                       parse(cell->back()->cell(0), FLAG_ITEM, l->extra == "mathmode");
                                }
 
                                else if (l->inset == "oldfont") {