]> git.lyx.org Git - features.git/commitdiff
Make cell-forward/backward cycle in math
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 9 Nov 2018 15:21:55 +0000 (15:21 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 9 Nov 2018 16:05:09 +0000 (16:05 +0000)
Make cell-backward put the cursor at the end of cell when using
mac-like cursor movement.

src/mathed/InsetMathGrid.cpp
src/mathed/InsetMathNest.cpp

index 5a4830cb39b29022da48abcb14412310744c19d4..4ce79bd6196d6c0ed7c7779f53c5a630cb69c743 100644 (file)
@@ -1432,25 +1432,6 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
                splitCell(cur);
                break;
 
-       case LFUN_CELL_BACKWARD:
-               // See below.
-               cur.selection(false);
-               if (!idxPrev(cur)) {
-                       cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
-                       cur.undispatched();
-               }
-               break;
-
-       case LFUN_CELL_FORWARD:
-               // Can't handle selection by additional 'shift' as this is
-               // hard bound to LFUN_CELL_BACKWARD
-               cur.selection(false);
-               if (!idxNext(cur)) {
-                       cmd = FuncRequest(LFUN_FINISHED_FORWARD);
-                       cur.undispatched();
-               }
-               break;
-
        case LFUN_NEWLINE_INSERT: {
                cur.recordUndoInset();
                row_type const r = cur.row();
index 857fd7f87e0fb3e7f2b39bed17159a00a6a6a723..8cd1254098d2c0f125a8de5f31a5f096a5498296 100644 (file)
@@ -216,7 +216,7 @@ bool InsetMathNest::idxPrev(Cursor & cur) const
        if (cur.idx() == 0)
                return false;
        --cur.idx();
-       cur.pos() = cur.lastpos();
+       cur.pos() = lyxrc.mac_like_cursor_movement ? cur.lastpos() : 0;
        return true;
 }
 
@@ -793,12 +793,24 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_CELL_FORWARD:
                cur.screenUpdateFlags(Update::Decoration | Update::FitCursor);
-               cur.inset().idxNext(cur);
+               cur.selHandle(false);
+               cur.clearTargetX();
+               cur.macroModeClose();
+               if (!cur.inset().idxNext(cur)) {
+                       cur.idx() = firstIdx();
+                       cur.pos() = 0;
+               }
                break;
 
        case LFUN_CELL_BACKWARD:
                cur.screenUpdateFlags(Update::Decoration | Update::FitCursor);
-               cur.inset().idxPrev(cur);
+               cur.selHandle(false);
+               cur.clearTargetX();
+               cur.macroModeClose();
+               if (!cur.inset().idxPrev(cur)) {
+                       cur.idx() = lastIdx();
+                       cur.pos() = lyxrc.mac_like_cursor_movement ? cur.lastpos() : 0;
+               }
                break;
 
        case LFUN_WORD_DELETE_BACKWARD: