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(
std::distance(text()->paragraphs().begin(), it.getPar()),
it.getPos());
text()->anchor() = text()->cursor();
resetAnchor();
update();
return;
}
@ -393,13 +393,13 @@ bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
UpdatableInset * BufferView::innerInset() const
{
return static_cast<UpdatableInset*>(cursor().innerInset());
return static_cast<UpdatableInset*>(fullCursor().innerInset());
}
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_;
}
LCursor const & BufferView::cursor() const
LCursor const & BufferView::fullCursor() const
{
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)
{
x_target_ = x;
@ -470,3 +500,9 @@ LyXText * BufferView::text() const
{
return pimpl_->buffer_ ? &pimpl_->buffer_->text() : 0;
}
void BufferView::resetAnchor()
{
return fullCursor().resetAnchor();
}

View File

@ -21,6 +21,7 @@
class Buffer;
class Change;
class CursorSlice;
class Encoding;
class ErrorList;
class FuncRequest;
@ -185,14 +186,26 @@ public:
/// clear the X selection
void unsetXSel();
/// access to cursor
LCursor & cursor();
/// access to cursor
LCursor const & cursor() const;
/// access to full cursor
LCursor & fullCursor();
/// access to full cursor
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;
///
LyXText * text() const;
///
void resetAnchor();
private:
///

View File

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

View File

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

View File

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

View File

@ -49,9 +49,9 @@ public:
/// pop one level off the cursor
void pop();
/// access to cursor 'tip'
CursorSlice & top() { return data_.back(); }
CursorSlice & top() { return cursor_.back(); }
/// 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
void cell(int);
@ -71,11 +71,15 @@ public:
void getDim(int & asc, int & desc) const;
/// cache the absolute coordinate from the top inset
void updatePos();
/// sets anchor to cursor position
void resetAnchor();
///
friend std::ostream & operator<<(std::ostream &, LCursor const &);
public:
/// mainly used as stack, but wee need random access
std::vector<CursorSlice> data_;
std::vector<CursorSlice> cursor_;
/// The
std::vector<CursorSlice> anchor_;
///
BufferView * bv_;
private:
@ -83,4 +87,9 @@ private:
int cached_y_;
};
class LCursorS
{
};
#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;
}
lyx::paroffset_type CursorSlice::par() const
CursorSlice::par_type CursorSlice::par() const
{
return par_;
}
void CursorSlice::pos(lyx::pos_type pos)
void CursorSlice::pos(pos_type pos)
{
pos_ = pos;
}
lyx::pos_type CursorSlice::pos() const
CursorSlice::pos_type CursorSlice::pos() const
{
return pos_;
}
@ -87,6 +99,7 @@ UpdatableInset * CursorSlice::asUpdatableInset() const
MathArray & CursorSlice::cell(CursorSlice::idx_type idx) const
{
BOOST_ASSERT(inset_);
BOOST_ASSERT(asMathInset());
return asMathInset()->cell(idx);
}
@ -100,6 +113,7 @@ MathArray & CursorSlice::cell() const
void CursorSlice::getPos(int & x, int & y) const
{
BOOST_ASSERT(inset_);
asMathInset()->getPos(idx_, pos_, x, y);
}

View File

@ -51,11 +51,15 @@ public:
explicit CursorSlice(InsetBase *);
/// 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
par_type par() const;
/// set the position within the paragraph
void pos(pos_type p);
void pos(pos_type pos);
/// return the position within the paragraph
pos_type pos() const;

View File

@ -172,7 +172,7 @@ void LyXScreen::showCursor(BufferView & bv)
int h = ascent + descent;
int x = 0;
int y = 0;
bv.cursor().getPos(x, y);
bv.fullCursor().getPos(x, y);
y -= ascent + bv.top_y();
//lyxerr << "LyXScreen::showCursor x: " << x << " y: " << y << endl;
@ -211,8 +211,8 @@ bool LyXScreen::fitCursor(BufferView * bv)
int newtop = top_y;
int x, y, asc, desc;
bv->cursor().getPos(x, y);
bv->cursor().getDim(asc, desc);
bv->fullCursor().getPos(x, y);
bv->fullCursor().getDim(asc, desc);
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;
inset.edit(bv, left);
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();
}
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;
if (cell == -1) {
tablemode = true;
bv->cursor() = theTempCursor;
bv->cursor().data_.push_back(CursorSlice(this));
bv->cursor().cell(cell);
bv->fullCursor(theTempCursor);
bv->fullCursor().push(this);
bv->fullCursor().cell(cell);
} else {
tablemode = false;
setPos(bv, cmd.x, cmd.y);
bv->cursor() = theTempCursor;
bv->cursor().cell(cell);
bv->fullCursor(theTempCursor);
bv->fullCursor().cell(cell);
}
lyxerr << bv->cursor() << endl;
@ -461,8 +461,8 @@ void InsetTabular::edit(BufferView * bv, bool left)
clearSelection();
resetPos(bv);
bv->fitCursor();
bv->cursor().push(this);
bv->cursor().cell(cell);
bv->fullCursor().push(this);
bv->fullCursor().cell(cell);
lyxerr << bv->cursor() << endl;
}
@ -477,7 +477,7 @@ void InsetTabular::edit(BufferView * bv, int x, int y)
clearSelection();
finishUndo();
//int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
bv->cursor().push(this);
bv->fullCursor().push(this);
//if (x > xx)
// activateCellInset(bv, cell, x - xx, y - cursory_);
}
@ -511,7 +511,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
break;
}
CursorSlice & cur = bv->cursor().data_.back();
CursorSlice & cur = bv->cursor();
if (!tablemode) {
@ -677,7 +677,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
case LFUN_NEXT: {
if (hasSelection())
clearSelection();
int actcell = bv->cursor().cell();
int actcell = bv->cursor().idx();
int actcol = tabular.column_of_cell(actcell);
int column = actcol;
if (bv->top_y() + bv->painter().paperHeight()
@ -695,7 +695,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
case LFUN_PRIOR: {
if (hasSelection())
clearSelection();
int actcell = bv->cursor().cell();
int actcell = bv->cursor().idx();
int actcol = tabular.column_of_cell(actcell);
int column = actcol;
if (yo_ < 0) {
@ -1278,7 +1278,7 @@ void checkLongtableSpecial(LyXTabular::ltType & ltt,
void InsetTabular::tabularFeatures(BufferView * bv,
LyXTabular::Feature feature, string const & value)
{
int actcell = bv->cursor().cell();
int actcell = bv->cursor().idx();
int sel_col_start;
int sel_col_end;
int sel_row_start;
@ -1881,7 +1881,7 @@ bool InsetTabular::pasteSelection(BufferView * bv)
{
if (!paste_tabular)
return false;
int actcell = bv->cursor().cell();
int actcell = bv->cursor().idx();
int actcol = tabular.column_of_cell(actcell);
int actrow = tabular.row_of_cell(actcell);
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 p = 0;
int actcell = bv->cursor().cell();
int actcell = bv->cursor().idx();
int actcol = tabular.column_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) {
case LFUN_MOUSE_PRESS:
bv->cursor() = theTempCursor;
bv->fullCursor(theTempCursor);
// fall through
default:
result = text_.dispatch(cmd);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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