mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
dociterator dont inherit from std::vector and updates
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9602 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4e100ec148
commit
aa491cdb98
@ -326,13 +326,14 @@ LyXText * BufferView::text() const
|
||||
|
||||
void BufferView::setCursor(ParIterator const & par, lyx::pos_type pos)
|
||||
{
|
||||
for (int i = 0, n = par.size(); i < n; ++i)
|
||||
for (int i = 0, n = par.depth(); i < n; ++i)
|
||||
par[i].inset().edit(cursor(), true);
|
||||
|
||||
cursor().setCursor(makeDocIterator(par, pos));
|
||||
cursor().selection() = false;
|
||||
}
|
||||
|
||||
|
||||
void BufferView::putSelectionAt(DocIterator const & cur,
|
||||
int length, bool backwards)
|
||||
{
|
||||
|
@ -484,7 +484,7 @@ void BufferView::Pimpl::scrollDocView(int value)
|
||||
}
|
||||
|
||||
|
||||
void BufferView::Pimpl::scroll(int lines)
|
||||
void BufferView::Pimpl::scroll(int /*lines*/)
|
||||
{
|
||||
// if (!buffer_)
|
||||
// return;
|
||||
@ -540,11 +540,11 @@ void BufferView::Pimpl::selectionRequested()
|
||||
}
|
||||
|
||||
if (!xsel_cache_.set ||
|
||||
cur.back() != xsel_cache_.cursor ||
|
||||
cur.anchor_.back() != xsel_cache_.anchor)
|
||||
cur.top() != xsel_cache_.cursor ||
|
||||
cur.anchor_.top() != xsel_cache_.anchor)
|
||||
{
|
||||
xsel_cache_.cursor = cur.back();
|
||||
xsel_cache_.anchor = cur.anchor_.back();
|
||||
xsel_cache_.cursor = cur.top();
|
||||
xsel_cache_.anchor = cur.anchor_.top();
|
||||
xsel_cache_.set = cur.selection();
|
||||
sel = cur.selectionAsString(false);
|
||||
if (!sel.empty())
|
||||
|
@ -1,3 +1,37 @@
|
||||
2005-02-08 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* text3.C (dispatch): size() -> depth()
|
||||
|
||||
* text2.C: remove some debug output
|
||||
|
||||
* paragraph.C: ws changes only
|
||||
|
||||
* lyxfunc.C (getStatus): size() -> depth()
|
||||
|
||||
* dociterator.h (clear, push_back, pop_back, internalData,
|
||||
operator[], resize, empty): new functions
|
||||
Make StableDocIterator and operator== be friends. Don't inherit
|
||||
from std::vector use a privat class variable slices_ instead.
|
||||
Modify to fit.
|
||||
|
||||
* dociterator.C: update because of not inheriting from std::vector
|
||||
anymore. Call explictly to slices_ instead. Use depth() instead of
|
||||
size() and top() instead of back()
|
||||
|
||||
* cursor.C: chagne size() -> depth and back() -> top(). Also
|
||||
remove some direct operator[](i) calls in favour of foo[i]
|
||||
(getFont): remove some dead code
|
||||
|
||||
* bufferview_funcs.C (coordOffset): size() -> depth()
|
||||
|
||||
* buffer.C: ws changes only
|
||||
|
||||
* CutAndPaste.C (eraseSelection): back() -> top()
|
||||
|
||||
* BufferView_pimpl.C (selectionRequested): back() -> top()
|
||||
|
||||
* BufferView.C (setCursor): size() -> depth()
|
||||
|
||||
2005-02-08 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* text3.C (cursorPrevious): return true if depm changed something
|
||||
|
@ -681,7 +681,7 @@ void eraseSelection(LCursor & cur)
|
||||
for (InsetBase::col_type col = c1; col <= c2; ++col)
|
||||
p->cell(p->index(row, col)).clear();
|
||||
}
|
||||
cur.back() = i1;
|
||||
cur.top() = i1;
|
||||
cur.pos() = 0; // We've deleted the whole cell. Only pos 0 is valid.
|
||||
cur.resetAnchor();
|
||||
} else {
|
||||
|
@ -482,7 +482,7 @@ void Buffer::insertStringAsLines(ParagraphList & pars,
|
||||
// insert the string, don't insert doublespace
|
||||
bool space_inserted = true;
|
||||
for (string::const_iterator cit = str.begin();
|
||||
cit != str.end(); ++cit) {
|
||||
cit != str.end(); ++cit) {
|
||||
Paragraph & par = pars[pit];
|
||||
if (*cit == '\n') {
|
||||
if (autobreakrows && (!par.empty() || par.allowEmpty())) {
|
||||
|
@ -156,9 +156,10 @@ Point coordOffset(DocIterator const & dit)
|
||||
int y = 0;
|
||||
|
||||
// Contribution of nested insets
|
||||
for (size_t i = 1; i != dit.size(); ++i) {
|
||||
for (size_t i = 1; i != dit.depth(); ++i) {
|
||||
CursorSlice const & sl = dit[i];
|
||||
int xx = 0, yy = 0;
|
||||
int xx = 0;
|
||||
int yy = 0;
|
||||
sl.inset().getCursorPos(sl, xx, yy);
|
||||
x += xx;
|
||||
y += yy;
|
||||
@ -184,7 +185,7 @@ Point getPos(DocIterator const & dit)
|
||||
CoordCache::InnerParPosCache::const_iterator it = cache.find(bot.pit());
|
||||
if (it == cache.end()) {
|
||||
//lyxerr << "cursor out of view" << std::endl;
|
||||
return Point(-1,-1);
|
||||
return Point(-1, -1);
|
||||
}
|
||||
Point p = coordOffset(dit); // offset from outer paragraph
|
||||
p.y_ += it->second.y_;
|
||||
|
75
src/cursor.C
75
src/cursor.C
@ -69,11 +69,11 @@ namespace {
|
||||
positionable(DocIterator const & cursor, DocIterator const & anchor)
|
||||
{
|
||||
// avoid deeper nested insets when selecting
|
||||
if (cursor.size() > anchor.size())
|
||||
if (cursor.depth() > anchor.depth())
|
||||
return false;
|
||||
|
||||
// anchor might be deeper, should have same path then
|
||||
for (size_t i = 0; i < cursor.size(); ++i)
|
||||
for (size_t i = 0; i < cursor.depth(); ++i)
|
||||
if (&cursor[i].inset() != &anchor[i].inset())
|
||||
return false;
|
||||
|
||||
@ -91,11 +91,12 @@ namespace {
|
||||
DocIterator result;
|
||||
|
||||
DocIterator it = c;
|
||||
it.back().pos() = 0;
|
||||
it.top().pos() = 0;
|
||||
DocIterator et = c;
|
||||
et.back().pos() = et.back().asMathInset()->cell(et.back().idx()).size();
|
||||
et.top().pos() = et.top().asMathInset()->cell(et.top().idx()).size();
|
||||
for (int i = 0; ; ++i) {
|
||||
int xo, yo;
|
||||
int xo;
|
||||
int yo;
|
||||
LCursor cur = c;
|
||||
cur.setCursor(it);
|
||||
cur.inset().getCursorPos(cur.top(), xo, yo);
|
||||
@ -192,15 +193,16 @@ void LCursor::setCursor(DocIterator const & cur)
|
||||
|
||||
void LCursor::dispatch(FuncRequest const & cmd0)
|
||||
{
|
||||
lyxerr[Debug::DEBUG] << "LCursor::dispatch: cmd: "
|
||||
<< cmd0 << endl << *this << endl;
|
||||
lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
|
||||
<< " cmd: " << cmd0 << '\n'
|
||||
<< *this << endl;
|
||||
if (empty())
|
||||
return;
|
||||
|
||||
FuncRequest cmd = cmd0;
|
||||
LCursor safe = *this;
|
||||
|
||||
for (; size(); pop()) {
|
||||
for (; depth(); pop()) {
|
||||
lyxerr[Debug::DEBUG] << "LCursor::dispatch: cmd: "
|
||||
<< cmd0 << endl << *this << endl;
|
||||
BOOST_ASSERT(pos() <= lastpos());
|
||||
@ -249,7 +251,7 @@ Buffer & LCursor::buffer() const
|
||||
|
||||
void LCursor::pop()
|
||||
{
|
||||
BOOST_ASSERT(size() >= 1);
|
||||
BOOST_ASSERT(depth() >= 1);
|
||||
pop_back();
|
||||
}
|
||||
|
||||
@ -297,7 +299,7 @@ bool LCursor::popRight()
|
||||
int LCursor::currentMode()
|
||||
{
|
||||
BOOST_ASSERT(!empty());
|
||||
for (int i = size() - 1; i >= 0; --i) {
|
||||
for (int i = depth() - 1; i >= 0; --i) {
|
||||
int res = operator[](i).inset().currentMode();
|
||||
if (res != InsetBase::UNDECIDED_MODE)
|
||||
return res;
|
||||
@ -347,9 +349,9 @@ bool LCursor::posRight()
|
||||
|
||||
CursorSlice LCursor::anchor() const
|
||||
{
|
||||
BOOST_ASSERT(anchor_.size() >= size());
|
||||
CursorSlice normal = anchor_[size() - 1];
|
||||
if (size() < anchor_.size() && back() <= normal) {
|
||||
BOOST_ASSERT(anchor_.depth() >= depth());
|
||||
CursorSlice normal = anchor_[depth() - 1];
|
||||
if (depth() < anchor_.depth() && top() <= normal) {
|
||||
// anchor is behind cursor -> move anchor behind the inset
|
||||
++normal.pos();
|
||||
}
|
||||
@ -360,16 +362,16 @@ CursorSlice LCursor::anchor() const
|
||||
CursorSlice LCursor::selBegin() const
|
||||
{
|
||||
if (!selection())
|
||||
return back();
|
||||
return anchor() < back() ? anchor() : back();
|
||||
return top();
|
||||
return anchor() < top() ? anchor() : top();
|
||||
}
|
||||
|
||||
|
||||
CursorSlice LCursor::selEnd() const
|
||||
{
|
||||
if (!selection())
|
||||
return back();
|
||||
return anchor() > back() ? anchor() : back();
|
||||
return top();
|
||||
return anchor() > top() ? anchor() : top();
|
||||
}
|
||||
|
||||
|
||||
@ -377,7 +379,7 @@ DocIterator LCursor::selectionBegin() const
|
||||
{
|
||||
if (!selection())
|
||||
return *this;
|
||||
return anchor() < back() ? anchor_ : *this;
|
||||
return anchor() < top() ? anchor_ : *this;
|
||||
}
|
||||
|
||||
|
||||
@ -385,7 +387,7 @@ DocIterator LCursor::selectionEnd() const
|
||||
{
|
||||
if (!selection())
|
||||
return *this;
|
||||
return anchor() > back() ? anchor_ : *this;
|
||||
return anchor() > top() ? anchor_ : *this;
|
||||
}
|
||||
|
||||
|
||||
@ -465,15 +467,15 @@ void LCursor::selHandle(bool sel)
|
||||
std::ostream & operator<<(std::ostream & os, LCursor const & cur)
|
||||
{
|
||||
os << "\n cursor: | anchor:\n";
|
||||
for (size_t i = 0, n = cur.size(); i != n; ++i) {
|
||||
os << " " << cur.operator[](i) << " | ";
|
||||
if (i < cur.anchor_.size())
|
||||
for (size_t i = 0, n = cur.depth(); i != n; ++i) {
|
||||
os << " " << cur[i] << " | ";
|
||||
if (i < cur.anchor_.depth())
|
||||
os << cur.anchor_[i];
|
||||
else
|
||||
os << "-------------------------------";
|
||||
os << "\n";
|
||||
}
|
||||
for (size_t i = cur.size(), n = cur.anchor_.size(); i < n; ++i) {
|
||||
for (size_t i = cur.depth(), n = cur.anchor_.depth(); i < n; ++i) {
|
||||
os << "------------------------------- | " << cur.anchor_[i] << "\n";
|
||||
}
|
||||
os << " selection: " << cur.selection_
|
||||
@ -525,7 +527,7 @@ bool LCursor::openable(MathAtom const & t) const
|
||||
return true;
|
||||
|
||||
// we can't move into anything new during selection
|
||||
if (depth() >= anchor_.size())
|
||||
if (depth() >= anchor_.depth())
|
||||
return false;
|
||||
if (!ptr_cmp(t.nucleus(), &anchor_[depth()].inset()))
|
||||
return false;
|
||||
@ -620,7 +622,7 @@ void LCursor::niceInsert(string const & t)
|
||||
void LCursor::niceInsert(MathAtom const & t)
|
||||
{
|
||||
macroModeClose();
|
||||
string safe = lyx::cap::grabAndEraseSelection(*this);
|
||||
string const safe = lyx::cap::grabAndEraseSelection(*this);
|
||||
plainInsert(t);
|
||||
// enter the new inset and move the contents of the selection if possible
|
||||
if (t->isActive()) {
|
||||
@ -752,7 +754,7 @@ void LCursor::macroModeClose()
|
||||
return;
|
||||
MathUnknownInset * p = activeMacro();
|
||||
p->finalize();
|
||||
string s = p->name();
|
||||
string const s = p->name();
|
||||
--pos();
|
||||
cell().erase(pos());
|
||||
|
||||
@ -803,10 +805,11 @@ int LCursor::targetX() const
|
||||
|
||||
void LCursor::setTargetX()
|
||||
{
|
||||
//for now this is good enough. A better solution would be to
|
||||
//avoid this rebreak by setting cursorX only after drawing
|
||||
// For now this is good enough. A better solution would be to
|
||||
// avoid this rebreak by setting cursorX only after drawing
|
||||
bottom().text()->redoParagraph(bottom().pit());
|
||||
int x, y;
|
||||
int x;
|
||||
int y;
|
||||
getPos(x, y);
|
||||
x_target_ = x;
|
||||
}
|
||||
@ -934,7 +937,7 @@ bool LCursor::goUpDown(bool up)
|
||||
//}
|
||||
|
||||
// try to find an inset that knows better then we
|
||||
while (1) {
|
||||
while (true) {
|
||||
//lyxerr << "updown: We are in " << &inset() << " idx: " << idx() << endl;
|
||||
// ask inset first
|
||||
if (inset().idxUpDown(*this, up)) {
|
||||
@ -953,7 +956,8 @@ bool LCursor::goUpDown(bool up)
|
||||
}
|
||||
|
||||
// any improvement so far?
|
||||
int xnew, ynew;
|
||||
int xnew;
|
||||
int ynew;
|
||||
getPos(xnew, ynew);
|
||||
if (up ? ynew < yo : ynew > yo)
|
||||
return true;
|
||||
@ -1061,7 +1065,7 @@ string LCursor::currentState()
|
||||
}
|
||||
|
||||
if (inTexted())
|
||||
return text()->currentState(*this);
|
||||
return text()->currentState(*this);
|
||||
|
||||
return string();
|
||||
}
|
||||
@ -1082,7 +1086,7 @@ Encoding const * LCursor::getEncoding() const
|
||||
int s = 0;
|
||||
// go up until first non-0 text is hit
|
||||
// (innermost text is 0 in mathed)
|
||||
for (s = size() - 1; s >= 0; --s)
|
||||
for (s = depth() - 1; s >= 0; --s)
|
||||
if (operator[](s).text())
|
||||
break;
|
||||
CursorSlice const & sl = operator[](s);
|
||||
@ -1123,7 +1127,7 @@ LyXFont LCursor::getFont() const
|
||||
int s = 0;
|
||||
// go up until first non-0 text is hit
|
||||
// (innermost text is 0 in mathed)
|
||||
for (s = size() - 1; s >= 0; --s)
|
||||
for (s = depth() - 1; s >= 0; --s)
|
||||
if (operator[](s).text())
|
||||
break;
|
||||
CursorSlice const & sl = operator[](s);
|
||||
@ -1132,7 +1136,6 @@ LyXFont LCursor::getFont() const
|
||||
bv().buffer()->params(),
|
||||
sl.pos(),
|
||||
outerFont(sl.pit(), text.paragraphs()));
|
||||
for (; s < size(); ++s)
|
||||
;
|
||||
|
||||
return font;
|
||||
}
|
||||
|
@ -244,11 +244,11 @@ bool DocIterator::inTexted() const
|
||||
LyXText * DocIterator::innerText()
|
||||
{
|
||||
BOOST_ASSERT(!empty());
|
||||
// go up until first non-0 text is hit
|
||||
// Go up until first non-0 text is hit
|
||||
// (innermost text is 0 in mathed)
|
||||
for (int i = size() - 1; i >= 0; --i)
|
||||
if (operator[](i).text())
|
||||
return operator[](i).text();
|
||||
for (int i = depth() - 1; i >= 0; --i)
|
||||
if (slices_[i].text())
|
||||
return slices_[i].text();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -257,18 +257,18 @@ LyXText const * DocIterator::innerText() const
|
||||
BOOST_ASSERT(!empty());
|
||||
// go up until first non-0 text is hit
|
||||
// (innermost text is 0 in mathed)
|
||||
for (int i = size() - 1; i >= 0; --i)
|
||||
if (operator[](i).text())
|
||||
return operator[](i).text();
|
||||
for (int i = depth() - 1; i >= 0; --i)
|
||||
if (slices_[i].text())
|
||||
return slices_[i].text();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
InsetBase * DocIterator::innerInsetOfType(int code) const
|
||||
{
|
||||
for (int i = size() - 1; i >= 0; --i)
|
||||
if (operator[](i).inset_->lyxCode() == code)
|
||||
return operator[](i).inset_;
|
||||
for (int i = depth() - 1; i >= 0; --i)
|
||||
if (slices_[i].inset_->lyxCode() == code)
|
||||
return slices_[i].inset_;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ void DocIterator::forwardPos()
|
||||
return;
|
||||
}
|
||||
|
||||
CursorSlice & top = back();
|
||||
CursorSlice & tip = top();
|
||||
//lyxerr << "XXX\n" << *this << endl;
|
||||
|
||||
// this is used twice and shows up in the profiler!
|
||||
@ -290,13 +290,13 @@ void DocIterator::forwardPos()
|
||||
// move into an inset to the right if possible
|
||||
InsetBase * n = 0;
|
||||
|
||||
if (top.pos() != lastp) {
|
||||
if (tip.pos() != lastp) {
|
||||
// this is impossible for pos() == size()
|
||||
if (inMathed()) {
|
||||
n = (top.cell().begin() + top.pos())->nucleus();
|
||||
n = (tip.cell().begin() + tip.pos())->nucleus();
|
||||
} else {
|
||||
if (paragraph().isInset(top.pos()))
|
||||
n = paragraph().getInset(top.pos());
|
||||
if (paragraph().isInset(tip.pos()))
|
||||
n = paragraph().getInset(tip.pos());
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,28 +307,28 @@ void DocIterator::forwardPos()
|
||||
}
|
||||
|
||||
// otherwise move on one position if possible
|
||||
if (top.pos() < lastp) {
|
||||
if (tip.pos() < lastp) {
|
||||
//lyxerr << "... next pos" << endl;
|
||||
++top.pos();
|
||||
++tip.pos();
|
||||
return;
|
||||
}
|
||||
//lyxerr << "... no next pos" << endl;
|
||||
|
||||
// otherwise move on one paragraph if possible
|
||||
if (top.pit() < lastpit()) {
|
||||
if (tip.pit() < lastpit()) {
|
||||
//lyxerr << "... next par" << endl;
|
||||
++top.pit();
|
||||
top.pos() = 0;
|
||||
++tip.pit();
|
||||
tip.pos() = 0;
|
||||
return;
|
||||
}
|
||||
//lyxerr << "... no next pit" << endl;
|
||||
|
||||
// otherwise try to move on one cell if possible
|
||||
if (top.idx() < lastidx()) {
|
||||
if (tip.idx() < lastidx()) {
|
||||
//lyxerr << "... next idx" << endl;
|
||||
++top.idx();
|
||||
top.pit() = 0;
|
||||
top.pos() = 0;
|
||||
++tip.idx();
|
||||
tip.pit() = 0;
|
||||
tip.pos() = 0;
|
||||
return;
|
||||
}
|
||||
//lyxerr << "... no next idx" << endl;
|
||||
@ -336,8 +336,8 @@ void DocIterator::forwardPos()
|
||||
// otherwise leave inset and jump over inset as a whole
|
||||
pop_back();
|
||||
// 'top' is invalid now...
|
||||
if (size())
|
||||
++back().pos();
|
||||
if (!empty())
|
||||
++top().pos();
|
||||
}
|
||||
|
||||
|
||||
@ -352,7 +352,7 @@ void DocIterator::forwardPar()
|
||||
void DocIterator::forwardChar()
|
||||
{
|
||||
forwardPos();
|
||||
while (size() != 0 && pos() == lastpos())
|
||||
while (!empty() && pos() == lastpos())
|
||||
forwardPos();
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ void DocIterator::forwardChar()
|
||||
void DocIterator::forwardInset()
|
||||
{
|
||||
forwardPos();
|
||||
while (size() != 0 && (pos() == lastpos() || nextInset() == 0))
|
||||
while (!empty() && (pos() == lastpos() || nextInset() == 0))
|
||||
forwardPos();
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ void DocIterator::forwardInset()
|
||||
void DocIterator::backwardChar()
|
||||
{
|
||||
backwardPos();
|
||||
while (size() != 0 && pos() == lastpos())
|
||||
while (!empty() && pos() == lastpos())
|
||||
backwardPos();
|
||||
}
|
||||
|
||||
@ -378,24 +378,24 @@ void DocIterator::backwardPos()
|
||||
//this dog bites his tail
|
||||
if (empty()) {
|
||||
push_back(CursorSlice(*inset_));
|
||||
back().idx() = lastidx();
|
||||
back().pit() = lastpit();
|
||||
back().pos() = lastpos();
|
||||
top().idx() = lastidx();
|
||||
top().pit() = lastpit();
|
||||
top().pos() = lastpos();
|
||||
return;
|
||||
}
|
||||
|
||||
CursorSlice & top = back();
|
||||
CursorSlice & tip = top();
|
||||
|
||||
if (top.pos() != 0) {
|
||||
--top.pos();
|
||||
} else if (top.pit() != 0) {
|
||||
--top.pit();
|
||||
top.pos() = lastpos();
|
||||
if (tip.pos() != 0) {
|
||||
--tip.pos();
|
||||
} else if (tip.pit() != 0) {
|
||||
--tip.pit();
|
||||
tip.pos() = lastpos();
|
||||
return;
|
||||
} else if (top.idx() != 0) {
|
||||
--top.idx();
|
||||
top.pit() = lastpit();
|
||||
top.pos() = lastpos();
|
||||
} else if (tip.idx() != 0) {
|
||||
--tip.idx();
|
||||
tip.pit() = lastpit();
|
||||
tip.pos() = lastpos();
|
||||
return;
|
||||
} else {
|
||||
pop_back();
|
||||
@ -406,17 +406,17 @@ void DocIterator::backwardPos()
|
||||
InsetBase * n = 0;
|
||||
|
||||
if (inMathed()) {
|
||||
n = (top.cell().begin() + top.pos())->nucleus();
|
||||
n = (tip.cell().begin() + tip.pos())->nucleus();
|
||||
} else {
|
||||
if (paragraph().isInset(top.pos()))
|
||||
n = paragraph().getInset(top.pos());
|
||||
if (paragraph().isInset(tip.pos()))
|
||||
n = paragraph().getInset(tip.pos());
|
||||
}
|
||||
|
||||
if (n && n->isActive()) {
|
||||
push_back(CursorSlice(*n));
|
||||
back().idx() = lastidx();
|
||||
back().pit() = lastpit();
|
||||
back().pos() = lastpos();
|
||||
top().idx() = lastidx();
|
||||
top().pit() = lastpit();
|
||||
top().pos() = lastpos();
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,18 +424,18 @@ void DocIterator::backwardPos()
|
||||
bool DocIterator::hasPart(DocIterator const & it) const
|
||||
{
|
||||
// it can't be a part if it is larger
|
||||
if (it.size() > size())
|
||||
if (it.depth() > depth())
|
||||
return false;
|
||||
|
||||
// as inset adresses are the 'last' level
|
||||
return &it.back().inset() == &operator[](it.size() - 1).inset();
|
||||
return &it.top().inset() == &slices_[it.depth() - 1].inset();
|
||||
}
|
||||
|
||||
|
||||
std::ostream & operator<<(std::ostream & os, DocIterator const & dit)
|
||||
{
|
||||
for (size_t i = 0, n = dit.size(); i != n; ++i)
|
||||
os << " " << dit.operator[](i) << "\n";
|
||||
for (size_t i = 0, n = dit.depth(); i != n; ++i)
|
||||
os << " " << dit[i] << "\n";
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -443,9 +443,9 @@ std::ostream & operator<<(std::ostream & os, DocIterator const & dit)
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
|
||||
StableDocIterator::StableDocIterator(const DocIterator & dit)
|
||||
StableDocIterator::StableDocIterator(DocIterator const & dit)
|
||||
{
|
||||
data_ = dit;
|
||||
data_ = dit.internalData();
|
||||
for (size_t i = 0, n = data_.size(); i != n; ++i)
|
||||
data_[i].inset_ = 0;
|
||||
}
|
||||
@ -459,14 +459,15 @@ DocIterator StableDocIterator::asDocIterator(InsetBase * inset) const
|
||||
for (size_t i = 0, n = data_.size(); i != n; ++i) {
|
||||
if (inset == 0) {
|
||||
// FIXME
|
||||
lyxerr << "Should not happen, but does e.g. after C-n C-l C-z S-C-z"
|
||||
<< endl << "dit: " << dit << endl
|
||||
lyxerr << BOOST_CURRENT_FUNCTION
|
||||
<< " Should not happen, but does e.g. after C-n C-l C-z S-C-z"
|
||||
<< '\n' << "dit: " << dit << '\n'
|
||||
<< " lastpos: " << dit.lastpos() << endl;
|
||||
//break;
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
dit.push_back(data_[i]);
|
||||
dit.back().inset_ = inset;
|
||||
dit.top().inset_ = inset;
|
||||
if (i + 1 != n)
|
||||
inset = dit.nextInset();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ bool ptr_cmp(A const * a, B const * b)
|
||||
|
||||
// The public inheritance should go in favour of a suitable data member
|
||||
// (or maybe private inheritance) at some point of time.
|
||||
class DocIterator : public std::vector<CursorSlice>
|
||||
class DocIterator // : public std::vector<CursorSlice>
|
||||
{
|
||||
public:
|
||||
/// type for cell number in inset
|
||||
@ -54,42 +54,55 @@ public:
|
||||
///
|
||||
explicit DocIterator(InsetBase & inset);
|
||||
|
||||
CursorSlice const & operator[](size_t i) const {
|
||||
return slices_[i];
|
||||
}
|
||||
|
||||
CursorSlice & operator[](size_t i) {
|
||||
return slices_[i];
|
||||
}
|
||||
|
||||
// What is the point of this function?
|
||||
void resize(size_t i) { slices_.resize(i); }
|
||||
|
||||
/// is the iterator valid?
|
||||
operator const void*() const { return empty() ? 0 : this; }
|
||||
/// is this iterator invalid?
|
||||
bool operator!() const { return empty(); }
|
||||
|
||||
bool empty() const { return slices_.empty(); }
|
||||
|
||||
//
|
||||
// access to slice at tip
|
||||
//
|
||||
/// access to tip
|
||||
CursorSlice & top() { return back(); }
|
||||
CursorSlice & top() { return slices_.back(); }
|
||||
/// access to tip
|
||||
CursorSlice const & top() const { return back(); }
|
||||
CursorSlice const & top() const { return slices_.back(); }
|
||||
/// access to outermost slice
|
||||
CursorSlice & bottom() { return front(); }
|
||||
CursorSlice & bottom() { return slices_.front(); }
|
||||
/// access to outermost slicetip
|
||||
CursorSlice const & bottom() const { return front(); }
|
||||
CursorSlice const & bottom() const { return slices_.front(); }
|
||||
/// how many nested insets do we have?
|
||||
size_t depth() const { return size(); }
|
||||
size_t depth() const { return slices_.size(); }
|
||||
/// the containing inset
|
||||
InsetBase & inset() const { return back().inset(); }
|
||||
InsetBase & inset() const { return top().inset(); }
|
||||
/// return the cell of the inset this cursor is in
|
||||
idx_type idx() const { return back().idx(); }
|
||||
idx_type idx() const { return top().idx(); }
|
||||
/// return the cell of the inset this cursor is in
|
||||
idx_type & idx() { return back().idx(); }
|
||||
idx_type & idx() { return top().idx(); }
|
||||
/// return the last possible cell in this inset
|
||||
idx_type lastidx() const;
|
||||
/// return the paragraph this cursor is in
|
||||
pit_type pit() const { return back().pit(); }
|
||||
pit_type pit() const { return top().pit(); }
|
||||
/// return the paragraph this cursor is in
|
||||
pit_type & pit() { return back().pit(); }
|
||||
pit_type & pit() { return top().pit(); }
|
||||
/// return the last possible paragraph in this inset
|
||||
pit_type lastpit() const;
|
||||
/// return the position within the paragraph
|
||||
pos_type pos() const { return back().pos(); }
|
||||
pos_type pos() const { return top().pos(); }
|
||||
/// return the position within the paragraph
|
||||
pos_type & pos() { return back().pos(); }
|
||||
pos_type & pos() { return top().pos(); }
|
||||
/// return the last position within the paragraph
|
||||
pos_type lastpos() const;
|
||||
|
||||
@ -191,7 +204,21 @@ public:
|
||||
/// output
|
||||
friend std::ostream &
|
||||
operator<<(std::ostream & os, DocIterator const & cur);
|
||||
friend bool operator==(DocIterator const &, DocIterator const &);
|
||||
friend class StableDocIterator;
|
||||
protected:
|
||||
void clear() { slices_.clear(); }
|
||||
void push_back(CursorSlice const & sl) {
|
||||
slices_.push_back(sl);
|
||||
}
|
||||
void pop_back() {
|
||||
slices_.pop_back();
|
||||
}
|
||||
private:
|
||||
std::vector<CursorSlice> const & internalData() const {
|
||||
return slices_;
|
||||
}
|
||||
std::vector<CursorSlice> slices_;
|
||||
InsetBase * inset_;
|
||||
};
|
||||
|
||||
@ -200,6 +227,20 @@ DocIterator doc_iterator_begin(InsetBase & inset);
|
||||
DocIterator doc_iterator_end(InsetBase & inset);
|
||||
|
||||
|
||||
inline
|
||||
bool operator==(DocIterator const & di1, DocIterator const & di2)
|
||||
{
|
||||
return di1.slices_ == di2.slices_;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
bool operator!=(DocIterator const & di1, DocIterator const & di2)
|
||||
{
|
||||
return !(di1 == di2);
|
||||
}
|
||||
|
||||
|
||||
// The difference to a ('non stable') DocIterator is the removed
|
||||
// (overwritte by 0...) part of the CursorSlice data items. So this thing
|
||||
// is suitable for external storage, but not for iteration as such.
|
||||
|
@ -1,3 +1,7 @@
|
||||
2005-02-08 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* LyXView.C (updateLayoutChoice): minor change to some comments
|
||||
|
||||
2005-01-20 Asger Ottar Alstrup <aalstrup@laerdal.dk>
|
||||
|
||||
* pch.h: use the HAVE_UNISTD_H preprocessor guard.
|
||||
|
@ -140,13 +140,13 @@ void LyXView::resetAutosaveTimer()
|
||||
|
||||
void LyXView::updateLayoutChoice()
|
||||
{
|
||||
// don't show any layouts without a buffer
|
||||
// Don't show any layouts without a buffer
|
||||
if (!view()->buffer()) {
|
||||
toolbars_->clearLayoutList();
|
||||
return;
|
||||
}
|
||||
|
||||
// update the layout display
|
||||
// Update the layout display
|
||||
if (toolbars_->updateLayoutList(buffer()->params().textclass)) {
|
||||
current_layout = buffer()->params().getLyXTextClass().defaultLayoutName();
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
2005-02-08 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* ControlSpellchecker.C (nextWord): size() -> depth()
|
||||
* ControlTabular.C(initializeParams): ditto
|
||||
|
||||
2005-01-31 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* ControlGraphics.C (browse): rewrite to use boost.filesystem
|
||||
|
@ -138,7 +138,7 @@ WordLangTuple nextWord(DocIterator & cur, ptrdiff_t & progress,
|
||||
bool ignoreword = false;
|
||||
string word, lang_code;
|
||||
|
||||
while(cur.size()) {
|
||||
while (cur.depth()) {
|
||||
if (isLetter(cur)) {
|
||||
if (!inword) {
|
||||
inword = true;
|
||||
|
@ -37,7 +37,7 @@ bool ControlTabular::initialiseParams(string const & data)
|
||||
LCursor const & cur = bv->cursor();
|
||||
// get the innermost tabular inset;
|
||||
// assume that it is "ours"
|
||||
for (int i = cur.size() - 1; i >= 0; --i)
|
||||
for (int i = cur.depth() - 1; i >= 0; --i)
|
||||
if (cur[i].inset().lyxCode() == InsetBase::TABULAR_CODE) {
|
||||
active_cell_ = cur[i].idx();
|
||||
break;
|
||||
|
@ -1,3 +1,8 @@
|
||||
2005-02-08 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* insetcollapsable.C (leaveInset): size() -> depth()
|
||||
* insettabular.C (isRightToLeft): ditto
|
||||
|
||||
2005-02-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* insetert.C (latex, linuxdoc, docbook): remove newline handling
|
||||
|
@ -41,7 +41,7 @@ using std::ostream;
|
||||
|
||||
void leaveInset(LCursor & cur, InsetBase const & in)
|
||||
{
|
||||
for (unsigned int i = 0; i != cur.size(); ++i) {
|
||||
for (size_t i = 0; i != cur.depth(); ++i) {
|
||||
if (&cur[i].inset() == &in) {
|
||||
cur.resize(i);
|
||||
return;
|
||||
|
@ -1664,9 +1664,9 @@ void InsetTabular::cutSelection(LCursor & cur)
|
||||
|
||||
bool InsetTabular::isRightToLeft(LCursor & cur) const
|
||||
{
|
||||
BOOST_ASSERT(cur.size() > 1);
|
||||
Paragraph const & parentpar = cur[cur.size() - 2].paragraph();
|
||||
LCursor::pos_type const parentpos = cur[cur.size() - 2].pos();
|
||||
BOOST_ASSERT(cur.depth() > 1);
|
||||
Paragraph const & parentpar = cur[cur.depth() - 2].paragraph();
|
||||
LCursor::pos_type const parentpos = cur[cur.depth() - 2].pos();
|
||||
return parentpar.getFontSettings(cur.bv().buffer()->params(),
|
||||
parentpos).language()->RightToLeft();
|
||||
}
|
||||
|
@ -292,7 +292,8 @@ InsetBase * InsetText::editXY(LCursor & cur, int x, int y) const
|
||||
|
||||
void InsetText::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
{
|
||||
//lyxerr << "InsetText::doDispatch: " << cmd.action << " " << endl;
|
||||
lyxerr << BOOST_CURRENT_FUNCTION
|
||||
<< " [ cmd.action = " << cmd.action << ']' << endl;
|
||||
setViewCache(&cur.bv());
|
||||
|
||||
text_.dispatch(cur, cmd);
|
||||
|
@ -150,7 +150,7 @@ bool getStatus(LCursor cursor,
|
||||
// BufferView * arg, though (which should be avoided)
|
||||
//LCursor safe = *this;
|
||||
bool res = false;
|
||||
for ( ; cursor.size(); cursor.pop()) {
|
||||
for ( ; cursor.depth(); cursor.pop()) {
|
||||
//lyxerr << "\nLCursor::getStatus: cmd: " << cmd << endl << *this << endl;
|
||||
DocIterator::idx_type & idx = cursor.idx();
|
||||
DocIterator::idx_type const lastidx = cursor.lastidx();
|
||||
@ -444,7 +444,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
|
||||
case LFUN_INSET_SETTINGS: {
|
||||
enable = false;
|
||||
if (!cur.size())
|
||||
if (!cur)
|
||||
break;
|
||||
UpdatableInset * inset = cur.inset().asUpdatableInset();
|
||||
lyxerr << "inset: " << inset << endl;
|
||||
|
@ -1,3 +1,7 @@
|
||||
2005-02-08 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* math_data.C (isInside): size() -> depth()
|
||||
|
||||
2005-01-31 Asger Ottar Alstrup <aalstrup@laerdal.dk>
|
||||
|
||||
* math_data.C:
|
||||
|
@ -221,7 +221,7 @@ namespace {
|
||||
bool isInside(DocIterator const & it, MathArray const & ar,
|
||||
lyx::pos_type p1, lyx::pos_type p2)
|
||||
{
|
||||
for (size_t i = 0; i != it.size(); ++i) {
|
||||
for (size_t i = 0; i != it.depth(); ++i) {
|
||||
CursorSlice const & sl = it[i];
|
||||
if (sl.inset().inMathed() && &sl.cell() == &ar)
|
||||
return p1 <= sl.pos() && sl.pos() < p2;
|
||||
|
@ -901,9 +901,9 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
|
||||
}
|
||||
|
||||
LyXFont basefont;
|
||||
|
||||
|
||||
LaTeXFeatures features(buf, bparams, runparams.nice);
|
||||
|
||||
|
||||
// output change tracking marks only if desired,
|
||||
// if dvipost is installed,
|
||||
// and with dvi/ps (other formats don't work)
|
||||
@ -1020,7 +1020,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
|
||||
|
||||
Change::Type change = pimpl_->lookupChange(i);
|
||||
|
||||
column += Changes::latexMarkChange(os, running_change,
|
||||
column += Changes::latexMarkChange(os, running_change,
|
||||
change, output);
|
||||
running_change = change;
|
||||
|
||||
@ -1878,4 +1878,3 @@ void Paragraph::dump() const
|
||||
rows_[i].dump();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1246,9 +1246,6 @@ bool LyXText::cursorRight(LCursor & cur)
|
||||
if (cur.pos() != cur.lastpos()) {
|
||||
bool updateNeeded = false;
|
||||
if (!checkAndActivateInset(cur, true)) {
|
||||
lyxerr << BOOST_CURRENT_FUNCTION
|
||||
<< " Running setCursor" << endl;
|
||||
|
||||
updateNeeded |= setCursor(cur, cur.pit(), cur.pos() + 1, true, false);
|
||||
if (false && bidi.isBoundary(cur.buffer(), cur.paragraph(),
|
||||
cur.pos()))
|
||||
|
@ -426,7 +426,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_BEGINNINGBUF:
|
||||
if (cur.size() == 1) {
|
||||
if (cur.depth() == 1) {
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
cursorTop(cur);
|
||||
@ -437,7 +437,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_BEGINNINGBUFSEL:
|
||||
if (cur.size() == 1) {
|
||||
if (cur.depth() == 1) {
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
cursorTop(cur);
|
||||
@ -448,7 +448,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_ENDBUF:
|
||||
if (cur.size() == 1) {
|
||||
if (cur.depth() == 1) {
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
cursorBottom(cur);
|
||||
@ -459,7 +459,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_ENDBUFSEL:
|
||||
if (cur.size() == 1) {
|
||||
if (cur.depth() == 1) {
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
cursorBottom(cur);
|
||||
|
Loading…
Reference in New Issue
Block a user