Anchor globalization

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8340 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-01-13 18:08:13 +00:00
parent 7cfc5e86a4
commit 25bafa2772
20 changed files with 233 additions and 146 deletions

View File

@ -316,7 +316,7 @@ void BufferView::gotoLabel(string const & label)
text()->setCursor( text()->setCursor(
std::distance(text()->paragraphs().begin(), it.getPar()), std::distance(text()->paragraphs().begin(), it.getPar()),
it.getPos()); it.getPos());
text()->anchor() = text()->cursor(); resetAnchor();
update(); update();
return; return;
} }
@ -393,13 +393,13 @@ bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
UpdatableInset * BufferView::innerInset() const UpdatableInset * BufferView::innerInset() const
{ {
return static_cast<UpdatableInset*>(cursor().innerInset()); return static_cast<UpdatableInset*>(fullCursor().innerInset());
} }
LyXText * BufferView::getLyXText() const LyXText * BufferView::getLyXText() const
{ {
return cursor().innerText(); return fullCursor().innerText();
} }
@ -436,18 +436,48 @@ int BufferView::workHeight() const
} }
LCursor & BufferView::cursor() void BufferView::fullCursor(LCursor const & cur)
{
pimpl_->cursor_ = cur;
}
LCursor & BufferView::fullCursor()
{ {
return pimpl_->cursor_; return pimpl_->cursor_;
} }
LCursor const & BufferView::cursor() const LCursor const & BufferView::fullCursor() const
{ {
return pimpl_->cursor_; return pimpl_->cursor_;
} }
CursorSlice & BufferView::cursor()
{
return fullCursor().cursor_.back();
}
CursorSlice const & BufferView::cursor() const
{
return fullCursor().cursor_.back();
}
CursorSlice & BufferView::anchor()
{
return fullCursor().anchor_.back();
}
CursorSlice const & BufferView::anchor() const
{
return fullCursor().anchor_.back();
}
void BufferView::x_target(int x) void BufferView::x_target(int x)
{ {
x_target_ = x; x_target_ = x;
@ -470,3 +500,9 @@ LyXText * BufferView::text() const
{ {
return pimpl_->buffer_ ? &pimpl_->buffer_->text() : 0; return pimpl_->buffer_ ? &pimpl_->buffer_->text() : 0;
} }
void BufferView::resetAnchor()
{
return fullCursor().resetAnchor();
}

View File

@ -21,6 +21,7 @@
class Buffer; class Buffer;
class Change; class Change;
class CursorSlice;
class Encoding; class Encoding;
class ErrorList; class ErrorList;
class FuncRequest; class FuncRequest;
@ -185,14 +186,26 @@ public:
/// clear the X selection /// clear the X selection
void unsetXSel(); void unsetXSel();
/// access to cursor /// access to full cursor
LCursor & cursor(); LCursor & fullCursor();
/// access to cursor /// access to full cursor
LCursor const & cursor() const; void fullCursor(LCursor const &);
/// access to full cursor
LCursor const & fullCursor() const;
/// access to topmost cursor slice
CursorSlice & cursor();
/// access to topmost cursor slice
CursorSlice const & cursor() const;
/// access to selection anchor
CursorSlice & anchor();
/// access to selection anchor
CursorSlice const & anchor() const;
/// ///
UpdatableInset * innerInset() const; UpdatableInset * innerInset() const;
/// ///
LyXText * text() const; LyXText * text() const;
///
void resetAnchor();
private: private:
/// ///

View File

@ -393,8 +393,8 @@ void BufferView::Pimpl::resizeCurrentBuffer()
if (!text) if (!text)
return; return;
par = text->cursor().par(); par = bv_->cursor().par();
pos = text->cursor().pos(); pos = bv_->cursor().pos();
selstartpar = text->selStart().par(); selstartpar = text->selStart().par();
selstartpos = text->selStart().pos(); selstartpos = text->selStart().pos();
selendpar = text->selEnd().par(); selendpar = text->selEnd().par();
@ -412,13 +412,13 @@ void BufferView::Pimpl::resizeCurrentBuffer()
text->selection.mark(mark_set); text->selection.mark(mark_set);
if (selection) { if (selection) {
text->setCursor(selstartpar, selstartpos); text->setCursor(selstartpar, selstartpos);
text->anchor() = text->cursor(); bv_->resetAnchor();
text->setCursor(selendpar, selendpos); text->setCursor(selendpar, selendpos);
text->setSelection(); text->setSelection();
text->setCursor(par, pos); text->setCursor(par, pos);
} else { } else {
text->setCursor(par, pos); text->setCursor(par, pos);
text->anchor() = text->cursor(); bv_->resetAnchor();
text->selection.set(false); text->selection.set(false);
} }
} }
@ -537,11 +537,11 @@ void BufferView::Pimpl::selectionRequested()
} }
if (!xsel_cache_.set || if (!xsel_cache_.set ||
text->cursor() != xsel_cache_.cursor || bv_->cursor() != xsel_cache_.cursor ||
text->anchor() != xsel_cache_.anchor) bv_->anchor() != xsel_cache_.anchor)
{ {
xsel_cache_.cursor = text->cursor(); xsel_cache_.cursor = bv_->cursor();
xsel_cache_.anchor = text->anchor(); xsel_cache_.anchor = bv_->anchor();
xsel_cache_.set = text->selection.set(); xsel_cache_.set = text->selection.set();
sel = text->selectionAsString(*bv_->buffer(), false); sel = text->selectionAsString(*bv_->buffer(), false);
if (!sel.empty()) if (!sel.empty())
@ -915,7 +915,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
if (!available()) if (!available())
return false; return false;
FuncRequest cmd1(cmd, bv_); FuncRequest cmd1(cmd, bv_);
UpdatableInset * inset = bv_->cursor().innerInset(); UpdatableInset * inset = bv_->fullCursor().innerInset();
DispatchResult res; DispatchResult res;
if (inset) { if (inset) {
cmd1.x -= inset->x(); cmd1.x -= inset->x();
@ -923,12 +923,12 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
res = inset->dispatch(cmd1); res = inset->dispatch(cmd1);
} else { } else {
cmd1.y += bv_->top_y(); cmd1.y += bv_->top_y();
res = bv_->cursor().innerText()->dispatch(cmd1); res = bv_->fullCursor().innerText()->dispatch(cmd1);
} }
if (bv_->fitCursor() || res.update()) { if (bv_->fitCursor() || res.update()) {
bv_->update(); bv_->update();
bv_->cursor().updatePos(); bv_->fullCursor().updatePos();
} }
return true; return true;
@ -968,7 +968,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
res = inset->dispatch(cmd2); res = inset->dispatch(cmd2);
if (res.update()) { if (res.update()) {
bv_->update(); bv_->update();
bv_->cursor().updatePos(); bv_->fullCursor().updatePos();
} }
res.update(false); res.update(false);
switch (res.val()) { switch (res.val()) {
@ -977,8 +977,9 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
case FINISHED_UP: case FINISHED_UP:
case FINISHED_DOWN: case FINISHED_DOWN:
theTempCursor.pop(); theTempCursor.pop();
bv_->cursor() = theTempCursor; bv_->fullCursor(theTempCursor);
bv_->cursor().innerText()->setCursorFromCoordinates(cmd.x, top_y() + cmd.y); bv_->fullCursor().innerText()
->setCursorFromCoordinates(cmd.x, top_y() + cmd.y);
if (bv_->fitCursor()) if (bv_->fitCursor())
bv_->update(); bv_->update();
return true; return true;
@ -994,9 +995,9 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
lyxerr << "dispatching " << cmd1 lyxerr << "dispatching " << cmd1
<< " to surrounding LyXText " << " to surrounding LyXText "
<< theTempCursor.innerText() << endl; << theTempCursor.innerText() << endl;
bv_->cursor() = theTempCursor; bv_->fullCursor(theTempCursor);
cmd1.y += bv_->top_y(); cmd1.y += bv_->top_y();
res = bv_->cursor().innerText()->dispatch(cmd1); res = bv_->fullCursor().innerText()->dispatch(cmd1);
if (bv_->fitCursor() || res.update()) if (bv_->fitCursor() || res.update())
bv_->update(); bv_->update();
@ -1276,7 +1277,7 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
bv_->text()->setLayout(hasLayout ? lres : tclass.defaultLayoutName()); bv_->text()->setLayout(hasLayout ? lres : tclass.defaultLayoutName());
bv_->text()->setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0); bv_->text()->setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
} }
bv_->cursor().innerText()->insertInset(inset); bv_->fullCursor().innerText()->insertInset(inset);
unFreezeUndo(); unFreezeUndo();
return true; return true;
} }

