}
-bool Changes::Range::loose_contains(pos_type const pos) const
+bool Changes::Range::containsOrPrecedes(pos_type const pos) const
{
return pos >= start && pos <= end;
}
erase(pos);
}
break;
- } else if (range.loose_contains(pos) && it + 1 == table_.end()) {
+ } else if (range.containsOrPrecedes(pos) && it + 1 == table_.end()) {
// this case happens when building from .lyx
set(change, pos);
break;
for (; it != end; ++it) {
Range & range(it->range);
- if (!found && range.loose_contains(pos)) {
+ if (!found && range.containsOrPrecedes(pos)) {
found = true;
if (lyxerr.debugging(Debug::CHANGES)) {
lyxerr[Debug::CHANGES] << "Found range of "
}
-Change const Changes::lookupFull(pos_type const pos) const
+Change const Changes::lookup(pos_type const pos) const
{
if (!table_.size()) {
if (lyxerr.debugging(Debug::CHANGES))
}
-Change::Type Changes::lookup(pos_type const pos) const
-{
- if (!table_.size()) {
- if (lyxerr.debugging(Debug::CHANGES))
- lyxerr[Debug::CHANGES] << "Empty, type is " << empty_type_ << endl;
- return empty_type_;
- }
-
- ChangeTable::const_iterator it = table_.begin();
- ChangeTable::const_iterator end = table_.end();
-
- for (; it != end; ++it) {
- if (it->range.contains(pos))
- return it->change.type;
- }
-
- check();
- BOOST_ASSERT(false && "missing changes for pos");
- return Change::UNCHANGED;
-}
-
-
bool Changes::isChange(pos_type const start, pos_type const end) const
{
if (!table_.size()) {
/// mark the given change and adjust
void record(Change, lyx::pos_type pos);
- /// return the change type at the given position
- Change::Type lookup(lyx::pos_type pos) const;
-
/// return the change at the given position
- Change const lookupFull(lyx::pos_type pos) const;
+ Change const lookup(lyx::pos_type pos) const;
/// return true if there is a change in the given range
bool isChange(lyx::pos_type start, lyx::pos_type end) const;
bool contains(lyx::pos_type pos) const;
// does this range contain pos, or can it be appended ?
- bool loose_contains(lyx::pos_type pos) const;
+ bool containsOrPrecedes(lyx::pos_type pos) const;
// is this range contained within r ?
bool contained(Range const & r) const;
bool findChange(DocIterator & cur)
{
for (; cur; cur.forwardPos())
- if (cur.inTexted() && cur.paragraph().lookupChangeType(cur.pos())
+ if (cur.inTexted() && cur.paragraph().lookupChange(cur.pos()).type
!= Change::UNCHANGED)
return true;
return false;
CursorSlice const & slice = dit[i];
if (!slice.inset().inMathed()
&& slice.pos() < slice.paragraph().size()) {
- Change::Type const ch = slice.paragraph().lookupChangeType(slice.pos());
+ Change::Type const ch = slice.paragraph().lookupChange(slice.pos()).type;
if (ch != Change::UNCHANGED)
return ch;
}
int column = 0;
for (pos_type i = 0; i <= size(); ++i) {
- Change change = pimpl_->lookupChangeFull(i);
+ Change change = pimpl_->lookupChange(i);
Changes::lyxMarkChange(os, column, curtime, running_change, change);
running_change = change;
int i = 0;
while (!empty() && (isNewline(0) || isLineSeparator(0))
- && (lookupChange(0) != Change::DELETED)) {
+ && (lookupChange(0).type != Change::DELETED)) {
erase(0);
++i;
}
open_font = true;
}
- Change::Type change = pimpl_->lookupChange(i);
+ Change::Type change = pimpl_->lookupChange(i).type;
column += Changes::latexMarkChange(os, running_change,
change, output);
}
-Change::Type Paragraph::lookupChangeType(lyx::pos_type pos) const
-{
- BOOST_ASSERT(pos <= size());
- return pimpl_->lookupChange(pos);
-}
-
-
Change const Paragraph::lookupChange(lyx::pos_type pos) const
{
BOOST_ASSERT(pos <= size());
- return pimpl_->lookupChangeFull(pos);
+ return pimpl_->lookupChange(pos);
}
}
-void Paragraph::setChange(lyx::pos_type pos, Change::Type type)
+void Paragraph::setChangeType(lyx::pos_type pos, Change::Type type)
{
- pimpl_->setChange(pos, type);
+ pimpl_->setChangeType(pos, type);
}
-void Paragraph::setChangeFull(lyx::pos_type pos, Change change)
+void Paragraph::setChange(lyx::pos_type pos, Change change)
{
- pimpl_->setChangeFull(pos, change);
+ pimpl_->setChange(pos, change);
}
/// set entire paragraph to new text for change tracking
void cleanChanges(ChangeTracking ct = trackingUnknown);
- /// look up change type at given pos
- Change::Type lookupChangeType(lyx::pos_type pos) const;
-
/// look up change at given pos
Change const lookupChange(lyx::pos_type pos) const;
/// is there a non-addition in this range ?
bool isChangeEdited(lyx::pos_type start, lyx::pos_type end) const;
- /// set change at pos
- void setChange(lyx::pos_type pos, Change::Type type);
+ /// set change type at given pos
+ void setChangeType(lyx::pos_type pos, Change::Type type);
- /// set full change at pos
- void setChangeFull(lyx::pos_type pos, Change change);
+ /// set change at given pos
+ void setChange(lyx::pos_type pos, Change change);
/// accept change
void acceptChange(lyx::pos_type start, lyx::pos_type end);
inline bool isInsertedText(Paragraph const & par, lyx::pos_type pos)
{
- return par.lookupChangeType(pos) == Change::INSERTED;
+ return par.lookupChange(pos).type == Change::INSERTED;
}
inline bool isDeletedText(Paragraph const & par, lyx::pos_type pos)
{
- return par.lookupChangeType(pos) == Change::DELETED;
+ return par.lookupChange(pos).type == Change::DELETED;
}
#endif // PARAGRAPH_H
pos_type pos_end = par.size() - 1;
for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
- Change::Type change = par.lookupChangeType(i);
+ Change::Type change = par.lookupChange(i).type;
if (moveItem(par, *tmp, bparams, i, j - pos)) {
tmp->setChange(j - pos, change);
++j;
pos_type pos_end = par.size() - 1;
for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
- Change::Type change = par.lookupChangeType(i);
+ Change::Type change = par.lookupChange(i).type;
if (moveItem(par, tmp, bparams, i, j - pos, change))
++j;
}
// Move over end-of-par change attr
- tmp.setChange(tmp.size(), par.lookupChangeType(par.size()));
+ tmp.setChange(tmp.size(), par.lookupChange(par.size()).type);
// If tracking changes, set all the text that is to be
// erased to Type::INSERTED.
// forcibly to "black" prevents this scenario. -- MV 13.3.2006
par.setChange(par.size(), Change::UNCHANGED);
- Change::Type cr = next.lookupChangeType(next.size());
+ Change::Type cr = next.lookupChange(next.size()).type;
// ok, now copy the paragraph
for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
- Change::Type change = next.lookupChangeType(i);
+ Change::Type change = next.lookupChange(i).type;
if (moveItem(next, par, bparams, i, pos_insert + j, change))
++j;
}
}
-void Paragraph::Pimpl::setChange(pos_type pos, Change::Type type)
+void Paragraph::Pimpl::setChangeType(pos_type pos, Change::Type type)
{
if (!tracking())
return;
}
-void Paragraph::Pimpl::setChangeFull(pos_type pos, Change change)
+void Paragraph::Pimpl::setChange(pos_type pos, Change change)
{
if (!tracking())
return;
changes_->set(change, pos);
}
-Change::Type Paragraph::Pimpl::lookupChange(pos_type pos) const
-{
- if (!tracking())
- return Change::UNCHANGED;
- return changes_->lookup(pos);
-}
-
-
-Change const Paragraph::Pimpl::lookupChangeFull(pos_type pos) const
+Change const Paragraph::Pimpl::lookupChange(pos_type pos) const
{
if (!tracking())
return Change(Change::UNCHANGED);
- return changes_->lookupFull(pos);
+ return changes_->lookup(pos);
}
pos_type i = start;
for (; i < end; ++i) {
- switch (lookupChange(i)) {
+ switch (lookupChange(i).type) {
case Change::UNCHANGED:
break;
pos_type i = start;
for (; i < end; ++i) {
- switch (lookupChange(i)) {
+ switch (lookupChange(i).type) {
case Change::UNCHANGED:
break;
BOOST_ASSERT(pos <= size());
if (tracking()) {
- Change::Type changetype(changes_->lookup(pos));
+ Change::Type changetype(changes_->lookup(pos).type);
changes_->record(Change(Change::DELETED), pos);
// only allow the actual removal if it was /new/ text
void untrackChanges();
/// set all text as new for change mode
void cleanChanges(Paragraph::ChangeTracking ct = Paragraph::trackingUnknown);
- /// look up change type at given pos
- Change::Type lookupChange(lyx::pos_type pos) const;
/// look up change at given pos
- Change const lookupChangeFull(lyx::pos_type pos) const;
- /// is there a change in the given range ?
+ Change const lookupChange(lyx::pos_type pos) const;
+ /// is there a change within the given range ?
bool isChanged(lyx::pos_type start, lyx::pos_type end) const;
/// is there a non-addition in this range ?
bool isChangeEdited(lyx::pos_type start, lyx::pos_type end) const;
- /// set change at pos
- void setChange(lyx::pos_type pos, Change::Type type);
- /// set full change at pos
- void setChangeFull(lyx::pos_type pos, Change change);
+ /// set change type at given pos
+ void setChangeType(lyx::pos_type pos, Change::Type type);
+ /// set change at given pos
+ void setChange(lyx::pos_type pos, Change change);
/// mark as erased
void markErased(bool);
/// accept change
pos_type pos = text_.bidi.vis2log(vpos);
pos_type const end = row_.endpos();
FontSpan const font_span = par_.fontSpan(pos);
- Change::Type const prev_change = par_.lookupChangeType(pos);
+ Change::Type const prev_change = par_.lookupChange(pos).type;
// first character
string str;
}
}
// Final change goes to paragraph break:
- par.setChangeFull(par.size(), change);
+ par.setChange(par.size(), change);
// Initialize begin_of_body_ on load; redoParagraph maintains
par.setBeginOfBody();
DocIterator it = cur.selectionBegin();
DocIterator et = cur.selectionEnd();
pit_type pit = it.pit();
- Change::Type const type = pars_[pit].lookupChangeType(it.pos());
+ Change::Type const type = pars_[pit].lookupChange(it.pos()).type;
for (; pit <= et.pit(); ++pit) {
pos_type left = ( pit == it.pit() ? it.pos() : 0 );
pos_type right =
DocIterator it = cur.selectionBegin();
DocIterator et = cur.selectionEnd();
pit_type pit = it.pit();
- Change::Type const type = pars_[pit].lookupChangeType(it.pos());
+ Change::Type const type = pars_[pit].lookupChange(it.pos()).type;
for (; pit <= et.pit(); ++pit) {
pos_type left = ( pit == it.pit() ? it.pos() : 0 );
pos_type right =