From 31b0364c2d585dc74bc277106a5638ac2bb0ce01 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 16 Jul 2003 08:42:26 +0000 Subject: [PATCH] replace the LyXCursor::irow_ member with on-demand computation of the value (as quickly tested by John last week) LyXCursor does not know about rows anymore... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7290 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 9 +++++++++ src/lyxcursor.C | 12 ------------ src/lyxcursor.h | 13 ------------- src/lyxfunc.C | 12 +++++++----- src/lyxtext.h | 7 +++++++ src/text.C | 11 ++++++++--- src/text2.C | 5 +---- 7 files changed, 32 insertions(+), 37 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index acdf4d48c9..7c9b728b80 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ + +2003-07-16 André Pönitz + + * lyxcursor.[Ch]: + * lyxfunc.[Ch]: + * text.C: + * text2.C: replace the LyXCursor::irow_ member with + on-demand computation of the value + 2003-07-16 John Levon * lyxfunc.C: support LFUN_INSET_SETTINGS for Note diff --git a/src/lyxcursor.C b/src/lyxcursor.C index 1e16cba9bd..fb29801545 100644 --- a/src/lyxcursor.C +++ b/src/lyxcursor.C @@ -111,18 +111,6 @@ int LyXCursor::iy() const } -void LyXCursor::irow(RowList::iterator r) -{ - irow_ = r; -} - - -RowList::iterator LyXCursor::irow() const -{ - return irow_; -} - - bool operator==(LyXCursor const & a, LyXCursor const & b) { return a.par() == b.par() diff --git a/src/lyxcursor.h b/src/lyxcursor.h index c098d6e472..8cbea6ce3d 100644 --- a/src/lyxcursor.h +++ b/src/lyxcursor.h @@ -10,7 +10,6 @@ #ifndef LYXCURSOR_H #define LYXCURSOR_H -#include "RowList.h" #include "ParagraphList.h" #include "support/types.h" @@ -79,16 +78,6 @@ public: * FIXME: explain why we need this ? especially for y... */ int iy() const; - /// set the stored next row - void irow(RowList::iterator r); - /** - * Return the next row, when this - * cursor is at the end of the previous row, for insets that take - * a full row. - * - * FIXME: explain why we need this ? especially for y... - */ - RowList::iterator irow() const; private: /// The paragraph the cursor is in. ParagraphList::iterator par_; @@ -120,8 +109,6 @@ private: int y_; /// the stored next-row y position int iy_; - /// the containing row for the next line - RowList::iterator irow_; }; /// diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 1c98cbdc93..e6344f043d 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -912,12 +912,13 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) owner->clearMessage(); goto exit_with_message; } else if (result == FINISHED_UP) { - if (TEXT()->cursor.irow() != TEXT()->rows().begin()) { + RowList::iterator const irow = TEXT()->cursorIRow(); + if (irow != TEXT()->rows().begin()) { #if 1 TEXT()->setCursorFromCoordinates( TEXT()->cursor.ix() + inset_x, TEXT()->cursor.iy() - - TEXT()->cursor.irow()->baseline() - 1); + irow->baseline() - 1); TEXT()->cursor.x_fix(TEXT()->cursor.x()); #else TEXT()->cursorUp(view()); @@ -929,13 +930,14 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) owner->clearMessage(); goto exit_with_message; } else if (result == FINISHED_DOWN) { - if (boost::next(TEXT()->cursor.irow()) != TEXT()->rows().end()) { + RowList::iterator const irow = TEXT()->cursorIRow(); + if (boost::next(irow) != TEXT()->rows().end()) { #if 1 TEXT()->setCursorFromCoordinates( TEXT()->cursor.ix() + inset_x, TEXT()->cursor.iy() - - TEXT()->cursor.irow()->baseline() + - TEXT()->cursor.irow()->height() + 1); + irow->baseline() + + irow->height() + 1); TEXT()->cursor.x_fix(TEXT()->cursor.x()); #else TEXT()->cursorDown(view()); diff --git a/src/lyxtext.h b/src/lyxtext.h index c4d1556768..a33a71c9bb 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -205,6 +205,13 @@ public: RowList::iterator getRow(LyXCursor const & cursor) const; /// convenience RowList::iterator cursorRow() const; + /** + * Return the next row, when cursor is at the end of the + * previous row, for insets that take a full row. + * + * FIXME: explain why we need this ? especially for y... + */ + RowList::iterator cursorIRow() const; /** returns a pointer to the row near the specified y-coordinate (relative to the whole text). y is set to the real beginning diff --git a/src/text.C b/src/text.C index 48e6a097ea..d6b9af3b36 100644 --- a/src/text.C +++ b/src/text.C @@ -1239,8 +1239,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit) // is it a bottom line? RowList::iterator next_rit = boost::next(rit); - if (next_rit == rows().end() || - next_rit->par() != pit) { + if (next_rit == rows().end() || next_rit->par() != pit) { // the bottom margin ParagraphList::iterator nextpit = boost::next(pit); if (nextpit == ownerParagraphs().end() && @@ -2684,10 +2683,16 @@ LyXText::getRow(ParagraphList::iterator pit, pos_type pos, int & y) const return rit; } +// returns pointer to some fancy row 'below' specified row +RowList::iterator LyXText::cursorIRow() const +{ + int y = 0; + return getRow(cursor.par(), cursor.pos(), y); +} + RowList::iterator LyXText::getRowNearY(int & y) const { - RowList::iterator rit = anchor_row_; RowList::iterator const beg = rows().begin(); RowList::iterator const end = rows().end(); diff --git a/src/text2.C b/src/text2.C index f60496f152..f8b72a88bb 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1523,7 +1523,6 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit, RowList::iterator beg = rows().begin(); RowList::iterator old_row = row; - cur.irow(row); // if we are before the first char of this row and are still in the // same paragraph and there is a previous row then put the cursor on // the end of the previous row @@ -1899,11 +1898,9 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y) float x = getCursorX(next_row, cur.pos(), last, bound); cur.ix(int(x)); cur.iy(y + row->height() + next_row->baseline()); - cur.irow(next_row); } else { cur.iy(cur.y()); cur.ix(cur.x()); - cur.irow(row); } cur.boundary(bound); } @@ -1972,7 +1969,7 @@ void LyXText::cursorDown(bool selecting) int x = cursor.x_fix(); int y = cursor.y() - cursorRow()->baseline() + cursorRow()->height() + 1; setCursorFromCoordinates(x, y); - if (!selecting && cursorRow() == cursor.irow()) { + if (!selecting && cursorRow() == cursorIRow()) { int topy = top_y(); int y1 = cursor.iy() - topy; int y2 = y1; -- 2.39.2