The main thing to realize is that iterators from different containers
cannot be compared.

With a couple of changes the Gcc 3.4 debug mode does not complain much
about cursor movement anymore, I have not begun to look into undo/cAp
yet.

This patch takes care of most of the cursor movement errors.

btw. On a semi-highspeed link vnc is great for running things remote.
a lot better than running with a remove xserver.

? 34debug.diff
? Config
? cursormove.diff
? postype-1.diff
? textcache.diff
Index: config/lyxinclude.m4
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/config/lyxinclude.m4,v
retrieving revision 1.89
diff -u -p -r1.89 lyxinclude.m4
--- config/lyxinclude.m4	16 Sep 2003 15:23:54 -0000	1.89
+++ config/lyxinclude.m4	22 Nov 2003 13:13:31 -0000
@@ -216,7 +216,7 @@ if test x$GXX = xyes; then
       *)       CXXFLAGS="$lyx_opt";;
     esac
     if test x$enable_debug = xyes ; then
-	CXXFLAGS="-g $CXXFLAGS"
+	CXXFLAGS="-g -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC $CXXFLAGS"
     fi
   fi
   if test x$enable_warnings = xyes ; then
Index: src/lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.258
diff -u -p -r1.258 lyxtext.h
--- src/lyxtext.h	21 Nov 2003 11:16:36 -0000	1.258
+++ src/lyxtext.h	22 Nov 2003 13:13:32 -0000
@@ -49,23 +49,16 @@ class VSpace;
 // The inheritance from TextCursor should go. It's just there to ease
 // transition...
 class LyXText : public TextCursor {
+	// Public Functions
 public:
 	/// Constructor
 	LyXText(BufferView *, InsetText *, bool ininset, ParagraphList & plist);
 
+	// Copy-constructor
+	LyXText & operator=(LyXText const &);
+
 	void init(BufferView *);
-	///
-	int height;
-	///
-	unsigned int width;
-	/// the current font settings
-	LyXFont current_font;
-	/// the current font
-	LyXFont real_current_font;
-	/// our buffer's default layout font
-	LyXFont defaultfont_;
-	///
-	InsetText * inset_owner;
+
 
 	/// update all cached row positions
 	void updateRowPositions();
@@ -120,10 +113,6 @@ public:
 
 	/// rebreaks the cursor par
 	void redoParagraph();
-private:
-	/// rebreaks the given par
-	void redoParagraphInternal(ParagraphList::iterator pit);
-public:
 
 	///
 	void toggleFree(LyXFont const &, bool toggleall = false);
@@ -152,10 +141,6 @@ public:
 
 	friend class LyXScreen;
 
-public:
-	/// only the top-level LyXText has this non-zero
-	BufferView * bv_owner;
-
 	/// returns an iterator pointing to a cursor paragraph
 	ParagraphList::iterator getPar(LyXCursor const & cursor) const;
 	///
@@ -320,24 +305,6 @@ public:
 	///
 	int workWidth() const;
 
-private:
-	///
-	float getCursorX(ParagraphList::iterator pit,
-	     Row const & row, lyx::pos_type pos, bool boundary) const;
-	/// used in setlayout
-	void makeFontEntriesLayoutSpecific(BufferParams const &, Paragraph & par);
-
-	/// Calculate and set the height of the row
-	void setHeightOfRow(ParagraphList::iterator, Row & row);
-
-	// fix the cursor `cur' after a characters has been deleted at `where'
-	// position. Called by deleteEmptyParagraphMechanism
-	void fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where);
-
-	/// delete double space (false) or empty paragraphs (true) around old_cursor
-	bool deleteEmptyParagraphMechanism(LyXCursor const & old_cursor);
-
-public:
 	/** Updates all counters starting BEHIND the row. Changed paragraphs
 	 * with a dynamic left margin will be rebroken. */
 	void updateCounters();
@@ -369,46 +336,6 @@ public:
 	 * the cursor and when creating a visible row */
 	void prepareToPrint(ParagraphList::iterator pit, Row & row) const;
 
