Fix bug #6126: Assertion with page down in Math manual.

If we correct the row where we put the cursor after a PgDn or PgUp command, then we should also adjust the y-coordinate that is used later for checkInsetHit and inset->editXY. 

However, this code doesn't function like it should, but that is bug #4382.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31007 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-08-13 14:18:12 +00:00
parent 945dad51bf
commit bc9b16683e
2 changed files with 15 additions and 10 deletions

View File

@ -1406,7 +1406,7 @@ pit_type TextMetrics::getPitNearY(int y)
} }
Row const & TextMetrics::getPitAndRowNearY(int y, pit_type & pit, Row const & TextMetrics::getPitAndRowNearY(int & y, pit_type & pit,
bool assert_in_view, bool up) bool assert_in_view, bool up)
{ {
ParagraphMetrics const & pm = par_metrics_[pit]; ParagraphMetrics const & pm = par_metrics_[pit];
@ -1422,23 +1422,27 @@ Row const & TextMetrics::getPitAndRowNearY(int y, pit_type & pit,
if (assert_in_view && yy + rit->height() != y) { if (assert_in_view && yy + rit->height() != y) {
if (!up) { if (!up) {
if (rit != pm.rows().begin()) if (rit != pm.rows().begin()) {
y = yy;
--rit; --rit;
else if (pit != 0) { } else if (pit != 0) {
--pit; --pit;
newParMetricsUp(); newParMetricsUp();
ParagraphMetrics const & pm2 = par_metrics_[pit]; ParagraphMetrics const & pm2 = par_metrics_[pit];
rit = pm2.rows().end(); rit = pm2.rows().end();
--rit; --rit;
y = yy;
} }
} else { } else {
if (rit != rlast) if (rit != rlast) {
y = yy + rit->height();
++rit; ++rit;
else if (pit != int(par_metrics_.size())) { } else if (pit != int(par_metrics_.size())) {
++pit; ++pit;
newParMetricsDown(); newParMetricsDown();
ParagraphMetrics const & pm2 = par_metrics_[pit]; ParagraphMetrics const & pm2 = par_metrics_[pit];
rit = pm2.rows().begin(); rit = pm2.rows().begin();
y = pm2.position();
} }
} }
} }
@ -1457,8 +1461,9 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y,
} }
pit_type pit = getPitNearY(y); pit_type pit = getPitNearY(y);
LASSERT(pit != -1, return 0); LASSERT(pit != -1, return 0);
Row const & row = getPitAndRowNearY(y, pit, assert_in_view, up); int yy = y; // is modified by getPitAndRowNearY
Row const & row = getPitAndRowNearY(yy, pit, assert_in_view, up);
bool bound = false; bool bound = false;
int xx = x; // is modified by getColumnNearX int xx = x; // is modified by getColumnNearX
@ -1470,7 +1475,7 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y,
cur.setTargetX(x); cur.setTargetX(x);
// try to descend into nested insets // try to descend into nested insets
Inset * inset = checkInsetHit(x, y); Inset * inset = checkInsetHit(x, yy);
//lyxerr << "inset " << inset << " hit at x: " << x << " y: " << y << endl; //lyxerr << "inset " << inset << " hit at x: " << x << " y: " << y << endl;
if (!inset) { if (!inset) {
// Either we deconst editXY or better we move current_font // Either we deconst editXY or better we move current_font
@ -1498,7 +1503,7 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y,
} }
// Try to descend recursively inside the inset. // Try to descend recursively inside the inset.
inset = inset->editXY(cur, x, y); inset = inset->editXY(cur, x, yy);
if (cur.top().text() == text_) if (cur.top().text() == text_)
cur.setCurrentFont(); cur.setCurrentFont();

View File

@ -179,7 +179,7 @@ public:
/// returns the row near the specified y-coordinate in a given paragraph /// returns the row near the specified y-coordinate in a given paragraph
/// (relative to the screen). If assert_in_view is true, it is made sure /// (relative to the screen). If assert_in_view is true, it is made sure
/// that the row is on screen completely; this might change the given pit. /// that the row is on screen completely; this might change the given pit.
Row const & getPitAndRowNearY(int y, pit_type & pit, Row const & getPitAndRowNearY(int & y, pit_type & pit,
bool assert_in_view, bool up); bool assert_in_view, bool up);
/// returns the paragraph number closest to screen y-coordinate. /// returns the paragraph number closest to screen y-coordinate.