in favour of BufferView::setCursor(ParIterator &, lyx::pos_type) The lockPath name is really out of context now (remember *lock* ;-) ? ) and it doesn't belong really to ParIterator.
Ok to go in? Alfredo Index: BufferView.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v retrieving revision 1.224 diff -u -p -u -r1.224 BufferView.C --- BufferView.C 28 Jan 2004 16:21:23 -0000 1.224 +++ BufferView.C 2 Feb 2004 09:57:11 -0000 @@ -444,6 +444,19 @@ LyXText * BufferView::text() const } +void BufferView::setCursor(ParIterator const & par, + lyx::pos_type pos) +{ + LCursor & cur = cursor(); + cur.reset(); + 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 * lt = par.text(*buffer()); + lt->setCursor(par.pit(), pos); +} /* @@ -468,7 +481,8 @@ void BufferView::putSelectionAt(PosItera cursor().clearSelection(); LyXText * text = par.text(*buffer()); - par.lockPath(this); + setCursor(par, cur.pos()); + // hack for the chicken and egg problem if (par.inset()) top_y(par.outerPar()->y); Index: BufferView.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v retrieving revision 1.161 diff -u -p -u -r1.161 BufferView.h --- BufferView.h 26 Jan 2004 10:13:06 -0000 1.161 +++ BufferView.h 2 Feb 2004 09:57:11 -0000 @@ -15,6 +15,8 @@ #ifndef BUFFER_VIEW_H #define BUFFER_VIEW_H +#include "support/types.h" + #include <boost/utility.hpp> #include <string> @@ -32,6 +34,7 @@ class LyXText; class LyXScreen; class LyXView; class Painter; +class ParIterator; class PosIterator; class TeXErrors; class UpdatableInset; @@ -189,6 +192,8 @@ public: LCursor const & cursor() const; /// LyXText * text() const; + /// + void setCursor(ParIterator const & par, lyx::pos_type pos); /// void putSelectionAt(PosIterator const & cur, int length, bool backwards); Index: BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.493 diff -u -p -u -r1.493 BufferView_pimpl.C --- BufferView_pimpl.C 30 Jan 2004 11:40:56 -0000 1.493 +++ BufferView_pimpl.C 2 Feb 2004 09:57:13 -0000 @@ -933,8 +933,8 @@ bool BufferView::Pimpl::workAreaDispatch screen().hideCursor(); - // either the inset under the cursor or the surrounding LyXText will - // handle this event. + // either the inset under the cursor or the + // surrounding LyXText will handle this event. // built temporary path to inset LyXText * text = bv_->text(); Index: iterators.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/iterators.C,v retrieving revision 1.42 diff -u -p -u -r1.42 iterators.C --- iterators.C 2 Feb 2004 08:55:44 -0000 1.42 +++ iterators.C 2 Feb 2004 09:57:13 -0000 @@ -221,17 +221,6 @@ ParIterator::ParIterator(PosIterator con } -void ParIterator::lockPath(BufferView * bv) const -{ - LCursor & cur = bv->cursor(); - cur.reset(); - int const last = size() - 1; - for (int i = 0; i < last; ++i) - (*positions_[i].it)->inset->edit(cur, true); - cur.resetAnchor(); -} - - bool operator==(ParIterator const & iter1, ParIterator const & iter2) { return iter1.positions() == iter2.positions(); Index: iterators.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/iterators.h,v retrieving revision 1.28 diff -u -p -u -r1.28 iterators.h --- iterators.h 27 Jan 2004 15:14:34 -0000 1.28 +++ iterators.h 2 Feb 2004 09:57:13 -0000 @@ -78,8 +78,6 @@ public: int index() const; /// size_t size() const; - /// - void lockPath(BufferView *) const; typedef std::vector<ParPosition> PosHolder; PosHolder const & positions() const Index: lyxfunc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v retrieving revision 1.564 diff -u -p -u -r1.564 lyxfunc.C --- lyxfunc.C 30 Jan 2004 11:40:57 -0000 1.564 +++ lyxfunc.C 2 Feb 2004 09:57:16 -0000 @@ -1164,11 +1164,9 @@ void LyXFunc::dispatch(FuncRequest const << " found." << endl; } - par.lockPath(view()); - LyXText * lt = par.text(*view()->buffer()); - // Set the cursor - lt->setCursor(par.pit(), 0); + view()->setCursor(par, 0); + view()->switchKeyMap(); owner->view_state_changed(); Index: undo.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/undo.C,v retrieving revision 1.37 diff -u -p -u -r1.37 undo.C --- undo.C 2 Feb 2004 08:55:44 -0000 1.37 +++ undo.C 2 Feb 2004 09:57:16 -0000 @@ -183,8 +183,9 @@ bool performUndoOrRedo(BufferView * bv, // rebreak the entire lyxtext buf.text().fullRebreak(); - pit.lockPath(bv); - text->setCursor(undo.cursor_par, undo.cursor_pos); + ParIterator pit2 = num2pit(buf, undo.text); + advance(pit2, undo.cursor_par); + bv->setCursor(pit2, undo.cursor_pos); finishUndo(); return true;