]> git.lyx.org Git - lyx.git/commitdiff
initial support for shift + right-mouse-click selection.
authorAbdelrazak Younes <younes@lyx.org>
Thu, 11 Oct 2007 14:46:53 +0000 (14:46 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Thu, 11 Oct 2007 14:46:53 +0000 (14:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20903 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/BufferView.h
src/Text3.cpp

index 9a892e8e98a4a46edb1b09ca87d89c2fefbc3bfd..72d6382a7debc33369cde0418cd43820dacb62f6 100644 (file)
@@ -1697,13 +1697,14 @@ bool BufferView::checkDepm(Cursor & cur, Cursor & old)
 }
 
 
-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;
@@ -1711,12 +1712,15 @@ bool BufferView::mouseSetCursor(Cursor & cur)
        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
@@ -1738,7 +1742,11 @@ bool BufferView::mouseSetCursor(Cursor & cur)
 
        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;
 }
index b92e908368a9e542ca16cf5c44d07b13e10a7d35..df58d927e4d06c8d31355021cc527e8ce72dadc1 100644 (file)
@@ -190,7 +190,7 @@ public:
        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
index d9d5b8f70b70ced12c10933ac978b496b6398d22..1dd9b126b85241851595420245488c3bbf28cdb5 100644 (file)
@@ -922,11 +922,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        // 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,