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);
}
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();
}
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());
}
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());
break;
case LFUN_BEGINNINGBUFSEL:
- bv_->cursor().reset();
+ bv_->cursor().reset(bv_->buffer()->inset());
if (!cur.selection())
cur.resetAnchor();
bv_->text()->cursorTop(cur);
break;
case LFUN_ENDBUFSEL:
- bv_->cursor().reset();
+ bv_->cursor().reset(bv_->buffer()->inset());
if (!cur.selection())
cur.resetAnchor();
bv_->text()->cursorBottom(cur);
+
+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
{}
-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;
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
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)
}
-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;
}
///
Paragraph(Paragraph const &);
///
- void operator=(Paragraph const &);
+ Paragraph & operator=(Paragraph const &);
///
~Paragraph();