Hi, just too many things happended implicitly in the CT code.
Attached please find a rather boring cleanup for my personal CT branch. Michael
Index: paragraph.h =================================================================== --- paragraph.h (Revision 13819) +++ paragraph.h (Arbeitskopie) @@ -323,17 +323,15 @@ void insert(lyx::pos_type pos, std::string const & str, LyXFont const & font); /// - void insertChar(lyx::pos_type pos, value_type c, - Change change = Change::INSERTED); + void insertChar(lyx::pos_type pos, value_type c, Change change); /// void insertChar(lyx::pos_type pos, value_type c, - LyXFont const &, Change change = Change::INSERTED); + LyXFont const &, Change change); /// - void insertInset(lyx::pos_type pos, InsetBase * inset, - Change change = Change::INSERTED); + void insertInset(lyx::pos_type pos, InsetBase * inset, Change change); /// void insertInset(lyx::pos_type pos, InsetBase * inset, - LyXFont const &, Change change = Change::INSERTED); + LyXFont const &, Change change); /// bool insetAllowed(InsetBase_code code); /// Index: insets/insettext.C =================================================================== --- insets/insettext.C (Revision 13819) +++ insets/insettext.C (Arbeitskopie) @@ -361,7 +361,7 @@ clear(); Paragraph & first = paragraphs().front(); for (unsigned int i = 0; i < data.length(); ++i) - first.insertChar(i, data[i], font); + first.insertChar(i, data[i], font, Change(Change::INSERTED)); } Index: text2.C =================================================================== --- text2.C (Revision 13818) +++ text2.C (Arbeitskopie) @@ -617,7 +617,7 @@ { BOOST_ASSERT(this == cur.text()); BOOST_ASSERT(inset); - cur.paragraph().insertInset(cur.pos(), inset); + cur.paragraph().insertInset(cur.pos(), inset, Change(Change::INSERTED)); } @@ -1220,10 +1220,10 @@ && old.pos() < oldpar.size() && oldpar.isLineSeparator(old.pos()) && oldpar.isLineSeparator(old.pos() - 1) - && oldpar.lookupChange(old.pos() - 1) != Change::DELETED) { + && oldpar.lookupChange(old.pos() - 1).type != Change::DELETED) { // We need to set the text to Change::INSERTED to // get it erased properly - oldpar.setChange(old.pos() -1, Change::INSERTED); + oldpar.setChangeType(old.pos() -1, Change::INSERTED); oldpar.erase(old.pos() - 1); #ifdef WITH_WARNINGS #warning This will not work anymore when we have multiple views of the same buffer Index: buffer.C =================================================================== --- buffer.C (Revision 13821) +++ buffer.C (Arbeitskopie) @@ -521,13 +521,13 @@ } else if (*cit == '\t') { if (!par.isFreeSpacing()) { // tabs are like spaces here - par.insertChar(pos, ' ', font); + par.insertChar(pos, ' ', font, Change(Change::INSERTED)); ++pos; space_inserted = true; } else { const pos_type n = 8 - pos % 8; for (pos_type i = 0; i < n; ++i) { - par.insertChar(pos, ' ', font); + par.insertChar(pos, ' ', font, Change(Change::INSERTED)); ++pos; } space_inserted = true; @@ -537,7 +537,7 @@ continue; } else { // just insert the character - par.insertChar(pos, *cit, font); + par.insertChar(pos, *cit, font, Change(Change::INSERTED)); ++pos; space_inserted = (*cit == ' '); } Index: CutAndPaste.C =================================================================== --- CutAndPaste.C (Revision 13818) +++ CutAndPaste.C (Arbeitskopie) @@ -296,7 +296,7 @@ // is "blue" for (pit_type pit = startpit; pit != endpit + 1;) { bool const merge = !params.tracking_changes || - pars[pit].lookupChange(pars[pit].size()) == + pars[pit].lookupChange(pars[pit].size()).type == Change::INSERTED; pos_type const left = ( pit == startpit ? startpos : 0 ); pos_type const right = ( pit == endpit ? endpos : @@ -675,7 +675,7 @@ string::const_iterator cit = str.begin(); string::const_iterator end = str.end(); for (; cit != end; ++cit, ++pos) - par.insertChar(pos, (*cit), font); + par.insertChar(pos, (*cit), font, Change(Change::INSERTED)); // Cut the selection cutSelection(cur, true, false); Index: paragraph_funcs.C =================================================================== --- paragraph_funcs.C (Revision 13818) +++ paragraph_funcs.C (Arbeitskopie) @@ -59,10 +59,6 @@ bool moveItem(Paragraph & from, Paragraph & to, BufferParams const & params, pos_type i, pos_type j, - Change change = Change(Change::INSERTED)); - -bool moveItem(Paragraph & from, Paragraph & to, - BufferParams const & params, pos_type i, pos_type j, Change change) { Paragraph::value_type const tmpchar = from.getChar(i); @@ -144,8 +140,8 @@ pos_type pos_end = par.size() - 1; for (pos_type i = pos, j = pos; i <= pos_end; ++i) { - Change::Type change = par.lookupChange(i).type; - if (moveItem(par, *tmp, bparams, i, j - pos)) { + Change change = par.lookupChange(i); + if (moveItem(par, *tmp, bparams, i, j - pos, Change(Change::INSERTED))) { tmp->setChange(j - pos, change); ++j; } @@ -212,18 +208,18 @@ pos_type pos_end = par.size() - 1; for (pos_type i = pos, j = pos; i <= pos_end; ++i) { - Change::Type change = par.lookupChange(i).type; + Change change = par.lookupChange(i); if (moveItem(par, tmp, bparams, i, j - pos, change)) ++j; } // Move over end-of-par change attr - tmp.setChange(tmp.size(), par.lookupChange(par.size()).type); + tmp.setChange(tmp.size(), par.lookupChange(par.size())); // If tracking changes, set all the text that is to be // erased to Type::INSERTED. for (pos_type k = pos_end; k >= pos; --k) { if (bparams.tracking_changes) - par.setChange(k, Change::INSERTED); + par.setChangeType(k, Change::INSERTED); par.erase(k); } } @@ -250,12 +246,12 @@ // one. It will (should) remain "orphaned", having no CT info to it, // and check() in changes.C will assert. Setting the para break // forcibly to "black" prevents this scenario. -- MV 13.3.2006 - par.setChange(par.size(), Change::UNCHANGED); + par.setChangeType(par.size(), Change::UNCHANGED); - Change::Type cr = next.lookupChange(next.size()).type; + Change cr = next.lookupChange(next.size()); // ok, now copy the paragraph for (pos_type i = 0, j = 0; i <= pos_end; ++i) { - Change::Type change = next.lookupChange(i).type; + Change change = next.lookupChange(i); if (moveItem(next, par, bparams, i, pos_insert + j, change)) ++j; } Index: rowpainter.C =================================================================== --- rowpainter.C (Revision 13818) +++ rowpainter.C (Arbeitskopie) @@ -266,7 +266,7 @@ if (pos < font_span.first || pos > font_span.last) break; - if (prev_change != par_.lookupChange(pos)) + if (prev_change != par_.lookupChange(pos).type) break; char_type c = par_.getChar(pos); Index: changes.h =================================================================== --- changes.h (Revision 13818) +++ changes.h (Arbeitskopie) @@ -30,7 +30,7 @@ DELETED // deleted text }; - Change(Type t = UNCHANGED, int a = 0, lyx::time_type ct = 0) + explicit Change(Type t, int a = 0, lyx::time_type ct = 0) : type(t), author(a), changetime(ct) {} Type type; Index: paragraph.C =================================================================== --- paragraph.C (Revision 13819) +++ paragraph.C (Arbeitskopie) @@ -254,7 +254,7 @@ LyXFont const & font) { for (size_t i = 0, n = str.size(); i != n ; ++i) - insertChar(start + i, str[i], font); + insertChar(start + i, str[i], font, Change(Change::INSERTED)); } Index: text.C =================================================================== --- text.C (Revision 13821) +++ text.C (Arbeitskopie) @@ -169,7 +169,7 @@ string layoutname = lex.getString(); font = LyXFont(LyXFont::ALL_INHERIT, bp.language); - change = Change(); + change = Change(Change::UNCHANGED); LyXTextClass const & tclass = bp.getLyXTextClass(); @@ -350,7 +350,7 @@ lex.nextToken(); string token = lex.getString(); LyXFont font; - Change change; + Change change(Change::UNCHANGED); while (lex.isOK()) { @@ -1098,7 +1098,7 @@ // Mark "carriage return" as inserted if change tracking: if (cur.buffer().params().tracking_changes) { - cur.paragraph().setChange(cur.paragraph().size(), + cur.paragraph().setChangeType(cur.paragraph().size(), Change::INSERTED); } @@ -1183,7 +1183,7 @@ BOOST_ASSERT(cur.pos() > 0); if ((par.isLineSeparator(cur.pos() - 1) || par.isNewline(cur.pos() - 1)) - && par.lookupChange(cur.pos() - 1) != Change::DELETED) { + && par.lookupChange(cur.pos() - 1).type != Change::DELETED) { static bool sent_space_message = false; if (!sent_space_message) { cur.message(_("You cannot type two spaces this way. " @@ -1194,7 +1194,7 @@ } } - par.insertChar(cur.pos(), c, current_font); + par.insertChar(cur.pos(), c, current_font, Change(Change::INSERTED)); setCursor(cur, cur.pit(), cur.pos() + 1, false, cur.boundary()); charInserted(); } @@ -1425,7 +1425,7 @@ boost::next(plist.begin(), et.pit())); // Paragraph merge if appropriate: - if (pars_[it.pit()].lookupChange(pars_[it.pit()].size()) + if (pars_[it.pit()].lookupChange(pars_[it.pit()].size()).type == Change::DELETED) { setCursorIntern(cur, it.pit() + 1, 0); backspacePos0(cur); @@ -1461,7 +1461,7 @@ pars_.erase(boost::next(plist.begin(), it.pit() + 1), boost::next(plist.begin(), et.pit())); // Paragraph merge if appropriate: - if (pars_[it.pit()].lookupChange(pars_[it.pit()].size()) + if (pars_[it.pit()].lookupChange(pars_[it.pit()].size()).type == Change::INSERTED) { setCursorIntern(cur, it.pit() + 1, 0); backspacePos0(cur); @@ -1586,7 +1586,7 @@ recordUndo(cur, Undo::DELETE, cur.pit()); setCursorIntern(cur, cur.pit(), cur.pos() + 1, false, cur.boundary()); needsUpdate = backspace(cur); - if (cur.paragraph().lookupChange(cur.pos()) == Change::DELETED) + if (cur.paragraph().lookupChange(cur.pos()).type == Change::DELETED) cur.posRight(); } else if (cur.pit() != cur.lastpit()) { LCursor scur = cur; @@ -1598,7 +1598,7 @@ if (cur.buffer().params().tracking_changes) { // move forward after the paragraph break is DELETED Paragraph & par = cur.paragraph(); - if (par.lookupChange(par.size()) == Change::DELETED) + if (par.lookupChange(par.size()).type == Change::DELETED) setCursorIntern(cur, cur.pit() + 1, 0); } } else { @@ -1699,8 +1699,8 @@ // deleted: Paragraph & par = pars_[cur.pit() - 1]; // Take care of a just inserted para break: - if (par.lookupChange(par.size()) != Change::INSERTED) { - par.setChange(par.size(), Change::DELETED); + if (par.lookupChange(par.size()).type != Change::INSERTED) { + par.setChangeType(par.size(), Change::DELETED); setCursorIntern(cur, cur.pit() - 1, par.size()); return true; } @@ -1754,7 +1754,8 @@ if (!hasbibitem) { InsetBibitem * inset(new InsetBibitem(InsetCommandParams("bibitem"))); - par.insertInset(0, static_cast<InsetBase *>(inset)); + par.insertInset(0, static_cast<InsetBase *>(inset), + Change(Change::INSERTED)); bv()->cursor().posRight(); } } @@ -2253,7 +2254,8 @@ Paragraph const & par = cur.paragraph(); std::ostringstream os; - bool const show_change = par.lookupChange(cur.pos()) != Change::UNCHANGED; + bool const show_change = + par.lookupChange(cur.pos()).type != Change::UNCHANGED; if (buf.params().tracking_changes) os << "[C] ";