]> git.lyx.org Git - features.git/commitdiff
bug 2109: trigger dEPM when moving cursor with mouse
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 1 Dec 2005 10:28:50 +0000 (10:28 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 1 Dec 2005 10:28:50 +0000 (10:28 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10637 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView.h
src/ChangeLog
src/lyxtext.h
src/mathed/ChangeLog
src/mathed/math_hullinset.C
src/mathed/math_nestinset.C
src/text3.C

index 31e01b155bae53be96e9146e4d8f931687d0ee63..0386b2d0730984d9c0064ec55572afa6a8f64664 100644 (file)
@@ -332,6 +332,26 @@ void BufferView::setCursor(DocIterator const & dit)
 }
 
 
+void BufferView::mouseSetCursor(LCursor & cur)
+{
+       BOOST_ASSERT(&cur.bv() == this);
+
+       // Has the cursor just left the inset?
+       if (&cursor().inset() != &cur.inset())
+               cursor().inset().notifyCursorLeaves(cursor());
+
+       // do the dEPM magic if needed
+       if (cursor().inTexted())
+               cursor().text()->deleteEmptyParagraphMechanism(cur, cursor());
+
+       cursor() = cur;
+       cursor().resetAnchor();
+       cursor().setTargetX();
+       finishUndo();
+
+}
+
+
 void BufferView::putSelectionAt(DocIterator const & cur,
                                int length, bool backwards)
 {
index 531b38f08bc67830f7d52b5695970440bbacab78..426e90a293d2d273f46d390b64374bc07020c540 100644 (file)
@@ -186,8 +186,11 @@ public:
        LCursor const & cursor() const;
        ///
        LyXText * text() const;
-       ///
+       /// sets cursor and open all relevant collapsable insets.
        void setCursor(DocIterator const &);
+       /// sets cursor; this is used when handling LFUN_MOUSE_PRESS.
+       void mouseSetCursor(LCursor & cur);
+
        /* Sets the selection. When \c backwards == false, set anchor
         * to \c cur and cursor to \c cur + \c length. When \c
         * backwards == true, set anchor to \c cur and cursor to \c
index b03f12b384cd289438744fb7f8f093acb4a7c5ec..86df83ffa4f90e87c66e9c44939f85bcf0019c26 100644 (file)
@@ -1,4 +1,15 @@
-2005-11-29  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+2005-11-30  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * BufferView.C (mouseSetCursor): new method. Calls
+       deleteEmptyParagraphMechanism if necessary.
+
+       * lyxtext.h: make deleteEmptyParagraphMechanism public.
+
+       * text3.C (dispatch/LFUN_MOUSE_PRESS): use
+       BufferView::mouseSetCursor (bug 2109).
+       (dispatch/LFUN_PASTE): remove #warning that is now irrelevant.
+
+2005-11-29  Jean-Marc Lasgouttes  <lasgouttes@lyx.org> 
 
        * text3.C (dispatch/LFUN_INDEX_INSERT): when a selection is set,
        do not remove it (this inset behaves differently from the others).
index 5a1fda886160a86ef6d47d74cdac3c5f121c5081..f3567c2cc72095689f99dabc2127d32877d4d3a8 100644 (file)
@@ -326,6 +326,9 @@ public:
        ///
        int cursorY(CursorSlice const & cursor, bool boundary) const;
 
+       /// delete double space or empty paragraphs around old cursor
+       bool deleteEmptyParagraphMechanism(LCursor & cur, LCursor & old);
+
        ///
        friend class LyXScreen;
 
@@ -372,9 +375,6 @@ private:
        // position. Called by deleteEmptyParagraphMechanism
        void fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where);
 
-       /// delete double space or empty paragraphs around old cursor
-       bool deleteEmptyParagraphMechanism(LCursor & cur, LCursor & old);
-
        ///
        void deleteWordForward(LCursor & cur);
        ///
index e66bc7868d9e9069a9d1cd0bfba2789726a5de39..847076b5eae9c4744378436eda436f943ec35dec 100644 (file)
@@ -1,3 +1,10 @@
+2005-11-30  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * math_nestinset.C (lfunMousePress): use mouseSetCursor (bug 2109).
+
+       * math_hullinset.C (doDispatch): comment out some annoying debug
+       messages. 
+
 2005-11-28  Martin Vermeer  <martin.vermeer@hut.fi>
 
        * math_deliminset.h: 
index ed159c05afd66ca6cead4cbbe6a13b25f16b1ecb..43f31366fba7c487cf09068487b00ca7d216f457 100644 (file)
@@ -984,14 +984,14 @@ void MathHullInset::doExtern(LCursor & cur, FuncRequest & func)
 
 void MathHullInset::doDispatch(LCursor & cur, FuncRequest & cmd)
 {
-       lyxerr << "action: " << cmd.action << endl;
+       //lyxerr << "action: " << cmd.action << endl;
        switch (cmd.action) {
 
        case LFUN_FINISHED_LEFT:
        case LFUN_FINISHED_RIGHT:
        case LFUN_FINISHED_UP:
        case LFUN_FINISHED_DOWN:
-               lyxerr << "action: " << cmd.action << endl;
+               //lyxerr << "action: " << cmd.action << endl;
                MathGridInset::doDispatch(cur, cmd);
                notifyCursorLeaves(cur);
                cur.undispatched();
index c6ef7f2d510d1c91479ea259ff733a828181734f..45935465a0e09a377efbb59736da8312878134c0 100644 (file)
@@ -1025,8 +1025,7 @@ void MathNestInset::lfunMousePress(LCursor & cur, FuncRequest & cmd)
        //lyxerr << "## lfunMousePress: buttons: " << cmd.button() << endl;
        if (cmd.button() == mouse_button::button1) {
                //lyxerr << "## lfunMousePress: setting cursor to: " << cur << endl;
-               cur.resetAnchor();
-               cur.bv().cursor() = cur;
+               cur.bv().mouseSetCursor(cur);
        }
 
        if (cmd.button() == mouse_button::button2) {
index 65e803f4d2876a557c945ddf97a2037ea123080f..8a882e22fafed7d3f43a3a2ada784f6d6a26a76e 100644 (file)
@@ -825,9 +825,6 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_PASTE:
                cur.message(_("Paste"));
                lyx::cap::replaceSelection(cur);
-#ifdef WITH_WARNINGS
-#warning FIXME Check if the arg is in the domain of available selections.
-#endif
                if (isStrUnsignedInt(cmd.argument))
                        pasteSelection(cur, convert<unsigned int>(cmd.argument));
                else
@@ -1028,20 +1025,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                        paste_internally = true;
                }
 
-               // Clear the selection
-               cur.clearSelection();
-
-               setCursorFromCoordinates(cur, cmd.x, cmd.y);
-               cur.resetAnchor();
-               finishUndo();
-               cur.setTargetX();
-
-               // Has the cursor just left the inset?
-               if (bv->cursor().inMathed() && !cur.inMathed())
-                       bv->cursor().inset().notifyCursorLeaves(bv->cursor());
-
-               // Set cursor here.
-               bv->cursor() = cur;
+               bv->mouseSetCursor(cur);
 
                // Insert primary selection with middle mouse
                // if there is a local selection in the current buffer,