Alfredo Braunstein wrote:

> I'll do the change.

Ok to commit? 

+ The above two fixes 
+ x0_ -> xo_ 
+ some cursorPar()->getRow(cursor.pos()) -> cursorRow

Alfredo
? bfri.C
Index: lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.256
diff -u -p -u -r1.256 lyxtext.h
--- lyxtext.h	20 Nov 2003 10:38:11 -0000	1.256
+++ lyxtext.h	21 Nov 2003 08:17:47 -0000
@@ -472,8 +472,8 @@ private:
 
 public:
 	/// absolute document pixel coordinates of this LyXText
-	int x0_;
-	int y0_;
+	int xo_;
+	int yo_;
 };
 
 /// return the default height of a row in pixels, considering font zoom
Index: rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.90
diff -u -p -u -r1.90 rowpainter.C
--- rowpainter.C	17 Nov 2003 20:28:09 -0000	1.90
+++ rowpainter.C	21 Nov 2003 08:17:51 -0000
@@ -993,12 +993,12 @@ int paintRows(BufferView const & bv, LyX
 				RowPainter painter(bv, text, pit, row, y + yo, xo, y + bv.top_y());
 				painter.paint();
 				y += row->height();
-				if (yy + y >= y2)
-					return y;
 			} else {
 				//lyxerr << "   paintRows: row: " << &*row << " ignored" << endl;
 			}
 		}
+		if (yy + y >= y2)
+			return y;
 	}
 
 	return y;
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.505
diff -u -p -u -r1.505 text2.C
--- text2.C	20 Nov 2003 17:10:54 -0000	1.505
+++ text2.C	21 Nov 2003 08:17:54 -0000
@@ -74,7 +74,7 @@ LyXText::LyXText(BufferView * bv, InsetT
 	  ParagraphList & paragraphs)
 	: height(0), width(0), inset_owner(inset), bv_owner(bv),
 	  in_inset_(ininset), paragraphs_(&paragraphs),
-	  cache_pos_(-1), x0_(0), y0_(0)
+	  cache_pos_(-1), xo_(0), yo_(0)
 {}
 
 
@@ -1300,6 +1300,7 @@ void LyXText::setCursor(LyXCursor & cur,
 
 	ParagraphList::iterator pit = getPar(par);
 	Row const & row = *pit->getRow(pos);
+
 	int y = pit->y + row.y_offset();
 
 	// y is now the beginning of the cursor row
@@ -1404,7 +1405,7 @@ void LyXText::setCursorIntern(paroffset_
 			      pos_type pos, bool setfont, bool boundary)
 {
 	setCursor(cursor, par, pos, boundary);
-	bv()->x_target(cursor.x() + x0_);
+	bv()->x_target(cursor.x() + xo_);
 	if (setfont)
 		setCurrentFont();
 }
@@ -1708,33 +1709,32 @@ bool LyXText::cursorRight(bool internal)
 
 void LyXText::cursorUp(bool selecting)
 {
-	ParagraphList::iterator cpit = cursorPar();
-	Row const & crow = *cpit->getRow(cursor.pos());
-	int x = bv()->x_target() - x0_;
-	int y = cursor.y() - crow.baseline() - 1;
+	Row const & row = *cursorRow();
+	int x = bv()->x_target() - xo_;
+	int y = cursor.y() - row.baseline() - 1;
 	setCursorFromCoordinates(x, y);
+	
 	if (!selecting) {
-		y += y0_ - bv()->top_y();
-		lyxerr << "y:" << y << " y0: " << y0_ << endl;
-		InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y);
+		int y_abs = y + yo_ - bv()->top_y();
+		InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y_abs);
 		if (inset_hit && isHighlyEditableInset(inset_hit))
-			inset_hit->edit(bv(), bv()->x_target(), y);
+			inset_hit->edit(bv(), bv()->x_target(), y_abs);
 	}
 }
 
 
 void LyXText::cursorDown(bool selecting)
 {
-	ParagraphList::iterator cpit = cursorPar();
-	Row const & crow = *cpit->getRow(cursor.pos());
-	int x = bv()->x_target() - x0_;
-	int y = cursor.y() - crow.baseline() + crow.height() + 1;
+	Row const & row = *cursorRow();
+	int x = bv()->x_target() - xo_;
+	int y = cursor.y() - row.baseline() + row.height() + 1;
 	setCursorFromCoordinates(x, y);
+
 	if (!selecting) {
-		y += y0_ - bv()->top_y();
-		InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y);
+		int y_abs = y + yo_ - bv()->top_y();
+		InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y_abs);
 		if (inset_hit && isHighlyEditableInset(inset_hit))
