]> git.lyx.org Git - features.git/commitdiff
fix two items from Konni's list of cursor up/down "issues"
authorAndré Pönitz <poenitz@gmx.net>
Fri, 22 Mar 2002 09:31:26 +0000 (09:31 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 22 Mar 2002 09:31:26 +0000 (09:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3810 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/math_cursor.C

index 852a90d6d3a144d6548cb9e4145f6e70210255a8..f3ab830a4c09a5fd4abf6fd1c688e7cc04b88964 100644 (file)
@@ -1,3 +1,8 @@
+
+2002-03-12  André Pönitz <poenitz@gmx.net>
+
+       * math_cursor.C: fix some Up/Down "issues"
+
 2002-03-21  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * most files: ws cleanup
index 175a0157a2f1755a561158d5f38eb676c7c500f4..86a3b12da80d65da912b69161bed049ea74d529b 100644 (file)
@@ -1175,6 +1175,9 @@ MathCursorPos const & MathCursor::cursor() const
 
 bool MathCursor::goUpDown(bool up)
 {
+       // Be warned: The 'logic' implemented in this function is highly fragile.
+       // A distance of one pixel or a '<' vs '<=' _really_ matters.
+       // So fiddle around with it only if you know what you are doing!
        int xlow, xhigh, ylow, yhigh;
 
   int xo, yo;
@@ -1219,8 +1222,10 @@ bool MathCursor::goUpDown(bool up)
 
        // try to find an inset that knows better then we
        while (1) {
-               // we found a cell that thinks it has something "below" us.
+               ///lyxerr << "updown: We are in " << *par() << " idx: " << idx() << '\n';
+               // ask inset first
                if (par()->idxUpDown(idx(), up)) {
+                       // we found a cell that thinks it has something "below" us.
                        ///lyxerr << "updown: found inset that handles UpDown\n";
                        xarray().boundingBox(xlow, xhigh, ylow, yhigh);
                        // project (xo,yo) onto proper box
@@ -1235,6 +1240,7 @@ bool MathCursor::goUpDown(bool up)
                        return true;
                }
 
+               // leave inset
                if (!popLeft()) {
                        // no such inset found, just take something "above"
                        ///lyxerr << "updown: handled by strange case\n";
@@ -1246,7 +1252,12 @@ bool MathCursor::goUpDown(bool up)
                                        up ? yo - 4 : formula()->yhigh()
                                );
                }
-               ///lyxerr << "updown: looping\n";
+               
+               // any improvement so far?
+               int xnew, ynew;
+               getPos(xnew, ynew);
+               if (up ? ynew < yo : ynew > yo)
+                       return true;
        }
 }
 
@@ -1267,7 +1278,9 @@ bool MathCursor::bruteFind
                        int yo = top.ypos();
                        if (xlow <= xo && xo <= xhigh && ylow <= yo && yo <= yhigh) {
                                double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
-                               if (d < best_dist) {
+                               // '<=' in order to take the last possible position
+                               // this is important for clicking behind \sum in e.g. '\sum_i a'
+                               if (d <= best_dist) {
                                        best_dist   = d;
                                        best_cursor = it.cursor();
                                }