mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +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;
|
||||
|
||||
if (buffer_) {
|
||||
// Save the current selection if any
|
||||
cap::saveSelection(cursor_);
|
||||
// Save the actual cursor position and anchor inside the
|
||||
// buffer so that it can be restored in case we rechange
|
||||
// to this buffer later on.
|
||||
@ -1347,6 +1349,10 @@ bool BufferView::mouseSetCursor(Cursor & cur)
|
||||
{
|
||||
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?
|
||||
bool badcursor = false;
|
||||
bool leftinset = (&cursor_.inset() != &cur.inset());
|
||||
@ -1399,7 +1405,6 @@ void BufferView::putSelectionAt(DocIterator const & cur,
|
||||
cursor_.setSelection(cursor_, -length);
|
||||
} else
|
||||
cursor_.setSelection(cursor_, length);
|
||||
cap::saveSelection(cursor_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -588,9 +588,11 @@ bool Cursor::selHandle(bool sel)
|
||||
if (sel == selection())
|
||||
return false;
|
||||
|
||||
if (!sel)
|
||||
cap::saveSelection(*this);
|
||||
|
||||
resetAnchor();
|
||||
selection() = sel;
|
||||
cap::saveSelection(*this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "Buffer.h"
|
||||
#include "buffer_funcs.h"
|
||||
#include "BufferParams.h"
|
||||
#include "BufferView.h"
|
||||
#include "Cursor.h"
|
||||
#include "debug.h"
|
||||
#include "ErrorList.h"
|
||||
@ -526,6 +527,8 @@ void cutSelection(Cursor & cur, bool doclear, bool realcut)
|
||||
Text * text = cur.text();
|
||||
BOOST_ASSERT(text);
|
||||
|
||||
saveSelection(cur);
|
||||
|
||||
// make sure that the depth behind the selection are restored, too
|
||||
recordUndoSelection(cur);
|
||||
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
|
||||
// a selection is cleared. Therefore, multiple keyboard selection
|
||||
// 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 << ": `"
|
||||
<< to_utf8(cur.selectionAsString(true)) << "'."
|
||||
<< endl;
|
||||
@ -832,6 +837,7 @@ void eraseSelection(Cursor & cur)
|
||||
CursorSlice const & i1 = cur.selBegin();
|
||||
CursorSlice const & i2 = cur.selEnd();
|
||||
if (i1.inset().asInsetMath()) {
|
||||
saveSelection(cur);
|
||||
cur.top() = i1;
|
||||
if (i1.idx() == i2.idx()) {
|
||||
i1.cell().erase(i1.pos(), i2.pos());
|
||||
@ -852,7 +858,6 @@ void eraseSelection(Cursor & cur)
|
||||
}
|
||||
// need a valid cursor. (Lgb)
|
||||
cur.clearSelection();
|
||||
theSelection().haveSelection(false);
|
||||
} else {
|
||||
lyxerr << "can't erase this selection 1" << endl;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user