-private:
-	///
-	void setCounter(Buffer const &, ParagraphList::iterator pit);
-	///
-	void deleteWordForward();
-	///
-	void deleteWordBackward();
-	///
-	void deleteLineForward();
-
-	/// sets row.end to the pos value *after* which a row should break.
-	/// for example, the pos after which isNewLine(pos) == true
-	void rowBreakPoint(ParagraphList::iterator pit, Row & row) const;
-
-	/// sets row.witdh to the minimum space a row needs on the screen in pixel
-	void fill(ParagraphList::iterator pit, Row & row, int workwidth) const;
-
-	/**
-	 * returns the minimum space a manual label needs on the
-	 * screen in pixels
-	 */
-	int labelFill(ParagraphList::iterator pit, Row const & row) const;
-
-	/// FIXME
-	int labelEnd(ParagraphList::iterator pit, Row const & row) const;
-
-	///
-	void charInserted();
-	/// set 'number' font property
-	void number();
-	/// is the cursor paragraph right-to-left?
-	bool rtl() const;
-
-public:
-	///
-	mutable Bidi bidi;
-	///
-	bool in_inset_;
-	///
-	ParagraphList * paragraphs_;
 	//
 	// special owner functions
 	///
@@ -417,6 +344,13 @@ public:
 	/// return true if this is owned by an inset.
 	bool isInInset() const;
 
+	///
+	ParagraphList::iterator firstPar() const;
+	///
+	ParagraphList::iterator lastPar() const;
+	///
+	ParagraphList::iterator endPar() const;
+	
 	/// return first row of text
 	RowList::iterator firstRow() const;
 	/// return last row of text
@@ -461,6 +395,91 @@ public:
 	///
 	bool checkAndActivateInset(bool front);
 
+
+	// Public Variables
+public:
+	///
+	int height;
+	///
+	unsigned int width;
+	/// the current font settings
+	LyXFont current_font;
+	/// the current font
+	LyXFont real_current_font;
+	/// our buffer's default layout font
+	LyXFont defaultfont_;
+	///
+	InsetText * inset_owner;
+
+	/// only the top-level LyXText has this non-zero
+	BufferView * bv_owner;
+
+	///
+	mutable Bidi bidi;
+	///
+	bool in_inset_;
+	///
+	ParagraphList * paragraphs_;
+
+	/// absolute document pixel coordinates of this LyXText
+	int xo_;
+	int yo_;
+
+
+	// Private Functions
+private:
+	/// rebreaks the given par
+	void redoParagraphInternal(ParagraphList::iterator pit);
+
+	///
+	float getCursorX(ParagraphList::iterator pit,
+	     Row const & row, lyx::pos_type pos, bool boundary) const;
+	/// used in setlayout
+	void makeFontEntriesLayoutSpecific(BufferParams const &, Paragraph & par);
+
+	/// Calculate and set the height of the row
+	void setHeightOfRow(ParagraphList::iterator, Row & row);
+
+	// fix the cursor `cur' after a characters has been deleted at `where'
+	// position. Called by deleteEmptyParagraphMechanism
+	void fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where);
+
+	/// delete double space (false) or empty paragraphs (true) around old_cursor
+	bool deleteEmptyParagraphMechanism(LyXCursor const & old_cursor);
+
+	///
+	void setCounter(Buffer const &, ParagraphList::iterator pit);
+	///
+	void deleteWordForward();
+	///
+	void deleteWordBackward();
+	///
+	void deleteLineForward();
+
+	/// sets row.end to the pos value *after* which a row should break.
+	/// for example, the pos after which isNewLine(pos) == true
+	void rowBreakPoint(ParagraphList::iterator pit, Row & row) const;
+
+	/// sets row.witdh to the minimum space a row needs on the screen in pixel
+	void fill(ParagraphList::iterator pit, Row & row, int workwidth) const;
+
+	/**
+	 * returns the minimum space a manual label needs on the
+	 * screen in pixels
+	 */
+	int labelFill(ParagraphList::iterator pit, Row const & row) const;
+
+	/// FIXME
+	int labelEnd(ParagraphList::iterator pit, Row const & row) const;
+
+	///
+	void charInserted();
+	/// set 'number' font property
+	void number();
+	/// is the cursor paragraph right-to-left?
+	bool rtl() const;
+
+	// Private Variables
 private:
 
 	/// prohibit this as long as there are back pointers...
@@ -469,11 +488,6 @@ private:
 	// cache for cursorPar()
 	mutable ParagraphList::iterator cache_par_;
 	mutable int cache_pos_;
-
-public:
-	/// absolute document pixel coordinates of this LyXText
-	int xo_;
-	int yo_;
 };
 
 /// return the default height of a row in pixels, considering font zoom
