The following patch is the result of a simple s/bv_->cursor()/cursor_/ on BufferView_pimpl.C. Indeed, BufferView::cursor() is defined as:
LCursor & BufferView::cursor() { return pimpl_->cursor_; } LCursor const & BufferView::cursor() const { return pimpl_->cursor_; } Therefore, the patch does not change anything functionally, but avoids a silly roundtrip (and makes code clearer IMO). If this kind of cleanup is welcome, the following on the list are bv_->buffer(), bv_->owner() and bv_->isSavedPosition(i). Comments? JMarc
Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.2111 diff -u -p -r1.2111 ChangeLog --- src/ChangeLog 7 Feb 2005 10:01:42 -0000 1.2111 +++ src/ChangeLog 7 Feb 2005 13:25:37 -0000 @@ -1,3 +1,8 @@ +2005-02-07 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * BufferView_pimpl.C: replace all occurences of bv_->cursor() by + cursor_. + 2005-02-07 Georg Baum <[EMAIL PROTECTED]> * CutAndPaste.C (pasteSelectionHelper): fix a crash Index: src/BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.573 diff -u -p -r1.573 BufferView_pimpl.C --- src/BufferView_pimpl.C 6 Feb 2005 00:30:11 -0000 1.573 +++ src/BufferView_pimpl.C 7 Feb 2005 13:25:37 -0000 @@ -419,7 +419,7 @@ void BufferView::Pimpl::updateScrollbar( lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION << " Updating scrollbar: height: " << t.paragraphs().size() - << " curr par: " << bv_->cursor().bottom().pit() + << " curr par: " << cursor_.bottom().pit() << " default height " << defaultRowHeight() << endl; // It would be better to fix the scrollbar to understand @@ -459,7 +459,7 @@ void BufferView::Pimpl::scrollDocView(in int const height = 2 * defaultRowHeight(); int const first = height; int const last = workarea().workHeight() - height; - LCursor & cur = bv_->cursor(); + LCursor & cur = cursor_; bv_funcs::CurStatus st = bv_funcs::status(bv_, cur); @@ -532,7 +532,7 @@ void BufferView::Pimpl::selectionRequest if (!available()) return; - LCursor & cur = bv_->cursor(); + LCursor & cur = cursor_; if (!cur.selection()) { xsel_cache_.set = false; @@ -557,7 +557,7 @@ void BufferView::Pimpl::selectionLost() { if (available()) { screen().hideCursor(); - bv_->cursor().clearSelection(); + cursor_.clearSelection(); xsel_cache_.set = false; } } @@ -591,11 +591,11 @@ void BufferView::Pimpl::workAreaResize() bool BufferView::Pimpl::fitCursor() { - if (bv_funcs::status(bv_, bv_->cursor()) == bv_funcs::CUR_INSIDE) { - LyXFont const font = bv_->cursor().getFont(); + if (bv_funcs::status(bv_, cursor_) == bv_funcs::CUR_INSIDE) { + LyXFont const font = cursor_.getFont(); int const asc = font_metrics::maxAscent(font); int const des = font_metrics::maxDescent(font); - Point p = bv_funcs::getPos(bv_->cursor()); + Point p = bv_funcs::getPos(cursor_); if (p.y_ - asc >= 0 && p.y_ + des < bv_->workHeight()) return false; } @@ -673,7 +673,7 @@ Change const BufferView::Pimpl::getCurre return Change(Change::UNCHANGED); LyXText * text = bv_->getLyXText(); - LCursor & cur = bv_->cursor(); + LCursor & cur = cursor_; if (!cur.selection()) return Change(Change::UNCHANGED); @@ -687,10 +687,10 @@ void BufferView::Pimpl::savePosition(uns { if (i >= saved_positions_num) return; - BOOST_ASSERT(bv_->cursor().inTexted()); + BOOST_ASSERT(cursor_.inTexted()); saved_positions[i] = Position(buffer_->fileName(), - bv_->cursor().paragraph().id(), - bv_->cursor().pos()); + cursor_.paragraph().id(), + cursor_.pos()); if (i > 0) owner_->message(bformat(_("Saved bookmark %1$d"), i)); } @@ -703,7 +703,7 @@ void BufferView::Pimpl::restorePosition( string const fname = saved_positions[i].filename; - bv_->cursor().clearSelection(); + cursor_.clearSelection(); if (fname != buffer_->fileName()) { Buffer * b = 0; @@ -722,7 +722,7 @@ void BufferView::Pimpl::restorePosition( if (par == buffer_->par_iterator_end()) return; - bv_->text()->setCursor(bv_->cursor(), par.pit(), + bv_->text()->setCursor(cursor_, par.pit(), min(par->size(), saved_positions[i].par_pos)); if (i > 0) @@ -754,12 +754,12 @@ void BufferView::Pimpl::switchKeyMap() void BufferView::Pimpl::center() { - CursorSlice & bot = bv_->cursor().bottom(); + CursorSlice & bot = cursor_.bottom(); lyx::pit_type const pit = bot.pit(); bot.text()->redoParagraph(pit); Paragraph const & par = bot.text()->paragraphs()[pit]; anchor_ref_ = pit; - offset_ref_ = bv_funcs::coordOffset(bv_->cursor()).y_ + par.ascent() + offset_ref_ = bv_funcs::coordOffset(cursor_).y_ + par.ascent() - workarea().workHeight() / 2; } @@ -816,13 +816,13 @@ void BufferView::Pimpl::MenuInsertLyXFil string const disp_fn = MakeDisplayPath(filename); owner_->message(bformat(_("Inserting document %1$s..."), disp_fn)); - bv_->cursor().clearSelection(); - bv_->getLyXText()->breakParagraph(bv_->cursor()); + cursor_.clearSelection(); + bv_->getLyXText()->breakParagraph(cursor_); - BOOST_ASSERT(bv_->cursor().inTexted()); + BOOST_ASSERT(cursor_.inTexted()); string const fname = MakeAbsPath(filename); - bool const res = bv_->buffer()->readFile(fname, bv_->cursor().pit()); + bool const res = bv_->buffer()->readFile(fname, cursor_.pit()); bv_->resize(); string s = res ? _("Document %1$s inserted.") @@ -846,7 +846,7 @@ void BufferView::Pimpl::trackChanges() buf->undostack().clear(); } else { update(); - bv_->text()->setCursor(bv_->cursor(), 0, 0); + bv_->text()->setCursor(cursor_, 0, 0); #ifdef WITH_WARNINGS #warning changes FIXME #endif @@ -887,7 +887,7 @@ bool BufferView::Pimpl::workAreaDispatch LCursor cur(*bv_); cur.push(bv_->buffer()->inset()); - cur.selection() = bv_->cursor().selection(); + cur.selection() = cursor_.selection(); // Doesn't go through lyxfunc, so we need to update // the layout choice etc. ourselves @@ -1024,7 +1024,7 @@ bool BufferView::Pimpl::dispatch(FuncReq << " button[" << cmd.button() << ']' << endl; - LCursor & cur = bv_->cursor(); + LCursor & cur = cursor_; switch (cmd.action) { @@ -1078,7 +1078,7 @@ bool BufferView::Pimpl::dispatch(FuncReq string label = cmd.argument; if (label.empty()) { InsetRef * inset = - getInsetByCode<InsetRef>(bv_->cursor(), + getInsetByCode<InsetRef>(cursor_, InsetBase::REF_CODE); if (inset) { label = inset->getContents(); @@ -1107,23 +1107,23 @@ bool BufferView::Pimpl::dispatch(FuncReq break; case LFUN_ACCEPT_ALL_CHANGES: { - bv_->cursor().reset(bv_->buffer()->inset()); + cursor_.reset(bv_->buffer()->inset()); #ifdef WITH_WARNINGS #warning FIXME changes #endif while (lyx::find::findNextChange(bv_)) - bv_->getLyXText()->acceptChange(bv_->cursor()); + bv_->getLyXText()->acceptChange(cursor_); update(); break; } case LFUN_REJECT_ALL_CHANGES: { - bv_->cursor().reset(bv_->buffer()->inset()); + cursor_.reset(bv_->buffer()->inset()); #ifdef WITH_WARNINGS #warning FIXME changes #endif while (lyx::find::findNextChange(bv_)) - bv_->getLyXText()->rejectChange(bv_->cursor()); + bv_->getLyXText()->rejectChange(cursor_); break; }