]> git.lyx.org Git - features.git/commitdiff
Fix bug #1839: Ctrl+arrows don't move to next/prev table cell.
authorVincent van Ravesteijn <vfr@lyx.org>
Mon, 25 Oct 2010 01:18:48 +0000 (01:18 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Mon, 25 Oct 2010 01:18:48 +0000 (01:18 +0000)
Patch from Punyashloka Biswal.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35812 a592a061-630c-0410-9148-cb99ea01b6c8

src/Text3.cpp
src/insets/InsetTabular.cpp

index 255dc62d6b487a4c451a2d7e2f509b5f3cd3673a..c132531bb7c5a738f54475d90b3ca584364823e7 100644 (file)
@@ -819,6 +819,26 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_WORD_FORWARD_SELECT:
                needsUpdate |= cur.selHandle(cmd.action() == LFUN_WORD_FORWARD_SELECT);
                needsUpdate |= cursorForwardOneWord(cur);
+
+               if (!needsUpdate && oldTopSlice == cur.top()
+                               && cur.boundary() == oldBoundary) {
+                       cur.undispatched();
+                       cmd = FuncRequest(LFUN_FINISHED_FORWARD);
+               
+                       // we will probably be moving out the inset, so we should execute
+                       // the depm-mechanism, but only when the cursor has a place to 
+                       // go outside this inset, i.e. in a slice above.
+                       if (cur.depth() > 1 && cur.pos() == cur.lastpos() 
+                                 && cur.pit() == cur.lastpit()) {
+                               // The cursor hasn't changed yet. To give the 
+                               // DEPM the possibility of doing something we must
+                               // provide it with two different cursors.
+                               Cursor dummy = cur;
+                               dummy.pos() = dummy.pit() = 0;
+                               if (cur.bv().checkDepm(dummy, cur))
+                                       cur.forceBufferUpdate();;
+                       }
+               }
                break;
 
        case LFUN_WORD_LEFT:
@@ -848,6 +868,27 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_WORD_BACKWARD_SELECT:
                needsUpdate |= cur.selHandle(cmd.action() == LFUN_WORD_BACKWARD_SELECT);
                needsUpdate |= cursorBackwardOneWord(cur);
+       
+               if (!needsUpdate && oldTopSlice == cur.top()
+                               && cur.boundary() == oldBoundary) {
+                       cur.undispatched();
+                       cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
+               
+                       // we will probably be moving out the inset, so we should execute
+                       // the depm-mechanism, but only when the cursor has a place to 
+                       // go outside this inset, i.e. in a slice above.
+                       if (cur.depth() > 1 && cur.pos() == 0 
+                                 && cur.pit() == 0) {
+                               // The cursor hasn't changed yet. To give the 
+                               // DEPM the possibility of doing something we must
+                               // provide it with two different cursors.
+                               Cursor dummy = cur;
+                               dummy.pos() = cur.lastpos();
+                               dummy.pit() = cur.lastpit();
+                               if (cur.bv().checkDepm(dummy, cur))
+                                       cur.forceBufferUpdate();
+                       }
+               }
                break;
 
        case LFUN_WORD_SELECT: {
index 90aa18d15b09f58a7d7859537bb7fe36b2a5555e..c5e8b0da975c2ccf5126a55e7fa6a705808658d8 100644 (file)
@@ -3773,7 +3773,15 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_CHAR_RIGHT_SELECT:
        case LFUN_CHAR_RIGHT:
        case LFUN_CHAR_LEFT_SELECT:
-       case LFUN_CHAR_LEFT: {
+       case LFUN_CHAR_LEFT: 
+       case LFUN_WORD_FORWARD:
+       case LFUN_WORD_FORWARD_SELECT:
+       case LFUN_WORD_BACKWARD:
+       case LFUN_WORD_BACKWARD_SELECT:
+       case LFUN_WORD_RIGHT:
+       case LFUN_WORD_RIGHT_SELECT:
+       case LFUN_WORD_LEFT:
+       case LFUN_WORD_LEFT_SELECT: {
                // determine whether we move to next or previous cell, where to enter 
                // the new cell from, and which command to "finish" (i.e., exit the
                // inset) with:
@@ -3782,12 +3790,16 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
                FuncCode finish_lfun;
 
                if (act == LFUN_CHAR_FORWARD 
-                               || act == LFUN_CHAR_FORWARD_SELECT) {
+                               || act == LFUN_CHAR_FORWARD_SELECT
+                               || act == LFUN_WORD_FORWARD
+                               || act == LFUN_WORD_FORWARD_SELECT) {
                        next_cell = true;
                        finish_lfun = LFUN_FINISHED_FORWARD;
                }
                else if (act == LFUN_CHAR_BACKWARD
-                               || act == LFUN_CHAR_BACKWARD_SELECT) {
+                               || act == LFUN_CHAR_BACKWARD_SELECT
+                               || act == LFUN_WORD_BACKWARD
+                               || act == LFUN_WORD_BACKWARD_SELECT) {
                        next_cell = false;
                        finish_lfun = LFUN_FINISHED_BACKWARD;
                }
@@ -3795,7 +3807,9 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
                // table's direction.
                else {
                        bool const right = act == LFUN_CHAR_RIGHT
-                               || act == LFUN_CHAR_RIGHT_SELECT;
+                               || act == LFUN_CHAR_RIGHT_SELECT
+                               || act == LFUN_WORD_RIGHT
+                               || act == LFUN_WORD_RIGHT_SELECT;
                        next_cell = isRightToLeft(cur) != right;
                        
                        if (lyxrc.visual_cursor)
@@ -3804,10 +3818,14 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
                        finish_lfun = right ? LFUN_FINISHED_RIGHT : LFUN_FINISHED_LEFT;
                }
 
-               bool const select = act == LFUN_CHAR_FORWARD_SELECT ||
-                   act == LFUN_CHAR_BACKWARD_SELECT ||
-                   act == LFUN_CHAR_RIGHT_SELECT ||
-                   act == LFUN_CHAR_LEFT_SELECT;
+               bool const select =     act == LFUN_CHAR_FORWARD_SELECT 
+                   || act == LFUN_CHAR_BACKWARD_SELECT
+                   || act == LFUN_CHAR_RIGHT_SELECT
+                   || act == LFUN_CHAR_LEFT_SELECT
+                       || act == LFUN_WORD_FORWARD_SELECT
+                       || act == LFUN_WORD_RIGHT_SELECT
+                       || act == LFUN_WORD_BACKWARD_SELECT
+                       || act == LFUN_WORD_LEFT_SELECT;
 
                // If we have a multicell selection or we're 
                // not doing some LFUN_*_SELECT thing anyway...