Index: src/text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.497
diff -u -p -r1.497 text.C
--- src/text.C	13 Nov 2003 13:43:39 -0000	1.497
+++ src/text.C	22 Nov 2003 13:13:32 -0000
@@ -1507,15 +1507,33 @@ RowList::iterator LyXText::firstRow() co
 }
 
 
+ParagraphList::iterator LyXText::firstPar() const
+{
+	return ownerParagraphs().begin();
+}
+
+
 RowList::iterator LyXText::lastRow() const
 {
 	return boost::prior(endRow());
 }
 
 
+ParagraphList::iterator LyXText::lastPar() const
+{
+	return boost::prior(endPar());
+}
+
+
 RowList::iterator LyXText::endRow() const
 {
 	return ownerParagraphs().back().rows.end();
+}
+
+
+ParagraphList::iterator LyXText::endPar() const
+{
+	return ownerParagraphs().end();
 }
 
 
Index: src/text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.508
diff -u -p -r1.508 text2.C
--- src/text2.C	21 Nov 2003 17:26:10 -0000	1.508
+++ src/text2.C	22 Nov 2003 13:13:33 -0000
@@ -73,11 +73,37 @@ using std::string;
 LyXText::LyXText(BufferView * bv, InsetText * inset, bool ininset,
 	  ParagraphList & paragraphs)
 	: height(0), width(0), inset_owner(inset), bv_owner(bv),
-	  in_inset_(ininset), paragraphs_(&paragraphs),
-	  cache_pos_(-1), xo_(0), yo_(0)
+	  in_inset_(ininset), paragraphs_(&paragraphs), xo_(0), yo_(0),
+	  cache_pos_(-1)
 {}
 
 
+LyXText & LyXText::operator=(LyXText const & lt)
+{
+	// Copy all public variables
+	height = lt.height;
+	width = lt.width;
+	current_font = lt.current_font;
+	real_current_font = lt.real_current_font;
+	defaultfont_ = lt.defaultfont_;
+	inset_owner = lt.inset_owner;
+	bv_owner = lt.bv_owner;
+	bidi = lt.bidi;
+	in_inset_ = lt.in_inset_;
+	paragraphs_ = lt.paragraphs_;
+	xo_ = lt.xo_;
+	yo_ = lt.yo_;
+
+	// Copy all the private variables
+
+	// we cannot initailize a iterator with a singular iterator.
+	//cache_par_ = lt.cache_par_;
+	cache_pos_ = lt.cache_pos_;
+
+	return *this;
+}
+
+
 void LyXText::init(BufferView * bview)
 {
 	bv_owner = bview;
@@ -1642,7 +1668,7 @@ DispatchResult LyXText::moveLeftIntern(b
 
 DispatchResult LyXText::moveUp()
 {
-	if (cursorRow() == firstRow())
+	if (cursorPar() == firstPar() && cursorRow() == firstRow())
 		return DispatchResult(false, FINISHED_UP);
 	cursorUp(false);
 	clearSelection();
@@ -1652,7 +1678,7 @@ DispatchResult LyXText::moveUp()
 
 DispatchResult LyXText::moveDown()
 {
-	if (cursorRow() == lastRow())
+	if (cursorPar() == lastPar() && cursorRow() == lastRow())
 		return DispatchResult(false, FINISHED_DOWN);
 	cursorDown(false);
 	clearSelection();
Index: src/text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.186
diff -u -p -r1.186 text3.C
--- src/text3.C	21 Nov 2003 11:16:37 -0000	1.186
+++ src/text3.C	22 Nov 2003 13:13:33 -0000
@@ -679,7 +679,7 @@ DispatchResult LyXText::dispatch(FuncReq
 		if (!selection.mark())
 			clearSelection();
 		finishChange(bv, false);
-		if (cursorRow() == firstRow())
+		if (cursorPar() == firstPar() && cursorRow() == firstRow())
 			return DispatchResult(false, FINISHED_UP);
 		cursorPrevious();
 		break;
@@ -688,7 +688,7 @@ DispatchResult LyXText::dispatch(FuncReq
 		if (!selection.mark())
 			clearSelection();
 		finishChange(bv, false);
-		if (cursorRow() == lastRow())
+		if (cursorPar() == lastPar() && cursorRow() == lastRow())
 			return DispatchResult(false, FINISHED_DOWN);
 		cursorNext();
 		break;

-- 
        Lgb

Reply via email to