From 0ac664310a9f11006b6787163cd1bdbba9f41549 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 1 Oct 2008 08:18:57 +0000 Subject: [PATCH] Modify the way multi-cell selection is done in tables: * 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 | 41 ++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 433d22fbd9..fd765d7274 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -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(); -- 2.39.5