View File

@ -295,7 +295,7 @@ void put_selection_at(BufferView * bv, PosIterator const & cur,
bv->top_y(par.outerPar()->y); bv->top_y(par.outerPar()->y);
bv->update(); bv->update();
text->setCursor(cur.pit(), cur.pos()); text->setCursor(cur.pit(), cur.pos());
bv->cursor().updatePos(); bv->fullCursor().updatePos();
if (length) { if (length) {
text->setSelectionRange(length); text->setSelectionRange(length);

View File

@ -32,17 +32,17 @@ using std::vector;
using std::endl; using std::endl;
std::ostream & operator<<(std::ostream & os, LCursor const & cursor) std::ostream & operator<<(std::ostream & os, LCursor const & cur)
{ {
os << "\n"; os << "\n";
for (size_t i = 0, n = cursor.data_.size(); i != n; ++i) for (size_t i = 0, n = cur.cursor_.size(); i != n; ++i)
os << " " << cursor.data_[i] << "\n"; os << " (" << cur.cursor_[i] << " | " << cur.anchor_[i] << "\n";
return os; return os;
} }
LCursor::LCursor(BufferView * bv) LCursor::LCursor(BufferView * bv)
: data_(1), bv_(bv) : cursor_(1), anchor_(1), bv_(bv)
{} {}
@ -51,8 +51,8 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
lyxerr << "\nLCursor::dispatch: " << *this << endl; lyxerr << "\nLCursor::dispatch: " << *this << endl;
FuncRequest cmd = cmd0; FuncRequest cmd = cmd0;
for (int i = data_.size() - 1; i >= 1; --i) { for (int i = cursor_.size() - 1; i >= 1; --i) {
CursorSlice const & citem = data_[i]; CursorSlice const & citem = cursor_[i];
lyxerr << "trying to dispatch to inset " << citem.inset_ << endl; lyxerr << "trying to dispatch to inset " << citem.inset_ << endl;
DispatchResult res = citem.inset_->dispatch(cmd); DispatchResult res = citem.inset_->dispatch(cmd);
if (res.dispatched()) { if (res.dispatched()) {
@ -100,7 +100,8 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
void LCursor::push(UpdatableInset * inset) void LCursor::push(UpdatableInset * inset)
{ {
lyxerr << "LCursor::push() inset: " << inset << endl; lyxerr << "LCursor::push() inset: " << inset << endl;
data_.push_back(CursorSlice(inset)); cursor_.push_back(CursorSlice(inset));
anchor_.push_back(CursorSlice(inset));
updatePos(); updatePos();
} }
@ -109,9 +110,10 @@ void LCursor::push(UpdatableInset * inset)
void LCursor::pop(int depth) void LCursor::pop(int depth)
{ {
lyxerr << "LCursor::pop() to " << depth << endl; lyxerr << "LCursor::pop() to " << depth << endl;
while (data_.size() > 1 && depth < data_.size()) { while (cursor_.size() > 1 && depth < cursor_.size()) {
lyxerr << "LCursor::pop a level " << endl; lyxerr << "LCursor::pop a level " << endl;
data_.pop_back(); cursor_.pop_back();
anchor_.pop_back();
} }
} }
@ -119,28 +121,30 @@ void LCursor::pop(int depth)
void LCursor::pop() void LCursor::pop()
{ {
lyxerr << "LCursor::pop() " << endl; lyxerr << "LCursor::pop() " << endl;
//BOOST_ASSERT(!data_.empty()); //BOOST_ASSERT(!cursor_.empty());
if (data_.size() <= 1) if (cursor_.size() <= 1)
lyxerr << "### TRYING TO POP FROM EMPTY CURSOR" << endl; lyxerr << "### TRYING TO POP FROM EMPTY CURSOR" << endl;
else else {
data_.pop_back(); cursor_.pop_back();
anchor_.pop_back();
}
} }
UpdatableInset * LCursor::innerInset() const UpdatableInset * LCursor::innerInset() const
{ {
return data_.size() <= 1 ? 0 : data_.back().asUpdatableInset(); return cursor_.size() <= 1 ? 0 : cursor_.back().asUpdatableInset();
} }
LyXText * LCursor::innerText() const LyXText * LCursor::innerText() const
{ {
if (data_.size() > 1) { if (cursor_.size() > 1) {
// go up until first non-0 text is hit // go up until first non-0 text is hit
// (innermost text is 0 e.g. for mathed and the outer tabular level) // (innermost text is 0 e.g. for mathed and the outer tabular level)
for (int i = data_.size() - 1; i >= 1; --i) for (int i = cursor_.size() - 1; i >= 1; --i)
if (data_[i].text()) if (cursor_[i].text())
return data_[i].text(); return cursor_[i].text();
} }
return bv_->text(); return bv_->text();
} }
@ -148,7 +152,7 @@ LyXText * LCursor::innerText() const
void LCursor::updatePos() void LCursor::updatePos()
{ {
if (data_.size() > 1) if (cursor_.size() > 1)
cached_y_ = bv_->top_y() + innerInset()->y(); cached_y_ = bv_->top_y() + innerInset()->y();
} }
@ -168,7 +172,7 @@ void LCursor::getDim(int & asc, int & desc) const
void LCursor::getPos(int & x, int & y) const void LCursor::getPos(int & x, int & y) const
{ {
if (data_.size() <= 1) { if (cursor_.size() <= 1) {
x = bv_->text()->cursorX(); x = bv_->text()->cursorX();
y = bv_->text()->cursorY(); y = bv_->text()->cursorY();
// y -= bv_->top_y(); // y -= bv_->top_y();
@ -182,7 +186,7 @@ void LCursor::getPos(int & x, int & y) const
// inset->draw() is not called: this doesn't update // inset->draw() is not called: this doesn't update
// inset.top_baseline, so getCursor() returns an old value. // inset.top_baseline, so getCursor() returns an old value.
// Ugly as you like. // Ugly as you like.
inset->getCursorPos(data_.back().idx_, x, y); inset->getCursorPos(cursor_.back().idx_, x, y);
x += inset->x(); x += inset->x();
y += cached_y_; y += cached_y_;
} }
@ -191,9 +195,9 @@ void LCursor::getPos(int & x, int & y) const
UpdatableInset * LCursor::innerInsetOfType(int code) const UpdatableInset * LCursor::innerInsetOfType(int code) const
{ {
for (int i = data_.size() - 1; i >= 1; --i) for (int i = cursor_.size() - 1; i >= 1; --i)
if (data_[i].asUpdatableInset()->lyxCode() == code) if (cursor_[i].asUpdatableInset()->lyxCode() == code)
return data_[i].asUpdatableInset(); return cursor_[i].asUpdatableInset();
return 0; return 0;
} }
@ -207,13 +211,19 @@ InsetTabular * LCursor::innerInsetTabular() const
void LCursor::cell(int idx) void LCursor::cell(int idx)
{ {
BOOST_ASSERT(!data_.empty()); BOOST_ASSERT(!cursor_.empty());
data_.back().idx_ = idx; cursor_.back().idx_ = idx;
} }
int LCursor::cell() const int LCursor::cell() const
{ {
BOOST_ASSERT(!data_.empty()); BOOST_ASSERT(!cursor_.empty());
return data_.back().idx_; return cursor_.back().idx_;
}
void LCursor::resetAnchor()
{
anchor_ = cursor_;
} }

View File

@ -49,9 +49,9 @@ public:
/// pop one level off the cursor /// pop one level off the cursor
void pop(); void pop();
/// access to cursor 'tip' /// access to cursor 'tip'
CursorSlice & top() { return data_.back(); } CursorSlice & top() { return cursor_.back(); }
/// access to cursor 'tip' /// access to cursor 'tip'
CursorSlice const & top() const { return data_.back(); } CursorSlice const & top() const { return cursor_.back(); }
/// set the cell the cursor is in /// set the cell the cursor is in
void cell(int); void cell(int);
@ -71,11 +71,15 @@ public:
void getDim(int & asc, int & desc) const; void getDim(int & asc, int & desc) const;
/// cache the absolute coordinate from the top inset /// cache the absolute coordinate from the top inset
void updatePos(); void updatePos();
/// sets anchor to cursor position
void resetAnchor();
/// ///
friend std::ostream & operator<<(std::ostream &, LCursor const &); friend std::ostream & operator<<(std::ostream &, LCursor const &);
public: public:
/// mainly used as stack, but wee need random access /// mainly used as stack, but wee need random access
std::vector<CursorSlice> data_; std::vector<CursorSlice> cursor_;
/// The
std::vector<CursorSlice> anchor_;
/// ///
BufferView * bv_; BufferView * bv_;
private: private:
@ -83,4 +87,9 @@ private:
int cached_y_; int cached_y_;
}; };
class LCursorS
{
};
#endif // LYXCURSOR_H #endif // LYXCURSOR_H

View File

@ -36,25 +36,37 @@ CursorSlice::CursorSlice(InsetBase * p)
} }
void CursorSlice::par(lyx::paroffset_type par) void CursorSlice::idx(idx_type idx)
{
idx_ = idx;
}
CursorSlice::idx_type CursorSlice::idx() const
{
return idx_;
}
void CursorSlice::par(par_type par)
{ {
par_ = par; par_ = par;
} }
lyx::paroffset_type CursorSlice::par() const CursorSlice::par_type CursorSlice::par() const
{ {
return par_; return par_;
} }
void CursorSlice::pos(lyx::pos_type pos) void CursorSlice::pos(pos_type pos)
{ {
pos_ = pos; pos_ = pos;
} }
lyx::pos_type CursorSlice::pos() const CursorSlice::pos_type CursorSlice::pos() const
{ {
return pos_; return pos_;
} }
@ -87,6 +99,7 @@ UpdatableInset * CursorSlice::asUpdatableInset() const
MathArray & CursorSlice::cell(CursorSlice::idx_type idx) const MathArray & CursorSlice::cell(CursorSlice::idx_type idx) const
{ {
BOOST_ASSERT(inset_); BOOST_ASSERT(inset_);
BOOST_ASSERT(asMathInset());
return asMathInset()->cell(idx); return asMathInset()->cell(idx);
} }
@ -100,6 +113,7 @@ MathArray & CursorSlice::cell() const
void CursorSlice::getPos(int & x, int & y) const void CursorSlice::getPos(int & x, int & y) const
{ {
BOOST_ASSERT(inset_);
asMathInset()->getPos(idx_, pos_, x, y); asMathInset()->getPos(idx_, pos_, x, y);
} }

View File

@ -51,11 +51,15 @@ public:
explicit CursorSlice(InsetBase *); explicit CursorSlice(InsetBase *);
/// set the paragraph that contains this cursor /// set the paragraph that contains this cursor
void par(par_type pit); void idx(idx_type idx);
/// return the paragraph this cursor is in
idx_type idx() const;
/// set the paragraph that contains this cursor
void par(par_type par);
/// return the paragraph this cursor is in /// return the paragraph this cursor is in
par_type par() const; par_type par() const;
/// set the position within the paragraph /// set the position within the paragraph
void pos(pos_type p); void pos(pos_type pos);
/// return the position within the paragraph /// return the position within the paragraph
pos_type pos() const; pos_type pos() const;

View File

@ -172,7 +172,7 @@ void LyXScreen::showCursor(BufferView & bv)
int h = ascent + descent; int h = ascent + descent;
int x = 0; int x = 0;
int y = 0; int y = 0;
bv.cursor().getPos(x, y); bv.fullCursor().getPos(x, y);
y -= ascent + bv.top_y(); y -= ascent + bv.top_y();
//lyxerr << "LyXScreen::showCursor x: " << x << " y: " << y << endl; //lyxerr << "LyXScreen::showCursor x: " << x << " y: " << y << endl;
@ -211,8 +211,8 @@ bool LyXScreen::fitCursor(BufferView * bv)
int newtop = top_y; int newtop = top_y;
int x, y, asc, desc; int x, y, asc, desc;
bv->cursor().getPos(x, y); bv->fullCursor().getPos(x, y);
bv->cursor().getDim(asc, desc); bv->fullCursor().getDim(asc, desc);
bool const big_row = h / 4 < asc + desc && asc + desc < h; bool const big_row = h / 4 < asc + desc && asc + desc < h;

View File

@ -308,7 +308,7 @@ void InsetCollapsable::edit(BufferView * bv, bool left)
lyxerr << "InsetCollapsable: edit left/right" << endl; lyxerr << "InsetCollapsable: edit left/right" << endl;
inset.edit(bv, left); inset.edit(bv, left);
open(); open();
bv->cursor().push(this); bv->fullCursor().push(this);
} }
@ -324,7 +324,7 @@ void InsetCollapsable::edit(BufferView * bv, int x, int y)
y += inset.ascent() - height_collapsed(); y += inset.ascent() - height_collapsed();
} }
inset.edit(bv, x, y); inset.edit(bv, x, y);
bv->cursor().push(this); bv->fullCursor().push(this);
} }

