]> git.lyx.org Git - features.git/commitdiff
revert mathed58.diff
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 15 Mar 2001 14:41:40 +0000 (14:41 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 15 Mar 2001 14:41:40 +0000 (14:41 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1772 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_parser.C
src/mathed/math_rowst.h

index 698215e802b07f451419cc6c7f7e3c3d80c91455..68bc7bff671f4d52d47864d46814896006b1f2df 100644 (file)
@@ -424,6 +424,9 @@ void mathed_parse(MathedArray & array, unsigned flags = 0,
        int acc_brace = 0;
        int acc_braces[8];
        MathParInset * mt = (mtx) ? *mtx : 0;
+       MathedRowContainer::iterator crow;
+       if (mt)
+               crow = mt->getRowSt().begin();
 
        ++plevel;
        MathedIter data(&array);
@@ -601,7 +604,8 @@ void mathed_parse(MathedArray & array, unsigned flags = 0,
                case LM_TK_NEWLINE:
                        if (mt && (flags & FLAG_END)) {
                                if (mt->Permit(LMPF_ALLOW_CR)) {
-                                       mt->getRowSt().push_back();
+                                       mt->getRowSt().insert(crow);
+                                       ++crow;
                                        data.insert('K', LM_TC_CR);
                                } else 
                                        mathPrintError("Unexpected newline");
@@ -753,11 +757,8 @@ void mathed_parse(MathedArray & array, unsigned flags = 0,
                        break;
                        
                case LM_TK_NONUM:
-                       if (mt) {
-                               if (!mt->getRowSt().data_.size())
-                                       mt->getRowSt().push_back();
-                               mt->getRowSt().back().setNumbered(false);
-                       }
+                       if (crow)
+                               crow->setNumbered(false);
                        break;
                
                case LM_TK_PMOD:
@@ -868,6 +869,7 @@ void mathed_parse(MathedArray & array, unsigned flags = 0,
                                        }
                                        mt->SetStyle(size);
                                        mt->SetType(mathed_env);
+                                       crow = mt->getRowSt().begin();
                                }
                                
                                lyxerr[Debug::MATHED] << "MATH BEGIN[" << mathed_env << "]" << endl;
@@ -912,8 +914,8 @@ void mathed_parse(MathedArray & array, unsigned flags = 0,
                                panic = true;
                                break;
                        } 
-                       if (mt) {
-                               mt->getRowSt().back().setLabel(yytext.data());
+                       if (crow) {
+                               crow->setLabel(yytext.data());
                        } else {
                                mathed_label = yytext.data();
                        }
index b4f1c3432cb23dcc2c88f58a7e7256ba049af205..16a265a7790d93e8b018a77f5a057f024a9fe059 100644 (file)
@@ -44,8 +44,10 @@ public:
        void setNumbered(bool nf);
        ///
        void setTab(unsigned int i, int t);
+       ///
+       friend class MathedRowSt;
 protected:
-       /// verticals 
+       /// Vericals 
        int asc_;
        ///
        int desc_;
@@ -61,9 +63,12 @@ protected:
 
 
  
-class MathedRowContainer {
-private:
-       ///
+// The idea is to change this  MathedRowContainer  to mimic the behaviour
+// of std::list<MathedRowStruct> in several small steps.  In the end it
+// could be replaced by such a list and MathedRowSt can go as well.
+struct MathedRowContainer {
+///
        struct iterator {
                ///
                iterator() : st_(0), pos_(0) {}
@@ -75,9 +80,9 @@ private:
                ///
                MathedRowStruct & operator*() { Assert(st_); return st_->data_[pos_]; }
                ///
-               MathedRowStruct * operator->() { Assert(st_); return &st_->data_[pos_]; }
+               MathedRowStruct * operator->() { return &st_->data_[pos_]; }
                ///
-               MathedRowStruct const * operator->() const { Assert(st_); return &st_->data_[pos_]; }
+               MathedRowStruct const * operator->() const { return &st_->data_[pos_]; }
                ///
                void operator++() { Assert(st_); ++pos_; }
                ///
@@ -87,45 +92,28 @@ private:
                        { return st_ == it.st_ && pos_ == it.pos_; }
 
        //private:
-               ///
-               friend class MathedRowContainer;
-
-               /// pointer to the container to which we belong
                MathedRowContainer * st_;
-               /// position in this container, e.g. row number
+               ///
                unsigned int pos_;
        };
 
-public:
-       /// 
+       ///
        iterator begin() { return iterator(this); }
        ///
        bool empty() const { return data_.size() == 0; }
 
-       /// insert item before 'it'
+       /// insert 'item' before 'iterator'
        void insert(iterator const & it) {
                Assert(it.st_ == this);
                data_.insert(data_.begin() + it.pos_, MathedRowStruct());
        }
-                       
-       /// erase item pointed to by 'it'
+
+       /// insert 'item' before 'iterator'
        void erase(iterator & it) {
                Assert(it.st_ == this);
                data_.erase(data_.begin() + it.pos_);
        }
 
-       /// access to last item
-       MathedRowStruct & back() {
-               Assert(data_.size());
-               return data_.back();
-       }
-       
-       /// append empty element
-       void push_back() {
-               data_.push_back(MathedRowStruct());
-       }
-       
-
        ///
        std::vector<MathedRowStruct> data_;