From: Alfredo Braunstein Date: Fri, 19 Mar 2004 16:36:52 +0000 (+0000) Subject: andre's "brown paper bag" patch X-Git-Tag: 1.6.10~15450 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=87a0c7598fbf04a9e55782632c1560a8d1f8afa2;p=features.git andre's "brown paper bag" patch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8506 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView.C b/src/BufferView.C index dc813f9b03..53defc5c60 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -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); } diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 58f1d633ad..79ec08c71b 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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); diff --git a/src/ChangeLog b/src/ChangeLog index 27132410fc..78d1fb80f3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ + +2004-03-19 André Pönitz + +        * 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 * LColor.C (getFromLyXName): make sure that the color name is used diff --git a/src/cursor.C b/src/cursor.C index adc8c6a0d4..6f8a911191 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -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; diff --git a/src/cursor.h b/src/cursor.h index 07a47b4e84..2bb5980277 100644 --- a/src/cursor.h +++ b/src/cursor.h @@ -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 diff --git a/src/paragraph.C b/src/paragraph.C index 2be105b73b..bbefcb9254 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -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; } diff --git a/src/paragraph.h b/src/paragraph.h index 28067bd2c2..08e897bba7 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -65,7 +65,7 @@ public: /// Paragraph(Paragraph const &); /// - void operator=(Paragraph const &); + Paragraph & operator=(Paragraph const &); /// ~Paragraph();