Andre Poenitz wrote:

>> [I think that the problem with target_x_ is that it is updated *too
>> [much*,
>> and thus it is completely in-sync with the cursor (and thus useless).
>> I'll have a look at it.]
> 
> Might be true...

It was.

This patch solves this, + some bv() -> true (except in moveUp/Down, where it
was set to false to allow entering insets)

[another problem: we should set x_target in absolute coordinates, but we do
it within LyXText, and LyXText doesn't kown it's own absolute x coords.
Maybe it should?]

Alfredo
Index: cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
retrieving revision 1.22
diff -u -p -u -r1.22 cursor.C
--- cursor.C	14 Nov 2003 18:15:58 -0000	1.22
+++ cursor.C	18 Nov 2003 11:15:47 -0000
@@ -120,7 +120,7 @@ void LCursor::push(UpdatableInset * inse
 {
 	lyxerr << "LCursor::push()  inset: " << inset << endl;
 	data_.push_back(CursorItem(inset));
-	cached_y_ = bv_->top_y() + innerInset()->y();
+	updatePos();
 }
 
 
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.502
diff -u -p -u -r1.502 text2.C
--- text2.C	17 Nov 2003 20:28:09 -0000	1.502
+++ text2.C	18 Nov 2003 11:15:52 -0000
@@ -257,7 +257,7 @@ void LyXText::toggleInset()
 		    && inset_owner->owner()->isOpen()) {
 			finishUndo();
 			inset_owner->owner()->close(bv());
-			bv()->getLyXText()->cursorRight(bv());
+			bv()->getLyXText()->cursorRight(true);
 			bv()->updateParagraphDialog();
 		}
 		return;
@@ -1175,7 +1175,7 @@ void LyXText::setSelectionRange(lyx::pos
 
 	selection.cursor = cursor;
 	while (length--)
-		cursorRight(bv());
+		cursorRight(true);
 	setSelection();
 }
 
@@ -1340,7 +1340,6 @@ void LyXText::setCursor(LyXCursor & cur,
 	}
 	// now get the cursors x position
 	cur.x(int(getCursorX(pit, row, pos, boundary)));
-	bv()->x_target(cur.x());
 }
 
 
@@ -1405,6 +1404,7 @@ void LyXText::setCursorIntern(paroffset_
 			      pos_type pos, bool setfont, bool boundary)
 {
 	setCursor(cursor, par, pos, boundary);
+	bv()->x_target(cursor.x());
 	if (setfont)
 		setCurrentFont();
 }
@@ -1620,7 +1620,7 @@ DispatchResult LyXText::moveRightIntern(
 		return DispatchResult(false, FINISHED_RIGHT);
 	if (activate_inset && checkAndActivateInset(front))
 		return DispatchResult(true, true);
-	cursorRight(bv());
+	cursorRight(true);
 	if (!selecting)
 		clearSelection();
 	return DispatchResult(true);
@@ -1632,7 +1632,7 @@ DispatchResult LyXText::moveLeftIntern(b
 {
 	if (cursor.par() == 0 && cursor.pos() <= 0)
 		return DispatchResult(false, FINISHED);
-	cursorLeft(bv());
+	cursorLeft(true);
 	if (!selecting)
 		clearSelection();
 	if (activate_inset && checkAndActivateInset(front))
@@ -1645,7 +1645,7 @@ DispatchResult LyXText::moveUp()
 {
 	if (cursorRow() == firstRow())
 		return DispatchResult(false, FINISHED_UP);
-	cursorUp(bv());
+	cursorUp(false);
 	clearSelection();
 	return DispatchResult(true);
 }
@@ -1655,7 +1655,7 @@ DispatchResult LyXText::moveDown()
 {
 	if (cursorRow() == lastRow())
 		return DispatchResult(false, FINISHED_DOWN);
-	cursorDown(bv());
+	cursorDown(false);
 	clearSelection();
 	return DispatchResult(true);
 }
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.182
diff -u -p -u -r1.182 text3.C
--- text3.C	17 Nov 2003 20:28:10 -0000	1.182
+++ text3.C	18 Nov 2003 11:15:54 -0000
@@ -1585,13 +1585,13 @@ DispatchResult LyXText::dispatch(FuncReq
 	case LFUN_FINISHED_LEFT:
 		lyxerr << "swallow LFUN_FINISHED_LEFT" << endl;
 		if (rtl())
-			cursorRight(bv);
+			cursorRight(true);
 		break;
 
 	case LFUN_FINISHED_RIGHT:
 		lyxerr << "swallow LFUN_FINISHED_RIGHT" << endl;
 		if (!rtl())
-			cursorRight(bv);
+			cursorRight(true);
 		break;
 
 	case LFUN_FINISHED_UP:
@@ -1600,7 +1600,7 @@ DispatchResult LyXText::dispatch(FuncReq
 
 	case LFUN_FINISHED_DOWN:
 		lyxerr << "swallow LFUN_FINISHED_DOWN" << endl;
-		cursorRight(bv);
+		cursorRight(true);
 		break;
 
 	default:

Reply via email to