-			inset_hit->edit(bv(), bv()->x_target(), y);
+			inset_hit->edit(bv(), bv()->x_target(), y_abs);
 	}
 }
 
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.184
diff -u -p -u -r1.184 text3.C
--- text3.C	20 Nov 2003 10:38:12 -0000	1.184
+++ text3.C	21 Nov 2003 08:17:55 -0000
@@ -260,7 +260,8 @@ InsetOld * LyXText::checkInsetHit(int x,
 	ParagraphList::iterator end;
 
 	getParsInRange(ownerParagraphs(),
-		       bv()->top_y(), bv()->top_y() + bv()->workHeight(),
+		       bv()->top_y() - yo_,
+		       bv()->top_y() - yo_ + bv()->workHeight(),
 		       pit, end);
 	
 	lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
@@ -365,8 +366,8 @@ void LyXText::cursorPrevious()
 
 	RowList::iterator crit = cursorRow();
 
-	int x = bv()->x_target() - x0_;
-	int y = bv()->top_y() - y0_;
+	int x = bv()->x_target() - xo_;
+	int y = bv()->top_y() - yo_;
 	setCursorFromCoordinates(x, y);
 
 	if (crit == cursorRow()) {
@@ -384,8 +385,8 @@ void LyXText::cursorNext()
 {
 	RowList::iterator crit = cursorRow();
 
-	int x = bv()->x_target() - x0_;
-	int y = bv()->top_y() + bv()->workHeight() - y0_;
+	int x = bv()->x_target() - xo_;
+	int y = bv()->top_y() + bv()->workHeight() - yo_;
 	setCursorFromCoordinates(x, y);
 
 	if (crit == cursorRow()) {
@@ -1242,9 +1243,9 @@ DispatchResult LyXText::dispatch(FuncReq
 		// FIXME: shouldn't be top-text-specific
 		if (cursorrow == cursorRow() && !in_inset_) {
 			if (cmd.y - bv->top_y() >= bv->workHeight())
-				cursorDown(false);
+				cursorDown(true);
 			else if (cmd.y - bv->top_y() < 0)
-				cursorUp(false);
+				cursorUp(true);
 		}
 		setSelection();
 		break;
@@ -1292,7 +1293,7 @@ DispatchResult LyXText::dispatch(FuncReq
 		setCursorFromCoordinates(cmd.x, cmd.y);
 		selection.cursor = cursor;
 		finishUndo();
-		bv->x_target(cursor.x() + x0_);
+		bv->x_target(cursor.x() + xo_);
 
 		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.547
diff -u -p -u -r1.547 insettext.C
--- insets/insettext.C	20 Nov 2003 10:38:12 -0000	1.547
+++ insets/insettext.C	21 Nov 2003 08:17:59 -0000
@@ -258,8 +258,8 @@ void InsetText::draw(PainterInfo & pi, i
 
 	x += TEXT_TO_INSET_OFFSET;
 
-	text_.x0_ = x;
-	text_.y0_ = y - text_.firstRow()->ascent_of_text() + bv->top_y();
+	text_.xo_ = x;
+	text_.yo_ = y - text_.firstRow()->ascent_of_text() + bv->top_y();
 	
 	paintTextInset(*bv, text_, x, y);
 
@@ -344,8 +344,8 @@ void InsetText::edit(BufferView * bv, in
 	lyxerr << "InsetText::edit xy" << endl;
 	old_par = -1;
 	sanitizeEmptyText(bv);
-	text_.setCursorFromCoordinates(x - text_.x0_, y + bv->top_y()
-				       - text_.y0_);
+	text_.setCursorFromCoordinates(x - text_.xo_, y + bv->top_y()
+				       - text_.yo_);
 	text_.clearSelection();
 	finishUndo();
 

Reply via email to