]> git.lyx.org Git - lyx.git/commitdiff
Modify the way multi-cell selection is done in tables:
authorAbdelrazak Younes <younes@lyx.org>
Wed, 1 Oct 2008 08:18:57 +0000 (08:18 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 1 Oct 2008 08:18:57 +0000 (08:18 +0000)
* Always put the cursor at the end of the cell (this was set at the beginning with mouse selection).
* handle LFUN_SELF_INSERT in case of multi-cell selection -> the whole cell contents will be deleted.

This commit fixes http://bugzilla.lyx.org/show_bug.cgi?id=5225

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

src/insets/InsetTabular.cpp

index 433d22fbd9740f6553e4ab1752cb0e7e60c6f822..fd765d7274cb6e9f64824688f15b2079fbff210a 100644 (file)
@@ -3295,8 +3295,8 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
                        // if this is a multicell selection, we just set the cursor to
                        // the beginning of the cell's text.
                        if (bvcur.selIsMultiCell()) {
-                               bvcur.pit() = 0;
-                               bvcur.pos() = 0;
+                               bvcur.pit() = bvcur.lastpit();
+                               bvcur.pos() = bvcur.lastpos();
                        }
                }
                break;
@@ -3409,6 +3409,11 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
                        cmd = FuncRequest(LFUN_FINISHED_FORWARD);
                        cur.undispatched();
                }
+               if (cur.selIsMultiCell()) {
+                       cur.pit() = cur.lastpit();
+                       cur.pos() = cur.lastpos();
+                       return;
+               }
                break;
 
        case LFUN_UP_SELECT:
@@ -3432,6 +3437,11 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
                        cmd = FuncRequest(LFUN_UP);
                        cur.undispatched();
                }
+               if (cur.selIsMultiCell()) {
+                       cur.pit() = cur.lastpit();
+                       cur.pos() = cur.lastpos();
+                       return;
+               }
                break;
 
 //     case LFUN_SCREEN_DOWN: {
@@ -3513,6 +3523,14 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
                        cell(cur.idx())->dispatch(cur, cmd);
                break;
 
+       case LFUN_SELF_INSERT:
+               if (cur.selIsMultiCell()) {
+                       cur.recordUndoInset(DELETE_UNDO);
+                       cutSelection(cur);
+               }
+               cell(cur.idx())->dispatch(cur, cmd);
+               break;
+
        case LFUN_CHAR_DELETE_BACKWARD:
        case LFUN_CHAR_DELETE_FORWARD:
                if (cur.selIsMultiCell()) {
@@ -4126,9 +4144,18 @@ void InsetTabular::moveNextCell(Cursor & cur, EntryDirection entry_from)
                        return;
                ++cur.idx();
        }
+
+       cur.boundary(false);
+
+       if (cur.selIsMultiCell()) {
+               cur.pit() = cur.lastpit();
+               cur.pos() = cur.lastpos();
+               resetPos(cur);
+               return;
+       }
+
        cur.pit() = 0;
        cur.pos() = 0;
-       cur.boundary(false);
 
        // in visual mode, place cursor at extreme left or right
        
@@ -4169,6 +4196,14 @@ void InsetTabular::movePrevCell(Cursor & cur, EntryDirection entry_from)
                        return;
                --cur.idx();
        }
+
+       if (cur.selIsMultiCell()) {
+               cur.pit() = cur.lastpit();
+               cur.pos() = cur.lastpos();
+               resetPos(cur);
+               return;
+       }
+
        cur.pit() = cur.lastpit();
        cur.pos() = cur.lastpos();