View File

@ -398,14 +398,14 @@ void InsetTabular::lfunMousePress(FuncRequest const & cmd)
lyxerr << "# InsetTabular::lfunMousePress cell: " << cell << endl; lyxerr << "# InsetTabular::lfunMousePress cell: " << cell << endl;
if (cell == -1) { if (cell == -1) {
tablemode = true; tablemode = true;
bv->cursor() = theTempCursor; bv->fullCursor(theTempCursor);
bv->cursor().data_.push_back(CursorSlice(this)); bv->fullCursor().push(this);
bv->cursor().cell(cell); bv->fullCursor().cell(cell);
} else { } else {
tablemode = false; tablemode = false;
setPos(bv, cmd.x, cmd.y); setPos(bv, cmd.x, cmd.y);
bv->cursor() = theTempCursor; bv->fullCursor(theTempCursor);
bv->cursor().cell(cell); bv->fullCursor().cell(cell);
} }
lyxerr << bv->cursor() << endl; lyxerr << bv->cursor() << endl;
@ -461,8 +461,8 @@ void InsetTabular::edit(BufferView * bv, bool left)
clearSelection(); clearSelection();
resetPos(bv); resetPos(bv);
bv->fitCursor(); bv->fitCursor();
bv->cursor().push(this); bv->fullCursor().push(this);
bv->cursor().cell(cell); bv->fullCursor().cell(cell);
lyxerr << bv->cursor() << endl; lyxerr << bv->cursor() << endl;
} }
@ -477,7 +477,7 @@ void InsetTabular::edit(BufferView * bv, int x, int y)
clearSelection(); clearSelection();
finishUndo(); finishUndo();
//int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell); //int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
bv->cursor().push(this); bv->fullCursor().push(this);
//if (x > xx) //if (x > xx)
// activateCellInset(bv, cell, x - xx, y - cursory_); // activateCellInset(bv, cell, x - xx, y - cursory_);
} }
@ -511,7 +511,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
break; break;
} }
CursorSlice & cur = bv->cursor().data_.back(); CursorSlice & cur = bv->cursor();
if (!tablemode) { if (!tablemode) {
@ -677,7 +677,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
case LFUN_NEXT: { case LFUN_NEXT: {
if (hasSelection()) if (hasSelection())
clearSelection(); clearSelection();
int actcell = bv->cursor().cell(); int actcell = bv->cursor().idx();
int actcol = tabular.column_of_cell(actcell); int actcol = tabular.column_of_cell(actcell);
int column = actcol; int column = actcol;
if (bv->top_y() + bv->painter().paperHeight() if (bv->top_y() + bv->painter().paperHeight()
@ -695,7 +695,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
case LFUN_PRIOR: { case LFUN_PRIOR: {
if (hasSelection()) if (hasSelection())
clearSelection(); clearSelection();
int actcell = bv->cursor().cell(); int actcell = bv->cursor().idx();
int actcol = tabular.column_of_cell(actcell); int actcol = tabular.column_of_cell(actcell);
int column = actcol; int column = actcol;
if (yo_ < 0) { if (yo_ < 0) {
@ -1278,7 +1278,7 @@ void checkLongtableSpecial(LyXTabular::ltType & ltt,
void InsetTabular::tabularFeatures(BufferView * bv, void InsetTabular::tabularFeatures(BufferView * bv,
LyXTabular::Feature feature, string const & value) LyXTabular::Feature feature, string const & value)
{ {
int actcell = bv->cursor().cell(); int actcell = bv->cursor().idx();
int sel_col_start; int sel_col_start;
int sel_col_end; int sel_col_end;
int sel_row_start; int sel_row_start;
@ -1881,7 +1881,7 @@ bool InsetTabular::pasteSelection(BufferView * bv)
{ {
if (!paste_tabular) if (!paste_tabular)
return false; return false;
int actcell = bv->cursor().cell(); int actcell = bv->cursor().idx();
int actcol = tabular.column_of_cell(actcell); int actcol = tabular.column_of_cell(actcell);
int actrow = tabular.row_of_cell(actcell); int actrow = tabular.row_of_cell(actcell);
for (int r1 = 0, r2 = actrow; for (int r1 = 0, r2 = actrow;
@ -2019,7 +2019,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
string::size_type len = buf.length(); string::size_type len = buf.length();
string::size_type p = 0; string::size_type p = 0;
int actcell = bv->cursor().cell(); int actcell = bv->cursor().idx();
int actcol = tabular.column_of_cell(actcell); int actcol = tabular.column_of_cell(actcell);
int actrow = tabular.row_of_cell(actcell); int actrow = tabular.row_of_cell(actcell);

View File

@ -314,7 +314,7 @@ DispatchResult InsetText::priv_dispatch(FuncRequest const & cmd,
switch (cmd.action) { switch (cmd.action) {
case LFUN_MOUSE_PRESS: case LFUN_MOUSE_PRESS:
bv->cursor() = theTempCursor; bv->fullCursor(theTempCursor);
// fall through // fall through
default: default:
result = text_.dispatch(cmd); result = text_.dispatch(cmd);

View File

@ -401,7 +401,7 @@ ParIterator::ParIterator(PosIterator const & pos)
void ParIterator::lockPath(BufferView * bv) const void ParIterator::lockPath(BufferView * bv) const
{ {
bv->cursor() = LCursor(bv); bv->fullCursor() = LCursor(bv);
int last = size() - 1; int last = size() - 1;
#warning this seems to create just one entry for InsetTabulars #warning this seems to create just one entry for InsetTabulars
for (int i = 0; i < last; ++i) for (int i = 0; i < last; ++i)

View File

@ -157,8 +157,8 @@ void LyXFunc::handleKeyFunc(kb_action action)
// actions // actions
keyseq.clear(); keyseq.clear();
// copied verbatim from do_accent_char // copied verbatim from do_accent_char
view()->resetAnchor();
view()->update(); view()->update();
view()->getLyXText()->anchor() = view()->getLyXText()->cursor();
} }
@ -322,8 +322,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
} }
} }
UpdatableInset * tli = view()->cursor().innerInset(); UpdatableInset * tli = view()->fullCursor().innerInset();
InsetTabular * tab = view()->cursor().innerInsetTabular(); InsetTabular * tab = view()->fullCursor().innerInsetTabular();
// I would really like to avoid having this switch and rather try to // I would really like to avoid having this switch and rather try to
// encode this in the function itself. // encode this in the function itself.
@ -356,7 +356,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
break; break;
case LFUN_LAYOUT_TABULAR: case LFUN_LAYOUT_TABULAR:
disable = !view()->cursor().innerInsetTabular(); disable = !view()->fullCursor().innerInsetTabular();
break; break;
case LFUN_DEPTH_MIN: case LFUN_DEPTH_MIN:
@ -471,7 +471,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
case LFUN_INSET_SETTINGS: { case LFUN_INSET_SETTINGS: {
disable = true; disable = true;
UpdatableInset * inset = view()->cursor().innerInset(); UpdatableInset * inset = view()->fullCursor().innerInset();
if (!inset) if (!inset)
break; break;
@ -543,7 +543,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
disable = !Exporter::IsExportable(*buf, "dvi") || disable = !Exporter::IsExportable(*buf, "dvi") ||
lyxrc.print_command == "none"; lyxrc.print_command == "none";
} else if (name == "character") { } else if (name == "character") {
UpdatableInset * tli = view()->cursor().innerInset(); UpdatableInset * tli = view()->fullCursor().innerInset();
disable = tli && tli->lyxCode() == InsetOld::ERT_CODE; disable = tli && tli->lyxCode() == InsetOld::ERT_CODE;
} else if (name == "vclog") { } else if (name == "vclog") {
disable = !buf->lyxvc().inUse(); disable = !buf->lyxvc().inUse();
@ -866,7 +866,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
case LFUN_ESCAPE: { case LFUN_ESCAPE: {
if (!view()->available()) if (!view()->available())
break; break;
view()->cursor().pop(); view()->fullCursor().pop();
// Tell the paragraph dialog that we changed paragraph // Tell the paragraph dialog that we changed paragraph
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE)); dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
break; break;
@ -1101,7 +1101,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
break; break;
case LFUN_LAYOUT_TABULAR: case LFUN_LAYOUT_TABULAR:
if (InsetTabular * tab = view()->cursor().innerInsetTabular()) if (InsetTabular * tab = view()->fullCursor().innerInsetTabular())
tab->openLayoutDialog(view()); tab->openLayoutDialog(view());
break; break;
@ -1449,7 +1449,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
default: { default: {
DispatchResult result = DispatchResult result =
view()->cursor().dispatch(FuncRequest(func, view())); view()->fullCursor().dispatch(FuncRequest(func, view()));
if (result.dispatched()) if (result.dispatched())
lyxerr << "dispatched by Cursor::dispatch()" << endl; lyxerr << "dispatched by Cursor::dispatch()" << endl;
else else
@ -1464,7 +1464,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
if (view()->available()) { if (view()->available()) {
view()->fitCursor(); view()->fitCursor();
view()->update(); view()->update();
view()->cursor().updatePos(); view()->fullCursor().updatePos();
// if we executed a mutating lfun, mark the buffer as dirty // if we executed a mutating lfun, mark the buffer as dirty
if (!getStatus(func).disabled() if (!getStatus(func).disabled()
&& !lyxaction.funcHasFlag(func.action, LyXAction::NoBuffer) && !lyxaction.funcHasFlag(func.action, LyXAction::NoBuffer)

View File

@ -313,7 +313,7 @@ void InsetFormulaBase::edit(BufferView * bv, bool left)
lyxerr << "Called FormulaBase::edit" << endl; lyxerr << "Called FormulaBase::edit" << endl;
releaseMathCursor(bv); releaseMathCursor(bv);
mathcursor = new MathCursor(this, left); mathcursor = new MathCursor(this, left);
bv->cursor().push(this); bv->fullCursor().push(this);
// if that is removed, we won't get the magenta box when entering an // if that is removed, we won't get the magenta box when entering an
// inset for the first time // inset for the first time
bv->update(); bv->update();
@ -327,7 +327,7 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int y)
mathcursor = new MathCursor(this, true); mathcursor = new MathCursor(this, true);
//metrics(bv); //metrics(bv);
mathcursor->setPos(x + xo_, y + yo_); mathcursor->setPos(x + xo_, y + yo_);
bv->cursor().push(this); bv->fullCursor().push(this);
// if that is removed, we won't get the magenta box when entering an // if that is removed, we won't get the magenta box when entering an
// inset for the first time // inset for the first time
bv->update(); bv->update();
@ -901,7 +901,7 @@ void mathDispatchCreation(FuncRequest const & cmd, bool display)
if (sel.empty()) { if (sel.empty()) {
InsetFormula * f = new InsetFormula(bv); InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) { if (openNewInset(bv, f)) {
bv->cursor().innerInset()-> bv->fullCursor().innerInset()->
dispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple")); dispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
// don't do that also for LFUN_MATH_MODE unless you want end up with // don't do that also for LFUN_MATH_MODE unless you want end up with
// always changing to mathrm when opening an inlined inset // always changing to mathrm when opening an inlined inset
@ -964,7 +964,7 @@ void mathDispatch(FuncRequest const & cmd)
case LFUN_MATH_DELIM: { case LFUN_MATH_DELIM: {
InsetFormula * f = new InsetFormula(bv); InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) { if (openNewInset(bv, f)) {
UpdatableInset * inset = bv->cursor().innerInset(); UpdatableInset * inset = bv->fullCursor().innerInset();
inset->dispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple")); inset->dispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
inset->dispatch(cmd); inset->dispatch(cmd);
} }

View File

@ -132,7 +132,7 @@ RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
paintBackground(); paintBackground();
// paint the selection background // paint the selection background
if (text_.selection.set() && &text_ == bv_.cursor().innerText()) if (text_.selection.set() && &text_ == bv_.fullCursor().innerText())
paintSelection(); paintSelection();
// vertical lines for appendix // vertical lines for appendix

View File

@ -1104,7 +1104,7 @@ void LyXText::selectWord(word_location loc)
setCursor(from.par(), from.pos()); setCursor(from.par(), from.pos());
if (to == from) if (to == from)
return; return;
anchor() = cursor(); bv()->resetAnchor();
setCursor(to.par(), to.pos()); setCursor(to.par(), to.pos());
setSelection(); setSelection();
} }
@ -1170,7 +1170,7 @@ void LyXText::deleteWordForward()
selection.set(true); // to avoid deletion selection.set(true); // to avoid deletion
cursorRightOneWord(); cursorRightOneWord();
setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
anchor() = cursor(); bv()->resetAnchor();
cursor() = tmpcursor; cursor() = tmpcursor;
setSelection(); setSelection();
cutSelection(true, false); cutSelection(true, false);
@ -1188,7 +1188,7 @@ void LyXText::deleteWordBackward()
selection.set(true); // to avoid deletion selection.set(true); // to avoid deletion
cursorLeftOneWord(); cursorLeftOneWord();
setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
anchor() = cursor(); bv()->resetAnchor();
cursor() = tmpcursor; cursor() = tmpcursor;
setSelection(); setSelection();
cutSelection(true, false); cutSelection(true, false);
@ -1207,7 +1207,7 @@ void LyXText::deleteLineForward()
selection.set(true); // to avoid deletion selection.set(true); // to avoid deletion
cursorEnd(); cursorEnd();
setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
anchor() = cursor(); bv()->resetAnchor();
cursor() = tmpcursor; cursor() = tmpcursor;
setSelection(); setSelection();
// What is this test for ??? (JMarc) // What is this test for ??? (JMarc)
@ -1601,7 +1601,7 @@ void LyXText::redoParagraph(ParagraphList::iterator pit)
void LyXText::fullRebreak() void LyXText::fullRebreak()
{ {
redoParagraphs(paragraphs().begin(), paragraphs().end()); redoParagraphs(paragraphs().begin(), paragraphs().end());
anchor() = cursor(); bv()->resetAnchor();
} }
@ -1937,25 +1937,25 @@ int LyXText::cursorY(CursorSlice const & cur) const
CursorSlice & LyXText::cursor() CursorSlice & LyXText::cursor()
{ {
return bv()->cursor().top(); return bv()->cursor();
} }
CursorSlice const & LyXText::cursor() const CursorSlice const & LyXText::cursor() const
{ {
return bv()->cursor().top(); return bv()->cursor();
} }
CursorSlice & LyXText::anchor() CursorSlice & LyXText::anchor()
{ {
return anchor_; return bv()->anchor();
} }
CursorSlice const & LyXText::anchor() const CursorSlice const & LyXText::anchor() const
{ {
return anchor_; return bv()->anchor();
} }
@ -2005,7 +2005,7 @@ void LyXText::clearSelection()
{ {
selection.set(false); selection.set(false);
selection.mark(false); selection.mark(false);
anchor() = cursor(); bv()->resetAnchor();
// reset this in the bv()! // reset this in the bv()!
if (bv() && bv()->text()) if (bv() && bv()->text())
bv()->unsetXSel(); bv()->unsetXSel();

View File

@ -95,7 +95,7 @@ void LyXText::init(BufferView * bview)
redoParagraphs(beg, end); redoParagraphs(beg, end);
setCursorIntern(0, 0); setCursorIntern(0, 0);
anchor() = cursor(); bv()->resetAnchor();
updateCounters(); updateCounters();
} }
@ -532,7 +532,7 @@ void LyXText::toggleFree(LyXFont const & font, bool toggleall)
if (implicitSelection) { if (implicitSelection) {
clearSelection(); clearSelection();
cursor() = resetCursor; cursor() = resetCursor;
anchor() = cursor(); bv()->resetAnchor();
} }
} }
@ -556,7 +556,7 @@ string LyXText::getStringToIndex()
// Reset cursors to their original position. // Reset cursors to their original position.
cursor() = reset_cursor; cursor() = reset_cursor;
anchor() = cursor(); bv()->resetAnchor();
// Clear the implicit selection. // Clear the implicit selection.
if (implicitSelection) if (implicitSelection)
@ -1026,7 +1026,7 @@ void LyXText::pasteSelection(size_t sel_index)
clearSelection(); clearSelection();
anchor() = cursor(); bv()->resetAnchor();
setCursor(ppp.first, ppp.second); setCursor(ppp.first, ppp.second);
setSelection(); setSelection();
updateCounters(); updateCounters();
@ -1038,7 +1038,7 @@ void LyXText::setSelectionRange(lyx::pos_type length)
if (!length) if (!length)
return; return;
anchor() = cursor(); bv()->resetAnchor();
while (length--) while (length--)
cursorRight(true); cursorRight(true);
setSelection(); setSelection();
@ -1087,7 +1087,7 @@ void LyXText::insertStringAsLines(string const & str)
bv()->buffer()->insertStringAsLines(pit, pos, current_font, str); bv()->buffer()->insertStringAsLines(pit, pos, current_font, str);
redoParagraphs(cursorPar(), endpit); redoParagraphs(cursorPar(), endpit);
anchor() = cursor(); bv()->resetAnchor();
setCursor(pit, pos); setCursor(pit, pos);
setSelection(); setSelection();
} }
@ -1673,7 +1673,7 @@ bool LyXText::deleteEmptyParagraphMechanism(CursorSlice const & old_cursor)
if (selection_position_was_oldcursor_position) { if (selection_position_was_oldcursor_position) {
// correct selection // correct selection
anchor() = cursor(); bv()->resetAnchor();
} }
} }
@ -1682,7 +1682,7 @@ bool LyXText::deleteEmptyParagraphMechanism(CursorSlice const & old_cursor)
if (old_pit->stripLeadingSpaces()) { if (old_pit->stripLeadingSpaces()) {
redoParagraph(old_pit); redoParagraph(old_pit);
anchor() = cursor(); bv()->resetAnchor();
} }
return false; return false;
} }

View File

@ -349,7 +349,7 @@ void LyXText::gotoInset(vector<InsetOld::Code> const & codes,
} }
} }
bv()->update(); bv()->update();
anchor() = cursor(); bv()->resetAnchor();
} }
@ -543,7 +543,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_RIGHTSEL: case LFUN_RIGHTSEL:
if (!selection.set()) if (!selection.set())
anchor() = cursor(); bv->resetAnchor();
if (rtl()) if (rtl())
cursorLeft(bv); cursorLeft(bv);
else else
@ -553,7 +553,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_LEFTSEL: case LFUN_LEFTSEL:
if (!selection.set()) if (!selection.set())
anchor() = cursor(); bv->resetAnchor();
if (rtl()) if (rtl())
cursorRight(bv); cursorRight(bv);
else else
@ -563,56 +563,56 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_UPSEL: case LFUN_UPSEL:
if (!selection.set()) if (!selection.set())
anchor() = cursor(); bv->resetAnchor();
cursorUp(true); cursorUp(true);
finishChange(bv, true); finishChange(bv, true);
break; break;
case LFUN_DOWNSEL: case LFUN_DOWNSEL:
if (!selection.set()) if (!selection.set())
anchor() = cursor(); bv->resetAnchor();
cursorDown(true); cursorDown(true);
finishChange(bv, true); finishChange(bv, true);
break; break;
case LFUN_UP_PARAGRAPHSEL: case LFUN_UP_PARAGRAPHSEL:
if (!selection.set()) if (!selection.set())
anchor() = cursor(); bv->resetAnchor();
cursorUpParagraph(); cursorUpParagraph();
finishChange(bv, true); finishChange(bv, true);
break; break;
case LFUN_DOWN_PARAGRAPHSEL: case LFUN_DOWN_PARAGRAPHSEL:
if (!selection.set()) if (!selection.set())
anchor() = cursor(); bv->resetAnchor();
cursorDownParagraph(); cursorDownParagraph();
finishChange(bv, true); finishChange(bv, true);
break; break;
case LFUN_PRIORSEL: case LFUN_PRIORSEL:
if (!selection.set()) if (!selection.set())
anchor() = cursor(); bv->resetAnchor();
cursorPrevious(); cursorPrevious();
finishChange(bv, true); finishChange(bv, true);
break; break;
case LFUN_NEXTSEL: case LFUN_NEXTSEL:
if (!selection.set()) if (!selection.set())
anchor() = cursor(); bv->resetAnchor();
cursorNext(); cursorNext();
finishChange(bv, true); finishChange(bv, true);
break; break;
case LFUN_HOMESEL: case LFUN_HOMESEL:
if (!selection.set()) if (!selection.set())
anchor() = cursor(); bv->resetAnchor();
cursorHome(); cursorHome();
finishChange(bv, true); finishChange(bv, true);
break; break;
case LFUN_ENDSEL: case LFUN_ENDSEL:
if (!selection.set()) if (!selection.set())
anchor() = cursor(); bv->resetAnchor();
cursorEnd(); cursorEnd();
finishChange(bv, true); finishChange(bv, true);
break; break;
@ -722,7 +722,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_DELETE: case LFUN_DELETE:
if (!selection.set()) { if (!selection.set()) {
Delete(); Delete();
anchor() = cursor(); bv->resetAnchor();
// It is possible to make it a lot faster still // It is possible to make it a lot faster still
// just comment out the line below... // just comment out the line below...
} else { } else {
@ -739,10 +739,10 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
cursorRight(bv); cursorRight(bv);
cursorLeft(bv); cursorLeft(bv);
Delete(); Delete();
anchor() = cursor(); bv->resetAnchor();
} else { } else {
Delete(); Delete();
anchor() = cursor(); bv->resetAnchor();
} }
} else { } else {
cutSelection(true, false); cutSelection(true, false);
@ -755,7 +755,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
if (!selection.set()) { if (!selection.set()) {
if (bv->owner()->getIntl().getTransManager().backspace()) { if (bv->owner()->getIntl().getTransManager().backspace()) {
backspace(); backspace();
anchor() = cursor(); bv->resetAnchor();
// It is possible to make it a lot faster still // It is possible to make it a lot faster still
// just comment out the line below... // just comment out the line below...
} }
@ -783,7 +783,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
replaceSelection(bv->getLyXText()); replaceSelection(bv->getLyXText());
breakParagraph(bv->buffer()->paragraphs(), 0); breakParagraph(bv->buffer()->paragraphs(), 0);
bv->update(); bv->update();
anchor() = cursor(); bv->resetAnchor();
bv->switchKeyMap(); bv->switchKeyMap();
bv->owner()->view_state_changed(); bv->owner()->view_state_changed();
break; break;
@ -792,7 +792,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
replaceSelection(bv->getLyXText()); replaceSelection(bv->getLyXText());
breakParagraph(bv->buffer()->paragraphs(), 1); breakParagraph(bv->buffer()->paragraphs(), 1);
bv->update(); bv->update();
anchor() = cursor(); bv->resetAnchor();
bv->switchKeyMap(); bv->switchKeyMap();
bv->owner()->view_state_changed(); bv->owner()->view_state_changed();
break; break;
@ -882,7 +882,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
} }
case LFUN_INSET_SETTINGS: case LFUN_INSET_SETTINGS:
bv->cursor().innerInset()->showInsetDialog(bv); bv->fullCursor().innerInset()->showInsetDialog(bv);
break; break;
case LFUN_INSET_TOGGLE: case LFUN_INSET_TOGGLE:
@ -924,7 +924,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_MARK_OFF: case LFUN_MARK_OFF:
clearSelection(); clearSelection();
bv->update(); bv->update();
anchor() = cursor(); bv->resetAnchor();
cmd.message(N_("Mark off")); cmd.message(N_("Mark off"));
break; break;
@ -932,7 +932,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
clearSelection(); clearSelection();
selection.mark(true); selection.mark(true);
bv->update(); bv->update();
anchor() = cursor(); bv->resetAnchor();
cmd.message(N_("Mark on")); cmd.message(N_("Mark on"));
break; break;
@ -944,7 +944,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
selection.mark(true); selection.mark(true);
cmd.message(N_("Mark set")); cmd.message(N_("Mark set"));
} }
anchor() = cursor(); bv->resetAnchor();
bv->update(); bv->update();
break; break;
@ -998,7 +998,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
if (in_inset_) if (in_inset_)
return DispatchResult(false); return DispatchResult(false);
if (!selection.set()) if (!selection.set())
anchor() = cursor(); bv->resetAnchor();
cursorTop(); cursorTop();
finishChange(bv, true); finishChange(bv, true);
break; break;
@ -1007,7 +1007,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
if (in_inset_) if (in_inset_)
return DispatchResult(false); return DispatchResult(false);
if (!selection.set()) if (!selection.set())
anchor() = cursor(); bv->resetAnchor();
cursorBottom(); cursorBottom();
finishChange(bv, true); finishChange(bv, true);
break; break;
@ -1171,7 +1171,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
for (int i = 0; i < datetmp_len; i++) for (int i = 0; i < datetmp_len; i++)
insertChar(datetmp[i]); insertChar(datetmp[i]);
anchor() = cursor(); bv->resetAnchor();
moveCursor(bv, false); moveCursor(bv, false);
break; break;
} }
@ -1182,7 +1182,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
if (cmd.button() == mouse_button::button1) { if (cmd.button() == mouse_button::button1) {
selection_possible = true; selection_possible = true;
cursorHome(); cursorHome();
anchor() = cursor(); bv->resetAnchor();
cursorEnd(); cursorEnd();
setSelection(); setSelection();
bv->haveSelection(selection.set()); bv->haveSelection(selection.set());
@ -1270,7 +1270,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
} }
setCursorFromCoordinates(cmd.x, cmd.y); setCursorFromCoordinates(cmd.x, cmd.y);
anchor() = cursor(); bv->resetAnchor();
finishUndo(); finishUndo();
bv->x_target(cursorX() + xo_); bv->x_target(cursorX() + xo_);
@ -1340,7 +1340,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
bv->owner()->getIntl().getTransManager(). bv->owner()->getIntl().getTransManager().
TranslateAndInsert(*cit, this); TranslateAndInsert(*cit, this);
anchor() = cursor(); bv->resetAnchor();
moveCursor(bv, false); moveCursor(bv, false);
// real_current_font.number can change so we need to // real_current_font.number can change so we need to

View File

@ -183,7 +183,7 @@ bool performUndoOrRedo(BufferView * bv, Undo const & undo)
// clear any selection // clear any selection
text->clearSelection(); text->clearSelection();
text->anchor() = text->cursor(); bv->resetAnchor();
text->updateCounters(); text->updateCounters();
// rebreak the entire lyxtext // rebreak the entire lyxtext