On Fri, 2006-01-20 at 13:19 +0100, Jean-Marc Lasgouttes wrote: > >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes: > > Martin> The other one would "fix" this bug by just moving to in > Martin> front/behind the math inset. Ugly, but it remembers the x > Martin> location when you press further cursor ups/downs. > >> That is kind of ugly indeed. I was about to say go ahead, but if > >> you say now that > > Hmm, I forgot the finish my sentence, didn't I? > > My thought was that we could use this workaround for 1.4, as long as > we get rid of this as soon as possible. Now, since the behaviour is > not very nice when leaving a math inset, are you sure that users will > be less upset by a fast but wrong behaviour instead of a slow but > correct one?
The slowness is really huge, so yes, that's what I think. I didn't give up though... attached a modification of bruteFind3 that does the three-paragraph trick. There is still a slight delay, but it's much better now. Give it a try. My feeling is that this is as risk-free as the workaround, but not as ugly. - Martin
Index: cursor.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v retrieving revision 1.141 diff -u -p -r1.141 cursor.C --- cursor.C 11 Jan 2006 17:08:50 -0000 1.141 +++ cursor.C 20 Jan 2006 13:48:02 -0000 @@ -162,15 +162,14 @@ namespace { /// moves position closest to (x, y) in given box bool bruteFind3(LCursor & cur, int x, int y, bool up) { + // Scans three paragraphs in main document around cursor BufferView & bv = cur.bv(); int ylow = up ? 0 : y + 1; int yhigh = up ? y - 1 : bv.workHeight(); int xlow = 0; int xhigh = bv.workWidth(); -// FIXME: bit more work needed to get 'from' and 'to' right. pit_type from = cur.bottom().pit(); - //pit_type to = cur.bottom().pit(); //lyxerr << "Pit start: " << from << endl; //lyxerr << "bruteFind3: x: " << x << " y: " << y @@ -179,9 +178,15 @@ namespace { // << endl; InsetBase & inset = bv.buffer()->inset(); DocIterator it = doc_iterator_begin(inset); - it.pit() = from; - DocIterator et = doc_iterator_end(inset); - + // Previous paragraph: + while (it.pit() < from - 1) + it.forwardPar(); + DocIterator et = it; + // Start of paragraph after next: + et.forwardPar(); + et.forwardPar(); + et.forwardPar(); + double best_dist = std::numeric_limits<double>::max(); DocIterator best_cursor = et; @@ -1032,9 +1037,7 @@ bool LCursor::goUpDown(bool up) // no such inset found, just take something "above" if (!popLeft()) { lyxerr << "updown: popleft failed (strange case)" << endl; - int ylow = up ? 0 : yo + 1; - int yhigh = up ? yo - 1 : bv().workHeight(); - return bruteFind(*this, xo, yo, 0, bv().workWidth(), ylow, yhigh); + return bruteFind3(*this, xo, yo, up); } // any improvement so far?
signature.asc
Description: This is a digitally signed message part