See attached.
? .bufferview_funcs.C.swp ? 1.diff ? mathed/.math_nestinset.C.swp Index: cursor.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v retrieving revision 1.111.2.8 diff -u -p -r1.111.2.8 cursor.C --- cursor.C 10 Nov 2004 09:16:12 -0000 1.111.2.8 +++ cursor.C 14 Nov 2004 10:59:02 -0000 @@ -359,7 +359,7 @@ void LCursor::getDim(int & asc, int & de BOOST_ASSERT(inset().asMathInset()); //inset().asMathInset()->getCursorDim(asc, des); asc = 10; - des = 10; + des = 2; } else if (inTexted()) { LyXFont const & realfont = text()->real_current_font; asc = font_metrics::maxAscent(realfont); Index: mathed/math_nestinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_nestinset.C,v retrieving revision 1.138.2.2 diff -u -p -r1.138.2.2 math_nestinset.C --- mathed/math_nestinset.C 9 Nov 2004 13:02:05 -0000 1.138.2.2 +++ mathed/math_nestinset.C 14 Nov 2004 10:59:03 -0000 @@ -34,6 +34,7 @@ #include "FuncStatus.h" #include "LColor.h" #include "bufferview_funcs.h" +#include "coordcache.h" #include "cursor.h" #include "debug.h" #include "dispatchresult.h" @@ -97,18 +98,46 @@ MathArray const & MathNestInset::cell(id } -void MathNestInset::getCursorPos(CursorSlice const & sl, int & x, int & y) const +void MathNestInset::getCursorPos(CursorSlice const & sl, + int & x, int & y) const { +// FIXME: This is a hack. Ideally, the coord cache should not store +// absolute positions, but relative ones. This would mean to call +// setXY() not in MathArray::draw(), but in the parent insets' draw() +// with the correctly adjusted x,y values. But this means that we'd have +// to touch all (math)inset's draw() methods. Right now, we'll store +// absolute value, and make them here relative, only to make them +// absolute again when actually drawing the cursor. What a mess. BOOST_ASSERT(ptr_cmp(&sl.inset(), this)); MathArray const & ar = sl.cell(); - x = ar.pos2x(sl.pos()); -// x = ar.xo() + ar.pos2x(sl.pos()); -// y = ar.yo(); + if (!theCoords.arrays_.has(&ar)) { + // this can (semi-)legally happen if we jsut created this cell + // and it never has been drawn before. So don't ASSERT. + //lyxerr << "no cached data for array " << &ar << endl; + x = 0; + y = 0; + return; + } + Point const pt = theCoords.arrays_.xy(&ar); + if (!theCoords.insets_.has(this)) { + // same as above + //lyxerr << "no cached data for inset " << this << endl; + x = 0; + y = 0; + return; + } + Point const pt2 = theCoords.insets_.xy(this); + //lyxerr << "retrieving position cache for MathArray " + // << pt.x_ << ' ' << pt.y_ << std::endl; + x = pt.x_ - pt2.x_ + ar.pos2x(sl.pos()); + y = pt.y_ - pt2.y_; +// lyxerr << "pt.y_ : " << pt.y_ << " pt2_.y_ : " << pt2.y_ +// << " asc: " << ascent() << " des: " << descent() +// << " ar.asc: " << ar.ascent() << " ar.des: " << ar.descent() << endl; // move cursor visually into empty cells ("blue rectangles"); if (ar.empty()) x += 2; } - void MathNestInset::metrics(MetricsInfo const & mi) const {