This patch from Félix-Antoine Bourbonnais makes sure that
cursorBegin/End and cursorTop/Bottom correctly return their dEPM
status. This fixes frawing problems when dEPM triggers.

I tested it and it does what it says. Applying now.

JMarc

Index: src/ChangeLog
===================================================================
--- src/ChangeLog	(revision 13390)
+++ src/ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2006-03-16  Félix-Antoine Bourbonnais  <[EMAIL PROTECTED]>
+
+	* text3.C (dispatch): set needsUpdate according to the return
+	value of the methods below (bug 2298)
+
+	* text2.C (cursorTop, cursorBottom, cursorHome, cursorEnd): return
+	true if dEPM triggered.
+
 2006-03-16  John Spray  <[EMAIL PROTECTED]>
 
 	* lyxfunc.C (getStatus): disable LFUN_MENUWRITE when document is
Index: src/text2.C
===================================================================
--- src/text2.C	(revision 13389)
+++ src/text2.C	(working copy)
@@ -476,16 +476,16 @@
 // the cursor set functions have a special mechanism. When they
 // realize you left an empty paragraph, they will delete it.
 
-void LyXText::cursorHome(LCursor & cur)
+bool LyXText::cursorHome(LCursor & cur)
 {
 	BOOST_ASSERT(this == cur.text());
 	Row const & row = cur.paragraph().getRow(cur.pos(),cur.boundary());
 
-	setCursor(cur, cur.pit(), row.pos());
+	return setCursor(cur, cur.pit(), row.pos());
 }
 
 
-void LyXText::cursorEnd(LCursor & cur)
+bool LyXText::cursorEnd(LCursor & cur)
 {
 	BOOST_ASSERT(this == cur.text());
 	// if not on the last row of the par, put the cursor before
@@ -494,7 +494,7 @@
 	pos_type end = cur.textRow().endpos();
 	if (end == 0)
 		// empty text, end-1 is no valid position
-		return;
+		return false;
 	bool boundary = false;
 	if (end != cur.lastpos()) {
 		if (!cur.paragraph().isLineSeparator(end-1)
@@ -503,21 +503,21 @@
 		else
 			--end;
 	}
-	setCursor(cur, cur.pit(), end, true, boundary);
+	return setCursor(cur, cur.pit(), end, true, boundary);
 }
 
 
-void LyXText::cursorTop(LCursor & cur)
+bool LyXText::cursorTop(LCursor & cur)
 {
 	BOOST_ASSERT(this == cur.text());
-	setCursor(cur, 0, 0);
+	return setCursor(cur, 0, 0);
 }
 
 
-void LyXText::cursorBottom(LCursor & cur)
+bool LyXText::cursorBottom(LCursor & cur)
 {
 	BOOST_ASSERT(this == cur.text());
-	setCursor(cur, cur.lastpit(), boost::prior(paragraphs().end())->size());
+	return setCursor(cur, cur.lastpit(), boost::prior(paragraphs().end())->size());
 }
 
 
Index: src/lyxtext.h
===================================================================
--- src/lyxtext.h	(revision 13389)
+++ src/lyxtext.h	(working copy)
@@ -209,17 +209,17 @@
 	///
 	bool cursorDownParagraph(LCursor & cur);
 	///
-	void cursorHome(LCursor & cur);
+	bool cursorHome(LCursor & cur);
 	///
-	void cursorEnd(LCursor & cur);
+	bool cursorEnd(LCursor & cur);
 	///
 	bool cursorPrevious(LCursor & cur);
 	///
 	bool cursorNext(LCursor & cur);
 	///
-	void cursorTop(LCursor & cur);
+	bool cursorTop(LCursor & cur);
 	///
-	void cursorBottom(LCursor & cur);
+	bool cursorBottom(LCursor & cur);
 	///
 	bool Delete(LCursor & cur);
 	///
Index: src/text3.C
===================================================================
--- src/text3.C	(revision 13389)
+++ src/text3.C	(working copy)
@@ -387,7 +387,7 @@
 		if (cur.depth() == 1) {
 			if (!cur.mark())
 				cur.clearSelection();
-			cursorTop(cur);
+			needsUpdate = cursorTop(cur);
 			finishChange(cur, false);
 		} else {
 			cur.undispatched();
@@ -398,7 +398,7 @@
 		if (cur.depth() == 1) {
 			if (!cur.selection())
 				cur.resetAnchor();
-			cursorTop(cur);
+			needsUpdate = cursorTop(cur);
 			finishChange(cur, true);
 		} else {
 			cur.undispatched();
@@ -409,7 +409,7 @@
 		if (cur.depth() == 1) {
 			if (!cur.mark())
 				cur.clearSelection();
-			cursorBottom(cur);
+			needsUpdate = cursorBottom(cur);
 			finishChange(cur, false);
 		} else {
 			cur.undispatched();
@@ -420,7 +420,7 @@
 		if (cur.depth() == 1) {
 			if (!cur.selection())
 				cur.resetAnchor();
-			cursorBottom(cur);
+			needsUpdate = cursorBottom(cur);
 			finishChange(cur, true);
 		} else {
 			cur.undispatched();
@@ -520,7 +520,7 @@
 		update(cur);
 		if (!cur.selection())
 			cur.resetAnchor();
-		cursorPrevious(cur);
+		needsUpdate = cursorPrevious(cur);
 		finishChange(cur, true);
 		break;
 
@@ -528,7 +528,7 @@
 		update(cur);
 		if (!cur.selection())
 			cur.resetAnchor();
-		cursorNext(cur);
+		needsUpdate = cursorNext(cur);
 		finishChange(cur, true);
 		break;
 
@@ -536,7 +536,7 @@
 		update(cur);
 		if (!cur.selection())
 			cur.resetAnchor();
-		cursorHome(cur);
+		needsUpdate = cursorHome(cur);
 		finishChange(cur, true);
 		break;
 
@@ -544,7 +544,7 @@
 		update(cur);
 		if (!cur.selection())
 			cur.resetAnchor();
-		cursorEnd(cur);
+		needsUpdate = cursorEnd(cur);
 		finishChange(cur, true);
 		break;
 
@@ -604,14 +604,14 @@
 	case LFUN_HOME:
 		if (!cur.mark())
 			cur.clearSelection();
-		cursorHome(cur);
+		needsUpdate = cursorHome(cur);
 		finishChange(cur, false);
 		break;
 
 	case LFUN_END:
 		if (!cur.mark())
 			cur.clearSelection();
-		cursorEnd(cur);
+		needsUpdate = cursorEnd(cur);
 		finishChange(cur, false);
 		break;
 

Reply via email to