]> git.lyx.org Git - lyx.git/blobdiff - src/Changes.cpp
Kornel's gcc compile fix.
[lyx.git] / src / Changes.cpp
index 685e69b0ee9007f52bc57253dedb08319e256a6a..2f7feb1256243571d9f253f6201365a95e7f8494 100644 (file)
@@ -54,9 +54,9 @@ bool Change::isSimilarTo(Change const & change) const
 }
 
 
-ColorCode Change::color() const
+Color Change::color() const
 {
-       ColorCode color = Color_none;
+       Color color = Color_none;
        switch (author % 5) {
                case 0:
                        color = Color_changedtextauthor1;
@@ -74,6 +74,10 @@ ColorCode Change::color() const
                        color = Color_changedtextauthor5;
                        break;
        }
+
+       if (deleted())
+               color.mergeColor = Color_deletedtextmodifier;
+
        return color;
 }
 
@@ -252,6 +256,24 @@ Change const & Changes::lookup(pos_type const pos) const
 }
 
 
+bool Changes::isDeleted(pos_type start, pos_type end) const
+{
+       ChangeTable::const_iterator it = table_.begin();
+       ChangeTable::const_iterator const itend = table_.end();
+
+       for (; it != itend; ++it) {
+               if (it->range.contains(Range(start, end))) {
+                       LYXERR(Debug::CHANGES, "range ("
+                               << start << ", " << end << ") fully contains ("
+                               << it->range.start << ", " << it->range.end
+                               << ") of type " << it->change.type);
+                       return it->change.type == Change::DELETED;
+               }
+       }
+       return false;
+}
+
+
 bool Changes::isChanged(pos_type const start, pos_type const end) const
 {
        ChangeTable::const_iterator it = table_.begin();
@@ -347,7 +369,7 @@ int Changes::latexMarkChange(odocstream & os, BufferParams const & bparams,
 }
 
 
-void Changes::lyxMarkChange(ostream & os, int & column,
+void Changes::lyxMarkChange(ostream & os, BufferParams const & bparams, int & column,
                            Change const & old, Change const & change)
 {
        if (old == change)
@@ -355,19 +377,21 @@ void Changes::lyxMarkChange(ostream & os, int & column,
 
        column = 0;
 
+       int const buffer_id = bparams.authors().get(change.author).buffer_id();
+
        switch (change.type) {
                case Change::UNCHANGED:
                        os << "\n\\change_unchanged\n";
                        break;
 
                case Change::DELETED: {
-                       os << "\n\\change_deleted " << change.author
+                       os << "\n\\change_deleted " << buffer_id
                                << " " << change.changetime << "\n";
                        break;
                }
 
                case Change::INSERTED: {
-                       os << "\n\\change_inserted " << change.author
+                       os << "\n\\change_inserted " << buffer_id
                                << " " << change.changetime << "\n";
                        break;
                }
@@ -406,15 +430,16 @@ void Changes::addToToc(DocIterator const & cdit, Buffer const & buffer) const
                        str.push_back(0x2702);
                        break;
                case Change::INSERTED:
-                       // 0x2702 is the hand writting symbol in the Dingbats unicode group.
+                       // 0x270d is the hand writting symbol in the Dingbats unicode group.
                        str.push_back(0x270d);
                        break;
                }
                dit.pos() = it->range.start;
                Paragraph const & par = dit.paragraph();
-               str += " " + par.asString(it->range.start, max(par.size(), it->range.end));
-               // FIXME: find an unicode character for carriage return presentation if
-               // present; i.e. when it->range.end > par.size()
+               str += " " + par.asString(it->range.start, min(par.size(), it->range.end));
+               if (it->range.end > par.size())
+                       // the end of paragraph symbol from the Punctuation group
+                       str.push_back(0x204B);
                docstring const & author = author_list.get(it->change.author).name();
                Toc::iterator it = change_list.item(0, author);
                if (it == change_list.end()) {