]> git.lyx.org Git - features.git/commitdiff
andre's "brown paper bag" patch
authorAlfredo Braunstein <abraunst@lyx.org>
Fri, 19 Mar 2004 16:36:52 +0000 (16:36 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Fri, 19 Mar 2004 16:36:52 +0000 (16:36 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8506 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView_pimpl.C
src/ChangeLog
src/cursor.C
src/cursor.h
src/paragraph.C
src/paragraph.h

index dc813f9b03591b67b2ba40574db6da479bb01681..53defc5c60f1d3b99155cea30d68296f442f7e72 100644 (file)
@@ -370,15 +370,14 @@ LyXText * BufferView::text() const
 void BufferView::setCursor(ParIterator const & par, lyx::pos_type pos)
 {
        LCursor & cur = cursor();
-       cur.reset();
-       cur.push(buffer()->inset());
+       cur.reset(buffer()->inset());
        ParIterator::PosHolder const & positions = par.positions();
        int const last = par.size() - 1;
        for (int i = 0; i < last; ++i)
                (*positions[i].it)->inset->edit(cur, true);
        cur.resetAnchor();
-       LyXText * text = par.text(*buffer());
-       text->setCursor(cur, text->parOffset(par.pit()), pos);
+       LyXText & text = *par.text(*buffer());
+       text.setCursor(cur, text.parOffset(par.pit()), pos);
 }
 
 
index 58f1d633ad29fea8604efcfcd2f570d1439ef153..79ec08c71b4b898cd0b8a11ba9f163fe4a45dbdf 100644 (file)
@@ -442,14 +442,14 @@ void BufferView::Pimpl::scrollDocView(int value)
        int const first = top_y() + height;
        int const last = top_y() + workarea().workHeight() - height;
 
-       bv_->cursor().reset();
+       bv_->cursor().reset(bv_->buffer()->inset());
        LyXText * text = bv_->text();
-       CursorSlice & cur = bv_->cursor().front();
-       int y = text->cursorY(cur);
+       int y = text->cursorY(bv_->cursor().front());
        if (y < first)
-               text->setCursorFromCoordinates(bv_->cursor(), 0, first);
-       else if (y > last)
-               text->setCursorFromCoordinates(bv_->cursor(), 0, last);
+               y = first;
+       if (y > last)
+               y = last;
+       text->setCursorFromCoordinates(bv_->cursor(), 0, y);
 
        owner_->updateLayoutChoice();
 }
@@ -1028,7 +1028,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
                break;
 
        case LFUN_ACCEPT_ALL_CHANGES: {
-               bv_->cursor().reset();
+               bv_->cursor().reset(bv_->buffer()->inset());
 #warning FIXME changes
                while (lyx::find::findNextChange(bv_))
                        bv_->getLyXText()->acceptChange(bv_->cursor());
@@ -1037,7 +1037,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
        }
 
        case LFUN_REJECT_ALL_CHANGES: {
-               bv_->cursor().reset();
+               bv_->cursor().reset(bv_->buffer()->inset());
 #warning FIXME changes
                while (lyx::find::findNextChange(bv_))
                        bv_->getLyXText()->rejectChange(bv_->cursor());
@@ -1090,7 +1090,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
                break;
 
        case LFUN_BEGINNINGBUFSEL:
-               bv_->cursor().reset();
+               bv_->cursor().reset(bv_->buffer()->inset());
                if (!cur.selection())
                        cur.resetAnchor();
                bv_->text()->cursorTop(cur);
@@ -1098,7 +1098,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
                break;
 
        case LFUN_ENDBUFSEL:
-               bv_->cursor().reset();
+               bv_->cursor().reset(bv_->buffer()->inset());
                if (!cur.selection())
                        cur.resetAnchor();
                bv_->text()->cursorBottom(cur);
index 27132410fcf2fce55bc318860c0de074f9efcc36..78d1fb80f39647e065c0c3e7260914981c14fd62 100644 (file)
@@ -1,3 +1,14 @@
+
+2004-03-19  André Pönitz  <poenitz@gmx.net>
+
+        * cursor.[Ch] (reset): take main text inset as argument
+
+        * BufferView: adjust
+        * BufferView_pimpl.C: adjust
+
+        * paragraph.[Ch]: fix completely broken operator=()
+
+
 2004-03-16  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * LColor.C (getFromLyXName): make sure that the color name is used
index adc8c6a0d4495344f69b8cbe6827b2d2b23b65ff..6f8a9111916a380ffb90ca2cac882a35bd5ab044 100644 (file)
@@ -86,12 +86,12 @@ LCursor::LCursor(BufferView & bv)
 {}
 
 
-void LCursor::reset()
+void LCursor::reset(InsetBase & inset)
 {
        clear();
-       push_back(CursorSlice());
+       push_back(CursorSlice(inset));
        anchor_.clear();
-       anchor_.push_back(CursorSlice());
+       anchor_.push_back(CursorSlice(inset));
        cached_y_ = 0;
        clearTargetX();
        selection_ = false;
index 07a47b4e843031dfa7c868b35957b9731b433c7c..2bb5980277461d65a20b346d486cffccf1da9a6e 100644 (file)
@@ -159,8 +159,9 @@ public:
        void info(std::ostream & os) const;
        /// are we in math mode (2), text mode (1) or unsure (0)?
        int currentMode();
-       /// reset cursor
-       void reset();
+       /// reset cursor bottom to the beginning of the given inset
+       // (sort of 'chroot' environment...)
+       void reset(InsetBase &);
        /// for spellchecking
        void replaceWord(std::string const & replacestring);
        /// update our view
index 2be105b73b34677e7989a48cd9562a8ee61985fd..bbefcb92549ed8f97c156ebf2c1ca03e26f9b849 100644 (file)
@@ -80,6 +80,7 @@ Paragraph::Paragraph(Paragraph const & par)
                text_(par.text_), begin_of_body_(par.begin_of_body_),
          pimpl_(new Paragraph::Pimpl(*par.pimpl_, this))
 {
+       //lyxerr << "Paragraph::Paragraph(Paragraph const&)" << endl;
        InsetList::iterator it = insetlist.begin();
        InsetList::iterator end = insetlist.end();
        for (; it != end; ++it)
@@ -87,32 +88,30 @@ Paragraph::Paragraph(Paragraph const & par)
 }
 
 
-void Paragraph::operator=(Paragraph const & par)
+Paragraph & Paragraph::operator=(Paragraph const & par)
 {
        // needed as we will destroy the pimpl_ before copying it
-       if (&par != this)
-               return;
-
-       lyxerr << "Paragraph::operator=()" << endl;
-
-       itemdepth = par.itemdepth;
-
-       insetlist = par.insetlist;
-       InsetList::iterator it = insetlist.begin();
-       InsetList::iterator end = insetlist.end();
-       for (; it != end; ++it)
-               it->inset = it->inset->clone().release();
-
-       rows = par.rows;
-       y = par.y;
-       height = par.height;
-       width = par.width;
-       layout_ = par.layout();
-       text_ = par.text_;
-       begin_of_body_ = par.begin_of_body_;
-
-       delete pimpl_;
-       pimpl_ = new Pimpl(*par.pimpl_, this);
+       if (&par != this) {
+               itemdepth = par.itemdepth;
+
+               insetlist = par.insetlist;
+               InsetList::iterator it = insetlist.begin();
+               InsetList::iterator end = insetlist.end();
+               for (; it != end; ++it)
+                       it->inset = it->inset->clone().release();
+
+               rows = par.rows;
+               y = par.y;
+               height = par.height;
+               width = par.width;
+               layout_ = par.layout();
+               text_ = par.text_;
+               begin_of_body_ = par.begin_of_body_;
+
+               delete pimpl_;
+               pimpl_ = new Pimpl(*par.pimpl_, this);
+       }
+       return *this;
 }
 
 
index 28067bd2c2e300a52c61f6ab92f4710f541bffac..08e897bba77ffed295453d563eb351d40df76a6c 100644 (file)
@@ -65,7 +65,7 @@ public:
        ///
        Paragraph(Paragraph const &);
        ///
-       void operator=(Paragraph const &);
+       Paragraph & operator=(Paragraph const &);
        ///
        ~Paragraph();