Make Cursor::anchor_ private and make an access function Cursor::realAnchor() to stress the fact that this is thus not the normalAnchor().

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34146 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2010-04-15 18:16:07 +00:00
parent d8db0e8515
commit 108a67ed43
6 changed files with 25 additions and 15 deletions

View File

@ -1859,10 +1859,10 @@ docstring const BufferView::requestSelection()
LYXERR(Debug::SELECTION, "requestSelection: xsel_cache.set: " << d->xsel_cache_.set);
if (!d->xsel_cache_.set ||
cur.top() != d->xsel_cache_.cursor ||
cur.anchor_.top() != d->xsel_cache_.anchor)
cur.realAnchor().top() != d->xsel_cache_.anchor)
{
d->xsel_cache_.cursor = cur.top();
d->xsel_cache_.anchor = cur.anchor_.top();
d->xsel_cache_.anchor = cur.realAnchor().top();
d->xsel_cache_.set = cur.selection();
return cur.selectionAsString(false);
}

View File

@ -214,7 +214,7 @@ bool bruteFind3(Cursor & cur, int x, int y, bool up)
for ( ; it != et; it.forwardPos()) {
// avoid invalid nesting when selecting
if (bv.cursorStatus(it) == CUR_INSIDE
&& (!cur.selection() || positionable(it, cur.anchor_))) {
&& (!cur.selection() || positionable(it, cur.realAnchor()))) {
Point p = bv.getPos(it, false);
int xo = p.x_;
int yo = p.y_;
@ -994,6 +994,12 @@ CursorSlice Cursor::normalAnchor() const
}
DocIterator & Cursor::realAnchor()
{
return anchor_;
}
CursorSlice Cursor::selBegin() const
{
if (!selection())

View File

@ -202,6 +202,10 @@ public:
/// access to normalized selection anchor
CursorSlice normalAnchor() const;
// FIXME: this can't be a const & and a const function because
// LFUN_TAB_* wants to move the real anchor.
/// access to real selection anchor
DocIterator & realAnchor();
/// sets anchor to cursor position
void resetAnchor();
/// access to owning BufferView
@ -288,8 +292,6 @@ public:
///
BufferView * bv_;
//private:
/// the anchor position
DocIterator anchor_;
///
DocIterator const & beforeDispatchCursor() const { return beforeDispatchCursor_; }
@ -297,6 +299,8 @@ public:
void saveBeforeDispatchPosXY();
private:
/// the anchor position
DocIterator anchor_;
///
mutable DispatchResult disp_;
/**

View File

@ -885,8 +885,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
bv->buffer().params().trackChanges);
// Update the selection pos to make sure the selection does not
// change as the inserted tab will increase the logical pos.
if (cur.anchor_.pit() == pit)
cur.anchor_.forwardPos();
if (cur.realAnchor().pit() == pit)
cur.realAnchor().forwardPos();
if (cur.pit() == pit)
cur.forwardPos();
}
@ -912,8 +912,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
if (par.getChar(0) == '\t') {
if (cur.pit() == pit)
cur.posBackward();
if (cur.anchor_.pit() == pit && cur.anchor_.pos() > 0 )
cur.anchor_.backwardPos();
if (cur.realAnchor().pit() == pit && cur.realAnchor().pos() > 0 )
cur.realAnchor().backwardPos();
par.eraseChar(0, tc);
} else
@ -922,8 +922,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
par.getChar(0) == ' ' && n_spaces < 4; ++n_spaces) {
if (cur.pit() == pit)
cur.posBackward();
if (cur.anchor_.pit() == pit && cur.anchor_.pos() > 0 )
cur.anchor_.backwardPos();
if (cur.realAnchor().pit() == pit && cur.realAnchor().pos() > 0 )
cur.realAnchor().backwardPos();
par.eraseChar(0, tc);
}
@ -1403,7 +1403,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
}
// ignore motions deeper nested than the real anchor
Cursor & bvcur = cur.bv().cursor();
if (!bvcur.anchor_.hasPart(cur)) {
if (!bvcur.realAnchor().hasPart(cur)) {
cur.undispatched();
break;
}

View File

@ -3560,7 +3560,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
//lyxerr << "# InsetTabular::MouseMotion\n" << bvcur << endl;
if (cmd.button() == mouse_button::button1) {
// only accept motions to places not deeper nested than the real anchor
if (!bvcur.anchor_.hasPart(cur)) {
if (!bvcur.realAnchor().hasPart(cur)) {
cur.undispatched();
break;
}
@ -3590,7 +3590,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
}
// only update if selection changes
if (bvcur.idx() == cur.idx() &&
!(bvcur.anchor_.idx() == cur.idx() && bvcur.pos() != cur.pos()))
!(bvcur.realAnchor().idx() == cur.idx() && bvcur.pos() != cur.pos()))
cur.noUpdate();
setCursorFromCoordinates(cur, cmd.x(), cmd.y());
bvcur.setCursor(cur);

View File

@ -1454,7 +1454,7 @@ void InsetMathNest::lfunMouseMotion(Cursor & cur, FuncRequest & cmd)
// only select with button 1
if (cmd.button() == mouse_button::button1) {
Cursor & bvcur = cur.bv().cursor();
if (bvcur.anchor_.hasPart(cur)) {
if (bvcur.realAnchor().hasPart(cur)) {
//lyxerr << "## lfunMouseMotion: cursor: " << cur << endl;
bvcur.setCursor(cur);
bvcur.setSelection(true);