Conceptually there is only one 'target x position' per BufferView, not one per inset. And the LyXCursors used for selection have not been using their x_fix at all.
Small step towards cursor globalization. [Finally we'd have one 'real' cursor per bv] Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)
Index: BufferView.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v retrieving revision 1.203 diff -u -p -r1.203 BufferView.C --- BufferView.C 20 Oct 2003 11:41:21 -0000 1.203 +++ BufferView.C 3 Nov 2003 17:34:50 -0000 @@ -56,7 +56,8 @@ extern BufferList bufferlist; BufferView::BufferView(LyXView * owner, int xpos, int ypos, int width, int height) - : pimpl_(new Pimpl(this, owner, xpos, ypos, width, height)) + : pimpl_(new Pimpl(this, owner, xpos, ypos, width, height)), + x_fix_(0) { text = 0; } @@ -579,4 +580,16 @@ void BufferView::haveSelection(bool sel) int BufferView::workHeight() const { return pimpl_->workarea().workHeight(); +} + + +void BufferView::x_fix(int x) +{ + x_fix_ = x; +} + + +int BufferView::x_fix() const +{ + return x_fix_; } Index: BufferView.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v retrieving revision 1.147 diff -u -p -r1.147 BufferView.h --- BufferView.h 6 Oct 2003 15:41:57 -0000 1.147 +++ BufferView.h 3 Nov 2003 17:34:51 -0000 @@ -201,6 +201,11 @@ public: /// execute the given function bool dispatch(FuncRequest const & argument); + + /// set target x position of cursor + void BufferView::x_fix(int x); + /// return target x position of cursor + int BufferView::x_fix() const; private: /// Set the current locking inset @@ -210,6 +215,21 @@ private: friend struct BufferView::Pimpl; Pimpl * pimpl_; + + /** + * The target x position of the cursor. This is used for when + * we have text like : + * + * blah blah blah blah| blah blah blah + * blah blah blah + * blah blah blah blah blah blah + * + * When we move onto row 3, we would like to be vertically aligned + * with where we were in row 1, despite the fact that row 2 is + * shorter than x() + */ + int x_fix_; + }; #endif // BUFFERVIEW_H Index: lyxcursor.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxcursor.C,v retrieving revision 1.26 diff -u -p -r1.26 lyxcursor.C --- lyxcursor.C 9 Oct 2003 10:52:07 -0000 1.26 +++ lyxcursor.C 3 Nov 2003 17:34:51 -0000 @@ -17,7 +17,7 @@ LyXCursor::LyXCursor() - : par_(-1), pos_(0), boundary_(false), x_(0), x_fix_(0), y_(0) + : par_(-1), pos_(0), boundary_(false), x_(0), y_(0) {} @@ -62,21 +62,10 @@ void LyXCursor::x(int n) x_ = n; } + int LyXCursor::x() const { return x_; -} - - -void LyXCursor::x_fix(int i) -{ - x_fix_ = i; -} - - -int LyXCursor::x_fix() const -{ - return x_fix_; } Index: lyxcursor.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxcursor.h,v retrieving revision 1.39 diff -u -p -r1.39 lyxcursor.h --- lyxcursor.h 9 Oct 2003 10:52:07 -0000 1.39 +++ lyxcursor.h 3 Nov 2003 17:34:51 -0000 @@ -45,21 +45,6 @@ public: void x(int i); /// return the x position in pixels int x() const; - /// set the cached x position - void x_fix(int i); - /** - * Return the cached x position of the cursor. This is used for when - * we have text like : - * - * blah blah blah blah| blah blah blah - * blah blah blah - * blah blah blah blah blah blah - * - * When we move onto row 3, we would like to be vertically aligned - * with where we were in row 1, despite the fact that row 2 is - * shorter than x() - */ - int x_fix() const; /// set the y position in pixels void y(int i); /// return the y position in pixels @@ -88,8 +73,6 @@ private: bool boundary_; /// the pixel x position int x_; - /// the cached x position - int x_fix_; /// the pixel y position int y_; }; Index: lyxfunc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v retrieving revision 1.530 diff -u -p -r1.530 lyxfunc.C --- lyxfunc.C 1 Nov 2003 15:45:14 -0000 1.530 +++ lyxfunc.C 3 Nov 2003 17:34:51 -0000 @@ -963,7 +963,7 @@ void LyXFunc::dispatch(FuncRequest const text->cursor.x() + inset_x, text->cursor.y() - row.baseline() - 1); - text->cursor.x_fix(text->cursor.x()); + view()->x_fix(text->cursor.x()); #else text->cursorUp(view()); #endif @@ -986,7 +986,7 @@ void LyXFunc::dispatch(FuncRequest const text->cursor.y() - row.baseline() + row.height() + 1); - text->cursor.x_fix(text->cursor.x()); + view()->x_fix(text->cursor.x()); #else text->cursorDown(view()); #endif Index: text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.490 diff -u -p -r1.490 text2.C --- text2.C 29 Oct 2003 10:47:14 -0000 1.490 +++ text2.C 3 Nov 2003 17:34:51 -0000 @@ -1339,9 +1339,8 @@ void LyXText::setCursor(LyXCursor & cur, BOOST_ASSERT(false); } // now get the cursors x position - float x = getCursorX(pit, row, pos, boundary); - cur.x(int(x)); - cur.x_fix(cur.x()); + cur.x(int(getCursorX(pit, row, pos, boundary))); + bv()->x_fix(cur.x()); } @@ -1620,7 +1619,7 @@ void LyXText::cursorUp(bool selecting) ParagraphList::iterator cpit = cursorPar(); Row const & crow = *cpit->getRow(cursor.pos()); #if 1 - int x = cursor.x_fix(); + int x = bv()->x_fix(); int y = cursor.y() - crow.baseline() - 1; setCursorFromCoordinates(x, y); if (!selecting) { @@ -1637,7 +1636,7 @@ void LyXText::cursorUp(bool selecting) #else lyxerr << "cursorUp: y " << cursor.y() << " bl: " << crow.baseline() << endl; - setCursorFromCoordinates(cursor.x_fix(), + setCursorFromCoordinates(bv()->x_fix(), cursor.y() - crow.baseline() - 1); #endif } @@ -1648,7 +1647,7 @@ void LyXText::cursorDown(bool selecting) ParagraphList::iterator cpit = cursorPar(); Row const & crow = *cpit->getRow(cursor.pos()); #if 1 - int x = cursor.x_fix(); + int x = bv()->x_fix(); int y = cursor.y() - crow.baseline() + crow.height() + 1; setCursorFromCoordinates(x, y); if (!selecting) { @@ -1663,7 +1662,7 @@ void LyXText::cursorDown(bool selecting) } } #else - setCursorFromCoordinates(cursor.x_fix(), + setCursorFromCoordinates(bv()->x_fix(), cursor.y() - crow.baseline() + crow.height() + 1); #endif } Index: text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.166 diff -u -p -r1.166 text3.C --- text3.C 1 Nov 2003 15:45:14 -0000 1.166 +++ text3.C 3 Nov 2003 17:34:51 -0000 @@ -260,7 +260,7 @@ void LyXText::cursorPrevious() return; } - setCursorFromCoordinates(cursor.x_fix(), y); + setCursorFromCoordinates(bv()->x_fix(), y); finishUndo(); if (crit == bv()->text->cursorRow()) { @@ -313,7 +313,7 @@ void LyXText::cursorNext() Row const & rr = *getRowNearY(y, dummypit); y = dummypit->y + rr.y_offset(); - setCursorFromCoordinates(cursor.x_fix(), y); + setCursorFromCoordinates(bv()->x_fix(), y); // + bv->workHeight()); finishUndo(); @@ -1326,7 +1326,7 @@ DispatchResult LyXText::dispatch(FuncReq bv->text->setCursorFromCoordinates(x, y + screen_first); finishUndo(); bv->text->selection.cursor = bv->text->cursor; - bv->text->cursor.x_fix(bv->text->cursor.x()); + bv->x_fix(bv->text->cursor.x()); if (bv->fitCursor()) selection_possible = false; Index: insets/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.522 diff -u -p -r1.522 insettext.C --- insets/insettext.C 3 Nov 2003 16:46:43 -0000 1.522 +++ insets/insettext.C 3 Nov 2003 17:34:51 -0000 @@ -512,7 +512,7 @@ void InsetText::lfunMousePress(FuncReque text_.setCursorFromCoordinates(cmd.x, cmd.y + dim_.asc); // set the selection cursor! text_.selection.cursor = text_.cursor; - text_.cursor.x_fix(text_.cursor.x()); + bv->x_fix(text_.cursor.x()); text_.clearSelection(); updateLocal(bv, false); @@ -584,7 +584,7 @@ void InsetText::lfunMouseMotion(FuncRequ BufferView * bv = cmd.view(); LyXCursor cur = text_.cursor; text_.setCursorFromCoordinates (cmd.x, cmd.y + dim_.asc); - text_.cursor.x_fix(text_.cursor.x()); + bv->x_fix(text_.cursor.x()); if (cur == text_.cursor) return; text_.setSelection(); @@ -632,7 +632,7 @@ InsetText::priv_dispatch(FuncRequest con if (!checkAndActivateInset(bv, cmd.x, tmp_y, mouse_button::none)) { text_.setCursorFromCoordinates(cmd.x, cmd.y + dim_.asc); text_.cursor.x(text_.cursor.x()); - text_.cursor.x_fix(text_.cursor.x()); + bv->x_fix(text_.cursor.x()); } }