Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
> Note that I removed all the pasting code for tabular and directed to
> InsetText instead. However the two code were a bit different and I do
> not know why. Could you review the patch?
OK, this version goes even further in removing duplicated-but-wrong
code in InsetTabular/MOUSE_PRESS and fixes bug 4133 too.
http://bugzilla.lyx.org/show_bug.cgi?id=4133
Unless someone tells me why mouse press in tabular is different from
mouse press in text, I am going to commit to trunk and branch.
Someone?
JMarc
Index: src/insets/InsetTabular.cpp
===================================================================
--- src/insets/InsetTabular.cpp (révision 19417)
+++ src/insets/InsetTabular.cpp (copie de travail)
@@ -3197,39 +3197,17 @@
case LFUN_MOUSE_PRESS:
//lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
- // FIXME: the following should be replaced by a better fix
- // that is already used for plain text (Text3.cpp).
- cap::saveSelection(bvcur);
- if (cmd.button() == mouse_button::button1
- || (cmd.button() == mouse_button::button3
- && (&bvcur.selBegin().inset() != this || !tablemode(bvcur)))) {
- if (!bvcur.selection() && !cur.bv().mouseSetCursor(cur))
- cur.noUpdate();
- cur.selection() = false;
- setCursorFromCoordinates(cur, cmd.x, cmd.y);
- cur.bv().mouseSetCursor(cur);
- break;
- }
-
- if (cmd.button() == mouse_button::button2) {
- if (cap::selection()) {
- // See comment in Text::dispatch why we
- // do this
- // FIXME This does not use paste_tabular,
- // another reason why paste_tabular should go.
- cap::copySelectionToStack();
- cmd = FuncRequest(LFUN_PASTE, "0");
- } else {
- cmd = FuncRequest(LFUN_PRIMARY_SELECTION_PASTE,
- "paragraph");
- }
- doDispatch(cur, cmd);
- cur.bv().buffer()->markDirty();
- cur.bv().mouseSetCursor(cur);
- }
+ // do not reset cursor/selection if we have selected
+ // some cells (bug 2715).
+ if (cmd.button() == mouse_button::button3
+ && &bvcur.selBegin().inset() == this
+ && tablemode(bvcur))
+ ;
+ else
+ // Let InsetText do it
+ cell(cur.idx())->dispatch(cur, cmd);
break;
-
case LFUN_MOUSE_MOTION:
//lyxerr << "# InsetTabular::MouseMotion\n" << bvcur << endl;
if (cmd.button() == mouse_button::button1) {
Index: src/mathed/InsetMathNest.cpp
===================================================================
--- src/mathed/InsetMathNest.cpp (révision 19417)
+++ src/mathed/InsetMathNest.cpp (copie de travail)
@@ -1155,30 +1155,30 @@
BufferView & bv = cur.bv();
// FIXME: the following should be replaced by a better fix
// that is already used for plain text (Text3.cpp).
- cap::saveSelection(bv.cursor());
+ bv.mouseSetCursor(cur);
if (cmd.button() == mouse_button::button1) {
//lyxerr << "## lfunMousePress: setting cursor to: " << cur << endl;
- bv.mouseSetCursor(cur);
// Update the cursor update flags as needed:
//
- // Update::Decoration: tells to update the decoration (visual box
- // corners that define the inset)/
- // Update::FitCursor: adjust the screen to the cursor position if
- // needed
+ // Update::Decoration: tells to update the decoration
+ // (visual box corners that define
+ // the inset)/
+ // Update::FitCursor: adjust the screen to the cursor
+ // position if needed
// cur.result().update(): don't overwrite previously set flags.
- cur.updateFlags(Update::Decoration | Update::FitCursor | cur.result().update());
+ cur.updateFlags(Update::Decoration | Update::FitCursor
+ | cur.result().update());
} else if (cmd.button() == mouse_button::button2) {
- MathData ar;
if (cap::selection()) {
// See comment in Text::dispatch why we do this
cap::copySelectionToStack();
cmd = FuncRequest(LFUN_PASTE, "0");
- doDispatch(cur, cmd);
- } else
+ doDispatch(bv.cursor(), cmd);
+ } else {
+ MathData ar;
asArray(theSelection().get(), ar);
-
- cur.insert(ar);
- bv.mouseSetCursor(cur);
+ bv.cursor().insert(ar);
+ }
}
}