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
This commit is contained in:
Jean-Marc Lasgouttes 2005-12-01 10:28:50 +00:00
parent 4f8b86badf
commit 3246cc9a4a
8 changed files with 50 additions and 26 deletions

View 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)
{

View 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

View 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).

View 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);
///

View 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:

View 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();

View 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) {

View 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,