+
+void Changes::addToToc(DocIterator const & cdit, Buffer const & buffer,
+ bool output_active) const
+{
+ if (table_.empty())
+ return;
+
+ shared_ptr<Toc> change_list = buffer.tocBackend().toc("change");
+ AuthorList const & author_list = buffer.params().authors();
+ DocIterator dit = cdit;
+
+ ChangeTable::const_iterator it = table_.begin();
+ ChangeTable::const_iterator const itend = table_.end();
+ for (; it != itend; ++it) {
+ docstring str;
+ switch (it->change.type) {
+ case Change::UNCHANGED:
+ continue;
+ case Change::DELETED:
+ // ✂ U+2702 BLACK SCISSORS
+ str.push_back(0x2702);
+ break;
+ case Change::INSERTED:
+ // ✍ U+270D WRITING HAND
+ str.push_back(0x270d);
+ break;
+ }
+ dit.pos() = it->range.start;
+ Paragraph const & par = dit.paragraph();
+ str += " " + par.asString(it->range.start, min(par.size(), it->range.end));
+ if (it->range.end > par.size())
+ // ¶ U+00B6 PILCROW SIGN
+ str.push_back(0xb6);
+ docstring const & author = author_list.get(it->change.author).name();
+ Toc::iterator it = TocBackend::findItem(*change_list, 0, author);
+ if (it == change_list->end()) {
+ change_list->push_back(TocItem(dit, 0, author, true));
+ change_list->push_back(TocItem(dit, 1, str, output_active));
+ continue;
+ }
+ for (++it; it != change_list->end(); ++it) {
+ if (it->depth() == 0 && it->str() != author)
+ break;
+ }
+ change_list->insert(it, TocItem(dit, 1, str, output_active));
+ }
+}
+
+
+void Changes::updateBuffer(Buffer const & buf)
+{
+ is_update_required_ = false;
+ if (!buf.areChangesPresent() && isChanged())
+ buf.setChangesPresent(true);
+}
+
+
+void Change::paintCue(PainterInfo & pi, double const x1, double const y,
+ double const x2, FontInfo const & font) const
+{
+ if (!changed())
+ return;
+ // Calculate 1/3 height of font
+ FontMetrics const & fm = theFontMetrics(font);
+ double const y_bar = deleted() ? y - fm.maxAscent() / 3
+ : y + 2 * pi.base.solidLineOffset() + pi.base.solidLineThickness();
+ pi.pain.line(int(x1), int(y_bar), int(x2), int(y_bar), color(),
+ Painter::line_solid, pi.base.solidLineThickness());
+}
+
+
+void Change::paintCue(PainterInfo & pi, double const x1, double const y1,
+ double const x2, double const y2) const
+{
+ /*
+ * y1 /
+ * /
+ * /
+ * /
+ * /
+ * y2 /_____
+ * x1 x2
+ */
+ switch(type) {
+ case UNCHANGED:
+ return;
+ case INSERTED:
+ pi.pain.line(int(x1), int(y2) + 1, int(x2), int(y2) + 1,
+ color(), Painter::line_solid,
+ pi.base.solidLineThickness());
+ return;
+ case DELETED:
+ // FIXME: we cannot use antialias since we keep drawing on the same
+ // background with the current painting mechanism.
+ pi.pain.line(int(x1), int(y2), int(x2), int(y1),
+ color(), Painter::line_solid_aliased,
+ pi.base.solidLineThickness());
+ return;
+ }
+}
+
+