]> git.lyx.org Git - features.git/commitdiff
prepare re-enabling LaTeX feature validation
authorAndré Pönitz <poenitz@gmx.net>
Fri, 13 Jul 2001 14:54:56 +0000 (14:54 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 13 Jul 2001 14:54:56 +0000 (14:54 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2240 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
src/mathed/array.C
src/mathed/array.h
src/mathed/formula.C
src/mathed/formulabase.C
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_macro.C
src/mathed/math_macro.h
src/mathed/math_matrixinset.C
src/mathed/math_matrixinset.h

index 4197abf417813238c631902e55af4f5645ad3b33..3a663915d0684910b532239b27415154866966dc 100644 (file)
@@ -339,3 +339,11 @@ void MathArray::WriteNormal(ostream & os) const
        Write(os, true);
 }
 
+
+void MathArray::Validate(LaTeXFeatures & features) const
+{
+       for (int pos = 0; pos < size(); next(pos)) 
+               if (isInset(pos)) 
+                       nextInset(pos)->Validate(features);
+}
+
index 5e17de0685bd39ad8f620537c85f112751011968..631b0314a56f1fedfdff90a18b799973fca0e5bd 100644 (file)
@@ -26,6 +26,7 @@
 class MathInset;
 class MathMacro;
 class Painter;
+class LaTeXFeatures;
 
 #ifdef __GNUG__
 #pragma interface
@@ -116,6 +117,8 @@ public:
        void Write(std::ostream &, bool) const;
        ///
        void WriteNormal(std::ostream &) const;
+       ///
+       void Validate(LaTeXFeatures &) const;
 private:
        ///
        typedef std::vector<unsigned char>           buffer_type;
index abd83ef8620aea146a753e9b07d8ecfe611e2ab6..27202d0eaee92a17a0542db05f36ac83e9c078a1 100644 (file)
@@ -123,6 +123,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &,
 {
        int x = int(xx) - 1;
        y -= 2;
+
        MathInset::workwidth = bv->workWidth();
        Painter & pain = bv->painter();
 
@@ -130,22 +131,20 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &,
        int w = par()->width();
        int h = par()->height();
        int a = par()->ascent();
-       pain.fillRectangle(int(x), y - a, w, h, LColor::mathbg);
-
-       if (mathcursor) {
-               if (mathcursor->formula() == this) {
-                       if (mathcursor->Selection()) {
-                               int xp[10];
-                               int yp[10];
-                               int n;
-                               mathcursor->SelGetArea(xp, yp, n);
-                               pain.fillPolygon(xp, yp, n, LColor::selection);
-                       }
-                       pain.rectangle(int(x), y - a, w, h, LColor::mathframe);
+       pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
+
+       if (mathcursor && mathcursor->formula() == this) {
+               if (mathcursor->Selection()) {
+                       int xp[10];
+                       int yp[10];
+                       int n;
+                       mathcursor->SelGetArea(xp, yp, n);
+                       pain.fillPolygon(xp, yp, n, LColor::selection);
                }
+               pain.rectangle(x, y - a, w, h, LColor::mathframe);
        }
 
-       par()->draw(pain, int(x), y);
+       par()->draw(pain, x, y);
        xx += par()->width();
 
        setCursorVisible(false);
index 49db390786cbc6aafa54276a34eb1e08371daeaf..be33157899905962d0174a8ebd0c7d10274b1d7b 100644 (file)
@@ -573,14 +573,14 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
                break;
 
        case LFUN_BACKSPACE:
-               if (!mathcursor->InMacroMode() && mathcursor->pos() == 0) {
+               // if (!mathcursor->InMacroMode() && mathcursor->pos() == 0)
+               if (mathcursor->pos() == 0) {
                        bv->lockedInsetStoreUndo(Undo::DELETE);
                        mathcursor->pullArg();
                        bv->updateInset(this, true);
                        break;
                }
-               if (!mathcursor->Left())
-                       break;
+               mathcursor->plainLeft();
                // fall through...
 
        case LFUN_DELETE:
index 7b1f7d91c5ddcb2a3365033ea9123122cb0447b6..0f9790e62bcb019a0982f68a54bccd0285043b90 100644 (file)
@@ -153,6 +153,11 @@ bool MathCursor::isInside(MathInset * p) const
 }
 
 
+bool MathCursor::plainLeft()
+{
+       return array().prev(cursor_);
+}
+
 bool MathCursor::Left(bool sel)
 {
        dump("Left 1");
@@ -165,8 +170,8 @@ bool MathCursor::Left(bool sel)
                        MacroModeClose();
                return true;
        }
-       clearLastCode();
        SelHandle(sel);
+       clearLastCode();
 
        bool result = false;
 
@@ -214,9 +219,8 @@ bool MathCursor::Right(bool sel)
                MacroModeClose();
                return true;
        }
-
-       clearLastCode();
        SelHandle(sel);
+       clearLastCode();
 
        bool result = false;
 
@@ -322,9 +326,8 @@ void MathCursor::Home()
        if (macro_mode)
                MacroModeClose();
        clearLastCode();
-       if (!par_->idxHome(idx_, cursor_)) {
+       if (!par_->idxHome(idx_, cursor_)) 
                pop();
-       }
        dump("Home 2");
 }
 
index 7981662233cad60d96543b4d95d6e77575a9cc44..e47807aefe1ca438d6f8d9fc4c9a6ed054ea1cf0 100644 (file)
@@ -56,6 +56,8 @@ public:
        /// Put the cursor in the last position
        void last();
        ///
+       bool plainLeft();
+       ///
        bool plainRight();
        ///
        void Delete();
index e39af4dc2a2bde97fc4886938112080998ff0869..7a0f9cece9cd5cbc756e62a5f212400a99001a1b 100644 (file)
@@ -357,3 +357,9 @@ bool MathInset::covers(int x, int y) const
                y >= yo_ - ascent_ &&
                y <= yo_ + descent_;
 }
+
+void MathInset::Validate(LaTeXFeatures & features) const
+{
+       for (int i = 0; i < nargs(); ++i)
+               cell(i).Validate(features);
+}
index bd1917c040ac37068032ba2bb4f2582e49112d7c..3075ca10baaf90afa48bcfd73c84aebfd188b36d 100644 (file)
@@ -39,6 +39,8 @@
 */
 
 
+class LaTeXFeatures;
+
 class MathInset {
 public: 
        /** A math inset has a name (usually its LaTeX name),
@@ -187,6 +189,8 @@ public:
        void dump() const;
 
        ///
+       void Validate(LaTeXFeatures & features) const;
+
        ///
        static int workwidth;
 protected:
index 01ce91fc4b2b66bcd406ec128e322a10303a61bb..5085e783bf864957aff6bea102d2e7df514b0865 100644 (file)
@@ -28,6 +28,7 @@
 #include "math_macrotable.h"
 #include "math_macrotemplate.h"
 #include "Painter.h"
+#include "LaTeXFeatures.h"
 
 using std::endl;
 
@@ -183,3 +184,11 @@ bool MathMacro::idxRight(int &, int &) const
 {
        return false;
 }
+
+
+void MathMacro::Validate(LaTeXFeatures & features) const
+{
+       if (name_ == "binom")
+               features.binom = true;
+       MathInset::Validate(features);
+}
index 24775e01632f7ae033bc508f9b8d616dc048dcc8..f40f3df82905160247fc2608802b40bd47af02ed 100644 (file)
@@ -62,6 +62,9 @@ public:
        ///
        bool idxRight(int &, int &) const;
 
+       ///
+       void Validate(LaTeXFeatures &) const;
+
 private:
        ///
        MathMacroTemplate const * const tmplate_;
index c3267d029470c0f093980ad6addfe4c875fb4a42..a7341f7d51f0d8972d8bb70e4ca9dd46ff0cab32 100644 (file)
@@ -221,7 +221,7 @@ bool MathMatrixInset::numberedType() const
 }
 
 
-void MathMatrixInset::Validate(LaTeXFeatures & features)
+void MathMatrixInset::Validate(LaTeXFeatures & features) const
 {
        features.amsstyle = ams();
 
@@ -230,40 +230,11 @@ void MathMatrixInset::Validate(LaTeXFeatures & features)
        //if (features.amsstyle)
        //  return;
 
-       //Validate1(features);
-
        features.boldsymbol = true;
-       features.binom      = true;
-}
+       //features.binom      = true;
 
-/*
-void MathMatrixInset::Validate1(LaTeXFeatures & features)
-{
-       MathIter it(cell());
-
-       while (it.OK() && !(features.binom && features.boldsymbol)) {
-               MathInset * p = it.nextInset();
-               if (p) {
-                       p = it.GetActiveInset();
-                       if (p) {
-                               if (!features.binom && p->GetType() == LM_OT_MACRO &&
-                                   p->name() == "binom") {
-                                       features.binom = true;
-                               } else {
-                                       for (int i = 0; i <= p->getMaxArgumentIdx(); ++i) {
-                                               p->setArgumentIdx(i);
-                                               Validate1(features, p);
-                                       }
-                               }
-                       } else {
-                               if (!features.boldsymbol && p->name() == "boldsymbol") 
-                                       features.boldsymbol = true;
-                       }
-               }
-               it.Next();
-       }
+       MathInset::Validate(features);
 }
-*/
 
 
 void MathMatrixInset::header_write(std::ostream & os) const
index 379555763f4904ab397acc1caa59ac7076bdfbb4..c2daa85dadcb14a69ede5dc7110de79f45602375 100644 (file)
@@ -49,7 +49,7 @@ public:
        ///
        std::vector<string> const getLabelList() const;
        ///
-       void Validate(LaTeXFeatures & features);
+       void Validate(LaTeXFeatures & features) const;
 
        ///
        void addRow(int);