mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
Restore the persistent selection feature (disabled because of bug 3877)
See also http://www.lyx.org/trac/changeset/19003 * BufferView.cpp (setBuffer): save selection before switching buffer (mouseSetCursor): save selection before resetting it (putSelectionAt): no need to save selection * Cursor.cpp (selHandle): save selection before resetting it * CutAndPaste.cpp (cutSelection, eraseSelection): save selection before deleting it. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19026 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f4b65f4e96
commit
1d51120eb4
@ -149,6 +149,8 @@ void BufferView::setBuffer(Buffer * b)
|
|||||||
<< "[ b = " << b << "]" << endl;
|
<< "[ b = " << b << "]" << endl;
|
||||||
|
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
|
// Save the current selection if any
|
||||||
|
cap::saveSelection(cursor_);
|
||||||
// Save the actual cursor position and anchor inside the
|
// Save the actual cursor position and anchor inside the
|
||||||
// buffer so that it can be restored in case we rechange
|
// buffer so that it can be restored in case we rechange
|
||||||
// to this buffer later on.
|
// to this buffer later on.
|
||||||
@ -1347,6 +1349,10 @@ bool BufferView::mouseSetCursor(Cursor & cur)
|
|||||||
{
|
{
|
||||||
BOOST_ASSERT(&cur.bv() == this);
|
BOOST_ASSERT(&cur.bv() == this);
|
||||||
|
|
||||||
|
// this event will clear selection so we save selection for
|
||||||
|
// persistent selection
|
||||||
|
cap::saveSelection(cursor());
|
||||||
|
|
||||||
// Has the cursor just left the inset?
|
// Has the cursor just left the inset?
|
||||||
bool badcursor = false;
|
bool badcursor = false;
|
||||||
bool leftinset = (&cursor_.inset() != &cur.inset());
|
bool leftinset = (&cursor_.inset() != &cur.inset());
|
||||||
@ -1399,7 +1405,6 @@ void BufferView::putSelectionAt(DocIterator const & cur,
|
|||||||
cursor_.setSelection(cursor_, -length);
|
cursor_.setSelection(cursor_, -length);
|
||||||
} else
|
} else
|
||||||
cursor_.setSelection(cursor_, length);
|
cursor_.setSelection(cursor_, length);
|
||||||
cap::saveSelection(cursor_);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,9 +588,11 @@ bool Cursor::selHandle(bool sel)
|
|||||||
if (sel == selection())
|
if (sel == selection())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!sel)
|
||||||
|
cap::saveSelection(*this);
|
||||||
|
|
||||||
resetAnchor();
|
resetAnchor();
|
||||||
selection() = sel;
|
selection() = sel;
|
||||||
cap::saveSelection(*this);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "buffer_funcs.h"
|
#include "buffer_funcs.h"
|
||||||
#include "BufferParams.h"
|
#include "BufferParams.h"
|
||||||
|
#include "BufferView.h"
|
||||||
#include "Cursor.h"
|
#include "Cursor.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "ErrorList.h"
|
#include "ErrorList.h"
|
||||||
@ -526,6 +527,8 @@ void cutSelection(Cursor & cur, bool doclear, bool realcut)
|
|||||||
Text * text = cur.text();
|
Text * text = cur.text();
|
||||||
BOOST_ASSERT(text);
|
BOOST_ASSERT(text);
|
||||||
|
|
||||||
|
saveSelection(cur);
|
||||||
|
|
||||||
// make sure that the depth behind the selection are restored, too
|
// make sure that the depth behind the selection are restored, too
|
||||||
recordUndoSelection(cur);
|
recordUndoSelection(cur);
|
||||||
pit_type begpit = cur.selBegin().pit();
|
pit_type begpit = cur.selBegin().pit();
|
||||||
@ -676,7 +679,9 @@ void saveSelection(Cursor & cur)
|
|||||||
// This function is called, not when a selection is formed, but when
|
// This function is called, not when a selection is formed, but when
|
||||||
// a selection is cleared. Therefore, multiple keyboard selection
|
// a selection is cleared. Therefore, multiple keyboard selection
|
||||||
// will not repeatively trigger this function (bug 3877).
|
// will not repeatively trigger this function (bug 3877).
|
||||||
if (cur.selection()) {
|
if (cur.selection()
|
||||||
|
&& cur.selBegin() == cur.bv().cursor().selBegin()
|
||||||
|
&& cur.selEnd() == cur.bv().cursor().selEnd()) {
|
||||||
LYXERR(Debug::ACTION) << BOOST_CURRENT_FUNCTION << ": `"
|
LYXERR(Debug::ACTION) << BOOST_CURRENT_FUNCTION << ": `"
|
||||||
<< to_utf8(cur.selectionAsString(true)) << "'."
|
<< to_utf8(cur.selectionAsString(true)) << "'."
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -832,6 +837,7 @@ void eraseSelection(Cursor & cur)
|
|||||||
CursorSlice const & i1 = cur.selBegin();
|
CursorSlice const & i1 = cur.selBegin();
|
||||||
CursorSlice const & i2 = cur.selEnd();
|
CursorSlice const & i2 = cur.selEnd();
|
||||||
if (i1.inset().asInsetMath()) {
|
if (i1.inset().asInsetMath()) {
|
||||||
|
saveSelection(cur);
|
||||||
cur.top() = i1;
|
cur.top() = i1;
|
||||||
if (i1.idx() == i2.idx()) {
|
if (i1.idx() == i2.idx()) {
|
||||||
i1.cell().erase(i1.pos(), i2.pos());
|
i1.cell().erase(i1.pos(), i2.pos());
|
||||||
@ -852,7 +858,6 @@ void eraseSelection(Cursor & cur)
|
|||||||
}
|
}
|
||||||
// need a valid cursor. (Lgb)
|
// need a valid cursor. (Lgb)
|
||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
theSelection().haveSelection(false);
|
|
||||||
} else {
|
} else {
|
||||||
lyxerr << "can't erase this selection 1" << endl;
|
lyxerr << "can't erase this selection 1" << endl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user