}
-bool BufferView::mouseSetCursor(Cursor & cur)
+bool BufferView::mouseSetCursor(Cursor & cur, bool select)
{
BOOST_ASSERT(&cur.bv() == this);
- // this event will clear selection so we save selection for
- // persistent selection
- cap::saveSelection(cursor());
+ if (!select)
+ // this event will clear selection so we save selection for
+ // persistent selection
+ cap::saveSelection(cursor());
// Has the cursor just left the inset?
bool badcursor = false;
if (leftinset)
badcursor = notifyCursorLeaves(d.cursor_, cur);
+ // FIXME: shift-mouse selection doesn't work well across insets.
+ bool do_selection = select && &d.cursor_.anchor().inset() == &cur.inset();
+
// do the dEPM magic if needed
// FIXME: (1) move this to InsetText::notifyCursorLeaves?
// FIXME: (2) if we had a working InsetText::notifyCursorLeaves,
// the leftinset bool would not be necessary (badcursor instead).
bool update = leftinset;
- if (!badcursor && d.cursor_.inTexted())
+ if (!do_selection && !badcursor && d.cursor_.inTexted())
update |= checkDepm(cur, d.cursor_);
// if the cursor was in an empty script inset and the new
d.cursor_.setCursor(dit);
d.cursor_.boundary(cur.boundary());
- d.cursor_.clearSelection();
+ if (do_selection)
+ d.cursor_.setSelection();
+ else
+ d.cursor_.clearSelection();
+
finishUndo();
return update;
}
bool checkDepm(Cursor & cur, Cursor & old);
/// sets cursor.
/// This is used when handling LFUN_MOUSE_PRESS.
- bool mouseSetCursor(Cursor & cur);
+ bool mouseSetCursor(Cursor & cur, bool select = false);
/// sets the selection.
/* When \c backwards == false, set anchor
// Single-click on work area
case LFUN_MOUSE_PRESS: {
// Right click on a footnote flag opens float menu
+ // FIXME: Why should we clear the selection in this case?
if (cmd.button() == mouse_button::button3)
cur.clearSelection();
+ bool do_selection = cmd.button() == mouse_button::button1
+ && cmd.argument() == "region-select";
// Set the cursor
- bool update = bv->mouseSetCursor(cur);
+ bool update = bv->mouseSetCursor(cur, do_selection);
// Insert primary selection with middle mouse
// if there is a local selection in the current buffer,