On Wed, Apr 06, 2005 at 10:56:44PM +0300, Martin Vermeer wrote:
> On Wed, Apr 06, 2005 at 04:22:18PM +0200, Jean-Marc Lasgouttes wrote:
> > >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:

...

> > I am not able to follow the logic, though.
>  
> 
> You're in good company.
> 
> I see this code (I changed the indentation to agree with the logic):
> 
> ---
>                 } else 
>                        if   (cur.posRight() || idxRight(cur)
>                           || cur.popRight() || cur.selection())
>                               ;
>                        else
>                               cmd = FuncRequest(LFUN_FINISHED_RIGHT);
>                 break;
> ---
> 
> In words: move right within a cell; if I hit the end, skip to the next
> cell; if I run out of cells, pop out of this inset; if any of these
> succeed (or if selection is on), do nothing further.
> 
> When is LFUN_FINISHED_RIGHT ever reached? At end of document?
> 
> A second question (am I being just dense or what?): even if the
> LFUN_FINISHED_RIGHT statement is reached, what does it actually do? I see
> that cmd is redefined, with LFUN_FINISHED_RIGHT as its action, but it's
> too late for this dispatch loop. Where is the newly built command being 
> dispatched?
> 
> This could explain a lot, e.g., why LFUN_END and LFUN_HOME don't manage
> to leave the inset even if the cursor is at the end or start. Nothing a
> simple cur.popRight or popLeft couldn't fix.
> 
> - Martin

See the attached patch, which does the job. 

There are obvious further simplifications possible.

- Martin


Index: math_nestinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_nestinset.C,v
retrieving revision 1.149
diff -u -r1.149 math_nestinset.C
--- math_nestinset.C    6 Apr 2005 19:01:55 -0000       1.149
+++ math_nestinset.C    7 Apr 2005 04:37:13 -0000
@@ -473,8 +473,6 @@
                } else if (cur.posRight() || idxRight(cur)
                        || cur.popRight() || cur.selection())
                        ;
-               else
-                       cmd = FuncRequest(LFUN_FINISHED_RIGHT);
                break;
 
        case LFUN_LEFTSEL:
@@ -490,12 +488,11 @@
                } else if (cur.posLeft() || idxLeft(cur)
                        || cur.popLeft() || cur.selection())
                        ;
-               else
-                       cmd = FuncRequest(LFUN_FINISHED_LEFT);
                break;
 
        case LFUN_UPSEL:
        case LFUN_UP:
+               if (cur.inMacroMode()) break;
                cur.selHandle(cmd.action == LFUN_UPSEL);
                if (!cur.up())
                        cmd = FuncRequest(LFUN_FINISHED_UP);
@@ -505,6 +502,7 @@
 
        case LFUN_DOWNSEL:
        case LFUN_DOWN:
+               if (cur.inMacroMode()) break;
                cur.selHandle(cmd.action == LFUN_DOWNSEL);
                if (!cur.down())
                        cmd = FuncRequest(LFUN_FINISHED_DOWN);
@@ -544,7 +542,8 @@
                        cur.idx() = 0;
                        cur.pos() = 0;
                } else {
-                       cmd = FuncRequest(LFUN_FINISHED_LEFT);
+                       cur.popLeft();
+                       cur.pos() = 0;
                }
                break;
 
@@ -564,7 +563,8 @@
                        cur.idx() = cur.lastidx();
                        cur.pos() = cur.lastpos();
                } else {
-                       cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+                       cur.popRight();
+                       cur.pos() = cur.lastpos();
                }
                break;
 

Attachment: pgpoO6dTYYt2r.pgp
Description: PGP signature

Reply via email to