From 3246cc9a4af47a3438bcd6ad5cde9eccd87973e1 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 1 Dec 2005 10:28:50 +0000 Subject: [PATCH] bug 2109: trigger dEPM when moving cursor with mouse git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10637 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 20 ++++++++++++++++++++ src/BufferView.h | 5 ++++- src/ChangeLog | 13 ++++++++++++- src/lyxtext.h | 6 +++--- src/mathed/ChangeLog | 7 +++++++ src/mathed/math_hullinset.C | 4 ++-- src/mathed/math_nestinset.C | 3 +-- src/text3.C | 18 +----------------- 8 files changed, 50 insertions(+), 26 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index 31e01b155b..0386b2d073 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -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) { diff --git a/src/BufferView.h b/src/BufferView.h index 531b38f08b..426e90a293 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -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 diff --git a/src/ChangeLog b/src/ChangeLog index b03f12b384..86df83ffa4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,15 @@ -2005-11-29 Jean-Marc Lasgouttes +2005-11-30 Jean-Marc Lasgouttes + + * 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 * text3.C (dispatch/LFUN_INDEX_INSERT): when a selection is set, do not remove it (this inset behaves differently from the others). diff --git a/src/lyxtext.h b/src/lyxtext.h index 5a1fda8861..f3567c2cc7 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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); /// diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index e66bc7868d..847076b5ea 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,10 @@ +2005-11-30 Jean-Marc Lasgouttes + + * math_nestinset.C (lfunMousePress): use mouseSetCursor (bug 2109). + + * math_hullinset.C (doDispatch): comment out some annoying debug + messages. + 2005-11-28 Martin Vermeer * math_deliminset.h: diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index ed159c05af..43f31366fb 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -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(); diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index c6ef7f2d51..45935465a0 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -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) { diff --git a/src/text3.C b/src/text3.C index 65e803f4d2..8a882e22fa 100644 --- a/src/text3.C +++ b/src/text3.C @@ -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(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, -- 2.39.5