The following patch should cure all mouse+depm problems. I tested it
when moving between insets (text>text, math>text, text>math) and it
seems to work.
However, this is core code, and I'd like someone to try it out hard.
JMarc
PS: it seems new bugs are found faster than new patches. Sigh.
Index: src/BufferView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v
retrieving revision 1.263
diff -u -p -r1.263 BufferView.C
--- src/BufferView.C 15 Jul 2005 22:10:15 -0000 1.263
+++ src/BufferView.C 30 Nov 2005 14:11:07 -0000
@@ -332,6 +332,26 @@ void BufferView::setCursor(DocIterator c
}
+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: src/BufferView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v
retrieving revision 1.188
diff -u -p -r1.188 BufferView.h
--- src/BufferView.h 9 Jun 2005 09:58:03 -0000 1.188
+++ src/BufferView.h 30 Nov 2005 14:11:07 -0000
@@ -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: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2332
diff -u -p -r1.2332 ChangeLog
--- src/ChangeLog 29 Nov 2005 15:08:33 -0000 1.2332
+++ src/ChangeLog 30 Nov 2005 14:11:08 -0000
@@ -1,4 +1,15 @@
-2005-11-29 Jean-Marc Lasgouttes <[EMAIL PROTECTED]>
+2005-11-30 Jean-Marc Lasgouttes <[EMAIL PROTECTED]>
+
+ * 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 <[EMAIL PROTECTED]>
Fix bug 2096.
Index: src/lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.330
diff -u -p -r1.330 lyxtext.h
--- src/lyxtext.h 28 Nov 2005 11:52:01 -0000 1.330
+++ src/lyxtext.h 30 Nov 2005 14:11:08 -0000
@@ -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;
@@ -371,9 +374,6 @@ private:
// fix the cursor `cur' after a characters has been deleted at `where'
// 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: src/text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.319
diff -u -p -r1.319 text3.C
--- src/text3.C 25 Nov 2005 09:27:08 -0000 1.319
+++ src/text3.C 30 Nov 2005 14:11:08 -0000
@@ -825,9 +825,6 @@ void LyXText::dispatch(LCursor & cur, Fu
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, Fu
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,
Index: src/mathed/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/ChangeLog,v
retrieving revision 1.535
diff -u -p -r1.535 ChangeLog
--- src/mathed/ChangeLog 28 Nov 2005 10:23:19 -0000 1.535
+++ src/mathed/ChangeLog 30 Nov 2005 14:11:08 -0000
@@ -1,3 +1,10 @@
+2005-11-30 Jean-Marc Lasgouttes <[EMAIL PROTECTED]>
+
+ * math_nestinset.C (lfunMousePress): use mouseSetCursor (bug 2109).
+
+ * math_hullinset.C (doDispatch): comment out some annoying debug
+ messages.
+
2005-11-28 Martin Vermeer <[EMAIL PROTECTED]>
* math_deliminset.h:
Index: src/mathed/math_hullinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_hullinset.C,v
retrieving revision 1.182
diff -u -p -r1.182 math_hullinset.C
--- src/mathed/math_hullinset.C 25 Nov 2005 14:40:32 -0000 1.182
+++ src/mathed/math_hullinset.C 30 Nov 2005 14:11:08 -0000
@@ -984,14 +984,14 @@ void MathHullInset::doExtern(LCursor & c
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: src/mathed/math_nestinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_nestinset.C,v
retrieving revision 1.177
diff -u -p -r1.177 math_nestinset.C
--- src/mathed/math_nestinset.C 22 Nov 2005 13:52:25 -0000 1.177
+++ src/mathed/math_nestinset.C 30 Nov 2005 14:11:08 -0000
@@ -1025,8 +1025,7 @@ void MathNestInset::lfunMousePress(LCurs
//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) {