]> git.lyx.org Git - features.git/commitdiff
dociterator dont inherit from std::vector and updates
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 8 Feb 2005 13:18:05 +0000 (13:18 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 8 Feb 2005 13:18:05 +0000 (13:18 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9602 a592a061-630c-0410-9148-cb99ea01b6c8

24 files changed:
src/BufferView.C
src/BufferView_pimpl.C
src/ChangeLog
src/CutAndPaste.C
src/buffer.C
src/bufferview_funcs.C
src/cursor.C
src/dociterator.C
src/dociterator.h
src/frontends/ChangeLog
src/frontends/LyXView.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlSpellchecker.C
src/frontends/controllers/ControlTabular.C
src/insets/ChangeLog
src/insets/insetcollapsable.C
src/insets/insettabular.C
src/insets/insettext.C
src/lyxfunc.C
src/mathed/ChangeLog
src/mathed/math_data.C
src/paragraph.C
src/text2.C
src/text3.C

index ecc66f0e05e8c4a1aee8cb3c8ced8de450c16f7d..2011ece20ad51217ba871759fcf7664667dd81e4 100644 (file)
@@ -326,13 +326,14 @@ LyXText * BufferView::text() const
 
 void BufferView::setCursor(ParIterator const & par, lyx::pos_type pos)
 {
-       for (int i = 0, n = par.size(); i < n; ++i)
+       for (int i = 0, n = par.depth(); i < n; ++i)
                par[i].inset().edit(cursor(), true);
 
        cursor().setCursor(makeDocIterator(par, pos));
        cursor().selection() = false;
 }
 
+
 void BufferView::putSelectionAt(DocIterator const & cur,
                                int length, bool backwards)
 {
index 2766e50deb6c757d4e293390ff2bf68b1f91025f..ea00412459f872af0c45d6f0788eccf6b67ece07 100644 (file)
@@ -484,7 +484,7 @@ void BufferView::Pimpl::scrollDocView(int value)
 }
 
 
-void BufferView::Pimpl::scroll(int lines)
+void BufferView::Pimpl::scroll(int /*lines*/)
 {
 //     if (!buffer_)
 //             return;
@@ -540,11 +540,11 @@ void BufferView::Pimpl::selectionRequested()
        }
 
        if (!xsel_cache_.set ||
-           cur.back() != xsel_cache_.cursor ||
-           cur.anchor_.back() != xsel_cache_.anchor)
+           cur.top() != xsel_cache_.cursor ||
+           cur.anchor_.top() != xsel_cache_.anchor)
        {
-               xsel_cache_.cursor = cur.back();
-               xsel_cache_.anchor = cur.anchor_.back();
+               xsel_cache_.cursor = cur.top();
+               xsel_cache_.anchor = cur.anchor_.top();
                xsel_cache_.set = cur.selection();
                sel = cur.selectionAsString(false);
                if (!sel.empty())
index b74e12d712e2e4e91fb1a39999fe7e1a2c38fc1a..da9c5ff1f30c6e7d684b5844aded48a7abd18b6d 100644 (file)
@@ -1,3 +1,37 @@
+2005-02-08  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * text3.C (dispatch): size() -> depth()
+
+       * text2.C: remove some debug output
+
+       * paragraph.C: ws changes only
+
+       * lyxfunc.C (getStatus): size() -> depth()
+
+       * dociterator.h (clear, push_back, pop_back, internalData,
+       operator[], resize, empty): new functions
+       Make StableDocIterator and operator== be friends. Don't inherit
+       from std::vector use a privat class variable slices_ instead.
+       Modify to fit.
+
+       * dociterator.C: update because of not inheriting from std::vector
+       anymore. Call explictly to slices_ instead. Use depth() instead of
+       size() and top() instead of back()
+
+       * cursor.C: chagne size() -> depth and back() -> top(). Also
+       remove some direct operator[](i) calls in favour of foo[i]
+       (getFont): remove some dead code
+
+       * bufferview_funcs.C (coordOffset): size() -> depth()
+
+       * buffer.C: ws changes only
+
+       * CutAndPaste.C (eraseSelection): back() -> top()
+
+       * BufferView_pimpl.C (selectionRequested): back() -> top()
+
+       * BufferView.C (setCursor): size() -> depth()
+
 2005-02-08  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * text3.C (cursorPrevious): return true if depm changed something
index 32bbbdf7a393878b68a2c48aee7d79ceb908a59f..ea55f938b8ec8e60232ed029b792f57d2bf0eba9 100644 (file)
@@ -681,7 +681,7 @@ void eraseSelection(LCursor & cur)
                                for (InsetBase::col_type col = c1; col <= c2; ++col)
                                        p->cell(p->index(row, col)).clear();
                }
-               cur.back() = i1;
+               cur.top() = i1;
                cur.pos() = 0; // We've deleted the whole cell. Only pos 0 is valid.
                cur.resetAnchor();
        } else {
index 8acdc91f38600d3e281f498ccefccbbbdd385997..9287b877badee5cd4171f149eb58dac8a5534a45 100644 (file)
@@ -482,7 +482,7 @@ void Buffer::insertStringAsLines(ParagraphList & pars,
        // insert the string, don't insert doublespace
        bool space_inserted = true;
        for (string::const_iterator cit = str.begin();
-           cit != str.end(); ++cit) { 
+           cit != str.end(); ++cit) {
                Paragraph & par = pars[pit];
                if (*cit == '\n') {
                        if (autobreakrows && (!par.empty() || par.allowEmpty())) {
index e83ce1ae85ae08074e1c7eaf534c43eb0a03c7c2..8032e6cdacd7c55662ea69db325edbe0e8da0aea 100644 (file)
@@ -156,9 +156,10 @@ Point coordOffset(DocIterator const & dit)
        int y = 0;
 
        // Contribution of nested insets
-       for (size_t i = 1; i != dit.size(); ++i) {
+       for (size_t i = 1; i != dit.depth(); ++i) {
                CursorSlice const & sl = dit[i];
-               int xx = 0, yy = 0;
+               int xx = 0;
+               int yy = 0;
                sl.inset().getCursorPos(sl, xx, yy);
                x += xx;
                y += yy;
@@ -184,7 +185,7 @@ Point getPos(DocIterator const & dit)
        CoordCache::InnerParPosCache::const_iterator it = cache.find(bot.pit());
        if (it == cache.end()) {
                //lyxerr << "cursor out of view" << std::endl;
-               return Point(-1,-1);
+               return Point(-1, -1);
        }
        Point p = coordOffset(dit); // offset from outer paragraph
        p.y_ += it->second.y_;
index e0b4e20453f9149743c793c8b5ca74dd3b8f81bc..6aeaec8884d0d8f47d0cf33045fe79c611b77a8e 100644 (file)
@@ -69,11 +69,11 @@ namespace {
        positionable(DocIterator const & cursor, DocIterator const & anchor)
        {
                // avoid deeper nested insets when selecting
-               if (cursor.size() > anchor.size())
+               if (cursor.depth() > anchor.depth())
                        return false;
 
                // anchor might be deeper, should have same path then
-               for (size_t i = 0; i < cursor.size(); ++i)
+               for (size_t i = 0; i < cursor.depth(); ++i)
                        if (&cursor[i].inset() != &anchor[i].inset())
                                return false;
 
@@ -91,11 +91,12 @@ namespace {
                DocIterator result;
 
                DocIterator it = c;
-               it.back().pos() = 0;
+               it.top().pos() = 0;
                DocIterator et = c;
-               et.back().pos() = et.back().asMathInset()->cell(et.back().idx()).size();
+               et.top().pos() = et.top().asMathInset()->cell(et.top().idx()).size();
                for (int i = 0; ; ++i) {
-                       int xo, yo;
+                       int xo;
+                       int yo;
                        LCursor cur = c;
                        cur.setCursor(it);
                        cur.inset().getCursorPos(cur.top(), xo, yo);
@@ -192,15 +193,16 @@ void LCursor::setCursor(DocIterator const & cur)
 
 void LCursor::dispatch(FuncRequest const & cmd0)
 {
-       lyxerr[Debug::DEBUG] << "LCursor::dispatch: cmd: "
-               << cmd0 << endl << *this << endl;
+       lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
+                            << " cmd: " << cmd0 << '\n'
+                            << *this << endl;
        if (empty())
                return;
 
        FuncRequest cmd = cmd0;
        LCursor safe = *this;
 
-       for (; size(); pop()) {
+       for (; depth(); pop()) {
                lyxerr[Debug::DEBUG] << "LCursor::dispatch: cmd: "
                        << cmd0 << endl << *this << endl;
                BOOST_ASSERT(pos() <= lastpos());
@@ -249,7 +251,7 @@ Buffer & LCursor::buffer() const
 
 void LCursor::pop()
 {
-       BOOST_ASSERT(size() >= 1);
+       BOOST_ASSERT(depth() >= 1);
        pop_back();
 }
 
@@ -297,7 +299,7 @@ bool LCursor::popRight()
 int LCursor::currentMode()
 {
        BOOST_ASSERT(!empty());
-       for (int i = size() - 1; i >= 0; --i) {
+       for (int i = depth() - 1; i >= 0; --i) {
                int res = operator[](i).inset().currentMode();
                if (res != InsetBase::UNDECIDED_MODE)
                        return res;
@@ -347,9 +349,9 @@ bool LCursor::posRight()
 
 CursorSlice LCursor::anchor() const
 {
-       BOOST_ASSERT(anchor_.size() >= size());
-       CursorSlice normal = anchor_[size() - 1];
-       if (size() < anchor_.size() && back() <= normal) {
+       BOOST_ASSERT(anchor_.depth() >= depth());
+       CursorSlice normal = anchor_[depth() - 1];
+       if (depth() < anchor_.depth() && top() <= normal) {
                // anchor is behind cursor -> move anchor behind the inset
                ++normal.pos();
        }
@@ -360,16 +362,16 @@ CursorSlice LCursor::anchor() const
 CursorSlice LCursor::selBegin() const
 {
        if (!selection())
-               return back();
-       return anchor() < back() ? anchor() : back();
+               return top();
+       return anchor() < top() ? anchor() : top();
 }
 
 
 CursorSlice LCursor::selEnd() const
 {
        if (!selection())
-               return back();
-       return anchor() > back() ? anchor() : back();
+               return top();
+       return anchor() > top() ? anchor() : top();
 }
 
 
@@ -377,7 +379,7 @@ DocIterator LCursor::selectionBegin() const
 {
        if (!selection())
                return *this;
-       return anchor() < back() ? anchor_ : *this;
+       return anchor() < top() ? anchor_ : *this;
 }
 
 
@@ -385,7 +387,7 @@ DocIterator LCursor::selectionEnd() const
 {
        if (!selection())
                return *this;
-       return anchor() > back() ? anchor_ : *this;
+       return anchor() > top() ? anchor_ : *this;
 }
 
 
@@ -465,15 +467,15 @@ void LCursor::selHandle(bool sel)
 std::ostream & operator<<(std::ostream & os, LCursor const & cur)
 {
        os << "\n cursor:                                | anchor:\n";
-       for (size_t i = 0, n = cur.size(); i != n; ++i) {
-               os << " " << cur.operator[](i) << " | ";
-               if (i < cur.anchor_.size())
+       for (size_t i = 0, n = cur.depth(); i != n; ++i) {
+               os << " " << cur[i] << " | ";
+               if (i < cur.anchor_.depth())
                        os << cur.anchor_[i];
                else
                        os << "-------------------------------";
                os << "\n";
        }
-       for (size_t i = cur.size(), n = cur.anchor_.size(); i < n; ++i) {
+       for (size_t i = cur.depth(), n = cur.anchor_.depth(); i < n; ++i) {
                os << "------------------------------- | " << cur.anchor_[i] << "\n";
        }
        os << " selection: " << cur.selection_
@@ -525,7 +527,7 @@ bool LCursor::openable(MathAtom const & t) const
                return true;
 
        // we can't move into anything new during selection
-       if (depth() >= anchor_.size())
+       if (depth() >= anchor_.depth())
                return false;
        if (!ptr_cmp(t.nucleus(), &anchor_[depth()].inset()))
                return false;
@@ -620,7 +622,7 @@ void LCursor::niceInsert(string const & t)
 void LCursor::niceInsert(MathAtom const & t)
 {
        macroModeClose();
-       string safe = lyx::cap::grabAndEraseSelection(*this);
+       string const safe = lyx::cap::grabAndEraseSelection(*this);
        plainInsert(t);
        // enter the new inset and move the contents of the selection if possible
        if (t->isActive()) {
@@ -752,7 +754,7 @@ void LCursor::macroModeClose()
                return;
        MathUnknownInset * p = activeMacro();
        p->finalize();
-       string s = p->name();
+       string const s = p->name();
        --pos();
        cell().erase(pos());
 
@@ -803,10 +805,11 @@ int LCursor::targetX() const
 
 void LCursor::setTargetX()
 {
-       //for now this is good enough. A better solution would be to
-       //avoid this rebreak by setting cursorX only after drawing
+       // For now this is good enough. A better solution would be to
+       // avoid this rebreak by setting cursorX only after drawing
        bottom().text()->redoParagraph(bottom().pit());
-       int x, y;
+       int x;
+       int y;
        getPos(x, y);
        x_target_ = x;
 }
@@ -934,7 +937,7 @@ bool LCursor::goUpDown(bool up)
        //}
 
        // try to find an inset that knows better then we
-       while (1) {
+       while (true) {
                //lyxerr << "updown: We are in " << &inset() << " idx: " << idx() << endl;
                // ask inset first
                if (inset().idxUpDown(*this, up)) {
@@ -953,7 +956,8 @@ bool LCursor::goUpDown(bool up)
                }
 
                // any improvement so far?
-               int xnew, ynew;
+               int xnew;
+               int ynew;
                getPos(xnew, ynew);
                if (up ? ynew < yo : ynew > yo)
                        return true;
@@ -1061,7 +1065,7 @@ string LCursor::currentState()
        }
 
        if (inTexted())
-        return text()->currentState(*this);
+               return text()->currentState(*this);
 
        return string();
 }
@@ -1082,7 +1086,7 @@ Encoding const * LCursor::getEncoding() const
        int s = 0;
        // go up until first non-0 text is hit
        // (innermost text is 0 in mathed)
-       for (s = size() - 1; s >= 0; --s)
+       for (s = depth() - 1; s >= 0; --s)
                if (operator[](s).text())
                        break;
        CursorSlice const & sl = operator[](s);
@@ -1123,7 +1127,7 @@ LyXFont LCursor::getFont() const
        int s = 0;
        // go up until first non-0 text is hit
        // (innermost text is 0 in mathed)
-       for (s = size() - 1; s >= 0; --s)
+       for (s = depth() - 1; s >= 0; --s)
                if (operator[](s).text())
                        break;
        CursorSlice const & sl = operator[](s);
@@ -1132,7 +1136,6 @@ LyXFont LCursor::getFont() const
                bv().buffer()->params(),
                sl.pos(),
                outerFont(sl.pit(), text.paragraphs()));
-       for (; s < size(); ++s)
-               ;
+
        return font;
 }
index fe01067aba2016dd186431a6aa70d6f3b90a98f5..81f465826baa3d697e9c56a20b9d554464a5a6d3 100644 (file)
@@ -244,11 +244,11 @@ bool DocIterator::inTexted() const
 LyXText * DocIterator::innerText()
 {
        BOOST_ASSERT(!empty());
-       // go up until first non-0 text is hit
+       // Go up until first non-0 text is hit
        // (innermost text is 0 in mathed)
-       for (int i = size() - 1; i >= 0; --i)
-               if (operator[](i).text())
-                       return operator[](i).text();
+       for (int i = depth() - 1; i >= 0; --i)
+               if (slices_[i].text())
+                       return slices_[i].text();
        return 0;
 }
 
@@ -257,18 +257,18 @@ LyXText const * DocIterator::innerText() const
        BOOST_ASSERT(!empty());
        // go up until first non-0 text is hit
        // (innermost text is 0 in mathed)
-       for (int i = size() - 1; i >= 0; --i)
-               if (operator[](i).text())
-                       return operator[](i).text();
+       for (int i = depth() - 1; i >= 0; --i)
+               if (slices_[i].text())
+                       return slices_[i].text();
        return 0;
 }
 
 
 InsetBase * DocIterator::innerInsetOfType(int code) const
 {
-       for (int i = size() - 1; i >= 0; --i)
-               if (operator[](i).inset_->lyxCode() == code)
-                       return operator[](i).inset_;
+       for (int i = depth() - 1; i >= 0; --i)
+               if (slices_[i].inset_->lyxCode() == code)
+                       return slices_[i].inset_;
        return 0;
 }
 
@@ -281,7 +281,7 @@ void DocIterator::forwardPos()
                return;
        }
 
-       CursorSlice & top = back();
+       CursorSlice & tip = top();
        //lyxerr << "XXX\n" << *this << endl;
 
        // this is used twice and shows up in the profiler!
@@ -290,13 +290,13 @@ void DocIterator::forwardPos()
        // move into an inset to the right if possible
        InsetBase * n = 0;
 
-       if (top.pos() != lastp) {
+       if (tip.pos() != lastp) {
                // this is impossible for pos() == size()
                if (inMathed()) {
-                       n = (top.cell().begin() + top.pos())->nucleus();
+                       n = (tip.cell().begin() + tip.pos())->nucleus();
                } else {
-                       if (paragraph().isInset(top.pos()))
-                               n = paragraph().getInset(top.pos());
+                       if (paragraph().isInset(tip.pos()))
+                               n = paragraph().getInset(tip.pos());
                }
        }
 
@@ -307,28 +307,28 @@ void DocIterator::forwardPos()
        }
 
        // otherwise move on one position if possible
-       if (top.pos() < lastp) {
+       if (tip.pos() < lastp) {
                //lyxerr << "... next pos" << endl;
-               ++top.pos();
+               ++tip.pos();
                return;
        }
        //lyxerr << "... no next pos" << endl;
 
        // otherwise move on one paragraph if possible
-       if (top.pit() < lastpit()) {
+       if (tip.pit() < lastpit()) {
                //lyxerr << "... next par" << endl;
-               ++top.pit();
-               top.pos() = 0;
+               ++tip.pit();
+               tip.pos() = 0;
                return;
        }
        //lyxerr << "... no next pit" << endl;
 
        // otherwise try to move on one cell if possible
-       if (top.idx() < lastidx()) {
+       if (tip.idx() < lastidx()) {
                //lyxerr << "... next idx" << endl;
-               ++top.idx();
-               top.pit() = 0;
-               top.pos() = 0;
+               ++tip.idx();
+               tip.pit() = 0;
+               tip.pos() = 0;
                return;
        }
        //lyxerr << "... no next idx" << endl;
@@ -336,8 +336,8 @@ void DocIterator::forwardPos()
        // otherwise leave inset and jump over inset as a whole
        pop_back();
        // 'top' is invalid now...
-       if (size())
-               ++back().pos();
+       if (!empty())
+               ++top().pos();
 }
 
 
@@ -352,7 +352,7 @@ void DocIterator::forwardPar()
 void DocIterator::forwardChar()
 {
        forwardPos();
-       while (size() != 0 && pos() == lastpos())
+       while (!empty() && pos() == lastpos())
                forwardPos();
 }
 
@@ -360,7 +360,7 @@ void DocIterator::forwardChar()
 void DocIterator::forwardInset()
 {
        forwardPos();
-       while (size() != 0 && (pos() == lastpos() || nextInset() == 0))
+       while (!empty() && (pos() == lastpos() || nextInset() == 0))
                forwardPos();
 }
 
@@ -368,7 +368,7 @@ void DocIterator::forwardInset()
 void DocIterator::backwardChar()
 {
        backwardPos();
-       while (size() != 0 && pos() == lastpos())
+       while (!empty() && pos() == lastpos())
                backwardPos();
 }
 
@@ -378,24 +378,24 @@ void DocIterator::backwardPos()
        //this dog bites his tail
        if (empty()) {
                push_back(CursorSlice(*inset_));
-               back().idx() = lastidx();
-               back().pit() = lastpit();
-               back().pos() = lastpos();
+               top().idx() = lastidx();
+               top().pit() = lastpit();
+               top().pos() = lastpos();
                return;
        }
 
-       CursorSlice & top = back();
+       CursorSlice & tip = top();
 
-       if (top.pos() != 0) {
-               --top.pos();
-       } else if (top.pit() != 0) {
-               --top.pit();
-               top.pos() = lastpos();
+       if (tip.pos() != 0) {
+               --tip.pos();
+       } else if (tip.pit() != 0) {
+               --tip.pit();
+               tip.pos() = lastpos();
                return;
-       } else if (top.idx() != 0) {
-               --top.idx();
-               top.pit() = lastpit();
-               top.pos() = lastpos();
+       } else if (tip.idx() != 0) {
+               --tip.idx();
+               tip.pit() = lastpit();
+               tip.pos() = lastpos();
                return;
        } else {
                pop_back();
@@ -406,17 +406,17 @@ void DocIterator::backwardPos()
        InsetBase * n = 0;
 
        if (inMathed()) {
-               n = (top.cell().begin() + top.pos())->nucleus();
+               n = (tip.cell().begin() + tip.pos())->nucleus();
        } else {
-               if (paragraph().isInset(top.pos()))
-                       n = paragraph().getInset(top.pos());
+               if (paragraph().isInset(tip.pos()))
+                       n = paragraph().getInset(tip.pos());
        }
 
        if (n && n->isActive()) {
                push_back(CursorSlice(*n));
-               back().idx() = lastidx();
-               back().pit() = lastpit();
-               back().pos() = lastpos();
+               top().idx() = lastidx();
+               top().pit() = lastpit();
+               top().pos() = lastpos();
        }
 }
 
@@ -424,18 +424,18 @@ void DocIterator::backwardPos()
 bool DocIterator::hasPart(DocIterator const & it) const
 {
        // it can't be a part if it is larger
-       if (it.size() > size())
+       if (it.depth() > depth())
                return false;
 
        // as inset adresses are the 'last' level
-       return &it.back().inset() == &operator[](it.size() - 1).inset();
+       return &it.top().inset() == &slices_[it.depth() - 1].inset();
 }
 
 
 std::ostream & operator<<(std::ostream & os, DocIterator const & dit)
 {
-       for (size_t i = 0, n = dit.size(); i != n; ++i)
-               os << " " << dit.operator[](i) << "\n";
+       for (size_t i = 0, n = dit.depth(); i != n; ++i)
+               os << " " << dit[i] << "\n";
        return os;
 }
 
@@ -443,9 +443,9 @@ std::ostream & operator<<(std::ostream & os, DocIterator const & dit)
 
 ///////////////////////////////////////////////////////
 
-StableDocIterator::StableDocIterator(const DocIterator & dit)
+StableDocIterator::StableDocIterator(DocIterator const & dit)
 {
-       data_ = dit;
+       data_ = dit.internalData();
        for (size_t i = 0, n = data_.size(); i != n; ++i)
                data_[i].inset_ = 0;
 }
@@ -459,14 +459,15 @@ DocIterator StableDocIterator::asDocIterator(InsetBase * inset) const
        for (size_t i = 0, n = data_.size(); i != n; ++i) {
                if (inset == 0) {
                        // FIXME
-                       lyxerr << "Should not happen, but does e.g. after C-n C-l C-z S-C-z"
-                               << endl << "dit: " << dit << endl
+                       lyxerr << BOOST_CURRENT_FUNCTION
+                              << " Should not happen, but does e.g. after C-n C-l C-z S-C-z"
+                               << '\n' << "dit: " << dit << '\n'
                                << " lastpos: " << dit.lastpos() << endl;
                        //break;
                        BOOST_ASSERT(false);
                }
                dit.push_back(data_[i]);
-               dit.back().inset_ = inset;
+               dit.top().inset_ = inset;
                if (i + 1 != n)
                        inset = dit.nextInset();
        }
index b5a1e80659cd622587cda55c9b86dcef605732af..a91fd32af39c17077bcc9ecaefddf4d145cc4a53 100644 (file)
@@ -34,7 +34,7 @@ bool ptr_cmp(A const * a, B const * b)
 
 // The public inheritance should go in favour of a suitable data member
 // (or maybe private inheritance) at some point of time.
-class DocIterator : public std::vector<CursorSlice>
+class DocIterator // : public std::vector<CursorSlice>
 {
 public:
        /// type for cell number in inset
@@ -54,42 +54,55 @@ public:
        ///
        explicit DocIterator(InsetBase & inset);
 
+       CursorSlice const & operator[](size_t i) const {
+               return slices_[i];
+       }
+
+       CursorSlice & operator[](size_t i) {
+               return slices_[i];
+       }
+
+       // What is the point of this function?
+       void resize(size_t i) { slices_.resize(i); }
+
        /// is the iterator valid?
        operator const void*() const { return empty() ? 0 : this; }
        /// is this iterator invalid?
        bool operator!() const { return empty(); }
 
+       bool empty() const { return slices_.empty(); }
+
        //
        // access to slice at tip
        //
        /// access to tip
-       CursorSlice & top() { return back(); }
+       CursorSlice & top() { return slices_.back(); }
        /// access to tip
-       CursorSlice const & top() const { return back(); }
+       CursorSlice const & top() const { return slices_.back(); }
        /// access to outermost slice
-       CursorSlice & bottom() { return front(); }
+       CursorSlice & bottom() { return slices_.front(); }
        /// access to  outermost slicetip
-       CursorSlice const & bottom() const { return front(); }
+       CursorSlice const & bottom() const { return slices_.front(); }
        /// how many nested insets do we have?
-       size_t depth() const { return size(); }
+       size_t depth() const { return slices_.size(); }
        /// the containing inset
-       InsetBase & inset() const { return back().inset(); }
+       InsetBase & inset() const { return top().inset(); }
        /// return the cell of the inset this cursor is in
-       idx_type idx() const { return back().idx(); }
+       idx_type idx() const { return top().idx(); }
        /// return the cell of the inset this cursor is in
-       idx_type & idx() { return back().idx(); }
+       idx_type & idx() { return top().idx(); }
        /// return the last possible cell in this inset
        idx_type lastidx() const;
        /// return the paragraph this cursor is in
-       pit_type pit() const { return back().pit(); }
+       pit_type pit() const { return top().pit(); }
        /// return the paragraph this cursor is in
-       pit_type & pit() { return back().pit(); }
+       pit_type & pit() { return top().pit(); }
        /// return the last possible paragraph in this inset
        pit_type lastpit() const;
        /// return the position within the paragraph
-       pos_type pos() const { return back().pos(); }
+       pos_type pos() const { return top().pos(); }
        /// return the position within the paragraph
-       pos_type & pos() { return back().pos(); }
+       pos_type & pos() { return top().pos(); }
        /// return the last position within the paragraph
        pos_type lastpos() const;
 
@@ -191,7 +204,21 @@ public:
        /// output
        friend std::ostream &
        operator<<(std::ostream & os, DocIterator const & cur);
+       friend bool operator==(DocIterator const &, DocIterator const &);
+       friend class StableDocIterator;
+protected:
+       void clear() { slices_.clear(); }
+       void push_back(CursorSlice const & sl) {
+               slices_.push_back(sl);
+       }
+       void pop_back() {
+               slices_.pop_back();
+       }
 private:
+       std::vector<CursorSlice> const & internalData() const {
+               return slices_;
+       }
+       std::vector<CursorSlice> slices_;
        InsetBase * inset_;
 };
 
@@ -200,6 +227,20 @@ DocIterator doc_iterator_begin(InsetBase & inset);
 DocIterator doc_iterator_end(InsetBase & inset);
 
 
+inline
+bool operator==(DocIterator const & di1, DocIterator const & di2)
+{
+       return di1.slices_ == di2.slices_;
+}
+
+
+inline
+bool operator!=(DocIterator const & di1, DocIterator const & di2)
+{
+       return !(di1 == di2);
+}
+
+
 // The difference to a ('non stable') DocIterator is the removed
 // (overwritte by 0...) part of the CursorSlice data items. So this thing
 // is suitable for external storage, but not for iteration as such.
index 4cf41a69026dfad6f32b73d1cade358b7edb5c65..f98bf7f9bda17406e77fe5f169d753e799fd0289 100644 (file)
@@ -1,3 +1,7 @@
+2005-02-08  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * LyXView.C (updateLayoutChoice): minor change to some comments
+
 2005-01-20  Asger Ottar Alstrup  <aalstrup@laerdal.dk>
 
        * pch.h: use the HAVE_UNISTD_H preprocessor guard.
index 848d0330afe319904805adb942d32d73bf38393d..7758bb400b96a353f6b8c1f624948452e27077d9 100644 (file)
@@ -140,13 +140,13 @@ void LyXView::resetAutosaveTimer()
 
 void LyXView::updateLayoutChoice()
 {
-       // don't show any layouts without a buffer
+       // Don't show any layouts without a buffer
        if (!view()->buffer()) {
                toolbars_->clearLayoutList();
                return;
        }
 
-       // update the layout display
+       // Update the layout display
        if (toolbars_->updateLayoutList(buffer()->params().textclass)) {
                current_layout = buffer()->params().getLyXTextClass().defaultLayoutName();
        }
index 88fc1447015092b98076b59a16d1bb2e8132cea8..65c71d828548c0cf623c4a74b9efada1f3d53880 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-08  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * ControlSpellchecker.C (nextWord): size() -> depth()
+       * ControlTabular.C(initializeParams): ditto
+
 2005-01-31  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * ControlGraphics.C (browse): rewrite to use boost.filesystem
index 40a73dba5dad205b26c5e366119abd481c231884..7e8c7b60f3026c95219b719db411f73c7c2c9a69 100644 (file)
@@ -138,7 +138,7 @@ WordLangTuple nextWord(DocIterator & cur, ptrdiff_t & progress,
        bool ignoreword = false;
        string word, lang_code;
 
-       while(cur.size()) {
+       while (cur.depth()) {
                if (isLetter(cur)) {
                        if (!inword) {
                                inword = true;
index 6cfb5df1887d2630e840d1d91e0e7ffece9a3fec..cbeec65e8dff58a9da07fcd78b2590d630ce2f71 100644 (file)
@@ -37,7 +37,7 @@ bool ControlTabular::initialiseParams(string const & data)
                LCursor const & cur = bv->cursor();
                // get the innermost tabular inset;
                // assume that it is "ours"
-               for (int i = cur.size() - 1; i >= 0; --i)
+               for (int i = cur.depth() - 1; i >= 0; --i)
                        if (cur[i].inset().lyxCode() == InsetBase::TABULAR_CODE) {
                                active_cell_ = cur[i].idx();
                                break;
index 2e1000c36c37cd6bf5e361e9caa856fbe12eb52d..b5f6f6a648fad8927a397b6c6a4800495f032c8d 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-08  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * insetcollapsable.C (leaveInset): size() -> depth()
+       * insettabular.C (isRightToLeft): ditto
+
 2005-02-03  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
 
        * insetert.C (latex, linuxdoc, docbook): remove newline handling
index 17bf4215ca2097927b45b30401b05bf67d839cb7..e22c1d63bc8efd186f0b7a10ca90719a7926bea2 100644 (file)
@@ -41,7 +41,7 @@ using std::ostream;
 
 void leaveInset(LCursor & cur, InsetBase const & in)
 {
-       for (unsigned int i = 0; i != cur.size(); ++i) {
+       for (size_t i = 0; i != cur.depth(); ++i) {
                if (&cur[i].inset() == &in) {
                        cur.resize(i);
                        return;
index 31d4744469ae64fc378ce04a488be2207b5e861a..68061502f74f3a1815cf1aa232cf81112e82e967 100644 (file)
@@ -1664,9 +1664,9 @@ void InsetTabular::cutSelection(LCursor & cur)
 
 bool InsetTabular::isRightToLeft(LCursor & cur) const
 {
-       BOOST_ASSERT(cur.size() > 1);
-       Paragraph const & parentpar = cur[cur.size() - 2].paragraph();
-       LCursor::pos_type const parentpos = cur[cur.size() - 2].pos();
+       BOOST_ASSERT(cur.depth() > 1);
+       Paragraph const & parentpar = cur[cur.depth() - 2].paragraph();
+       LCursor::pos_type const parentpos = cur[cur.depth() - 2].pos();
        return parentpar.getFontSettings(cur.bv().buffer()->params(),
                                         parentpos).language()->RightToLeft();
 }
index 144aa4fb4578f668634fd5281beaa1143b791e0e..f3c7a5450f573a39b106b5aa424797fe87615585 100644 (file)
@@ -292,7 +292,8 @@ InsetBase * InsetText::editXY(LCursor & cur, int x, int y) const
 
 void InsetText::doDispatch(LCursor & cur, FuncRequest & cmd)
 {
-       //lyxerr << "InsetText::doDispatch: " << cmd.action << " " << endl;
+       lyxerr << BOOST_CURRENT_FUNCTION
+              << " [ cmd.action = " << cmd.action << ']' << endl;
        setViewCache(&cur.bv());
 
        text_.dispatch(cur, cmd);
index 69bcaf2ea3ecf79dcc5aa6b442816260c6f91300..ef698a9fbef972efb0984bbb58018bf4fa07638e 100644 (file)
@@ -150,7 +150,7 @@ bool getStatus(LCursor cursor,
        // BufferView * arg, though (which should be avoided)
        //LCursor safe = *this;
        bool res = false;
-       for ( ; cursor.size(); cursor.pop()) {
+       for ( ; cursor.depth(); cursor.pop()) {
                //lyxerr << "\nLCursor::getStatus: cmd: " << cmd << endl << *this << endl;
                DocIterator::idx_type & idx = cursor.idx();
                DocIterator::idx_type const lastidx = cursor.lastidx();
@@ -444,7 +444,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
 
        case LFUN_INSET_SETTINGS: {
                enable = false;
-               if (!cur.size())
+               if (!cur)
                        break;
                UpdatableInset * inset = cur.inset().asUpdatableInset();
                lyxerr << "inset: " << inset << endl;
index 2717e0cef9f70f22d367ca1b6f9b33cb75e2d436..3b683126d5060373e84e2248f11f91fb4bad8056 100644 (file)
@@ -1,3 +1,7 @@
+2005-02-08  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * math_data.C (isInside): size() -> depth()
+
 2005-01-31  Asger Ottar Alstrup  <aalstrup@laerdal.dk>
 
        * math_data.C:
index ffda365de26ed54d09a107b4b2f8566e24ac731e..913eeef60ff57597b99455991e8807df6646916e 100644 (file)
@@ -221,7 +221,7 @@ namespace {
 bool isInside(DocIterator const & it, MathArray const & ar,
        lyx::pos_type p1, lyx::pos_type p2)
 {
-       for (size_t i = 0; i != it.size(); ++i) {
+       for (size_t i = 0; i != it.depth(); ++i) {
                CursorSlice const & sl = it[i];
                if (sl.inset().inMathed() && &sl.cell() == &ar)
                        return p1 <= sl.pos() && sl.pos() < p2;
index 755966eff1e815076a095c71bae089de2deaf9ee..28caa48fac40dcc04ec76a94f59f14113f6c614d 100644 (file)
@@ -901,9 +901,9 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
        }
 
        LyXFont basefont;
-       
+
        LaTeXFeatures features(buf, bparams, runparams.nice);
-       
+
        // output change tracking marks only if desired,
        // if dvipost is installed,
        // and with dvi/ps (other formats don't work)
@@ -1020,7 +1020,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
 
                Change::Type change = pimpl_->lookupChange(i);
 
-               column += Changes::latexMarkChange(os, running_change, 
+               column += Changes::latexMarkChange(os, running_change,
                        change, output);
                running_change = change;
 
@@ -1878,4 +1878,3 @@ void Paragraph::dump() const
                rows_[i].dump();
        }
 }
-
index 6560c49310402c9a1e4e51dd90a3067b7604eeeb..2fd76bc774c332268b8f8d463f17c07ac95ee4f6 100644 (file)
@@ -1246,9 +1246,6 @@ bool LyXText::cursorRight(LCursor & cur)
        if (cur.pos() != cur.lastpos()) {
                bool updateNeeded = false;
                if (!checkAndActivateInset(cur, true)) {
-                       lyxerr << BOOST_CURRENT_FUNCTION
-                              << " Running setCursor" << endl;
-
                        updateNeeded |= setCursor(cur, cur.pit(), cur.pos() + 1, true, false);
                        if (false && bidi.isBoundary(cur.buffer(), cur.paragraph(),
                                                         cur.pos()))
index ca0be38640a89a86165715fb8ee446e396bf4f09..9ddee5cf60f2574b5ce4fd8a2e52492ee0aa6687 100644 (file)
@@ -426,7 +426,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_BEGINNINGBUF:
-               if (cur.size() == 1) {
+               if (cur.depth() == 1) {
                        if (!cur.mark())
                                cur.clearSelection();
                        cursorTop(cur);
@@ -437,7 +437,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_BEGINNINGBUFSEL:
-               if (cur.size() == 1) {
+               if (cur.depth() == 1) {
                        if (!cur.selection())
                                cur.resetAnchor();
                        cursorTop(cur);
@@ -448,7 +448,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_ENDBUF:
-               if (cur.size() == 1) {
+               if (cur.depth() == 1) {
                        if (!cur.mark())
                                cur.clearSelection();
                        cursorBottom(cur);
@@ -459,7 +459,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_ENDBUFSEL:
-               if (cur.size() == 1) {
+               if (cur.depth() == 1) {
                        if (!cur.selection())
                                cur.resetAnchor();
                        cursorBottom(cur);