+size_type calculateRowSignature(Row const & row, Paragraph const & par,
+ int x, int y)
+{
+ boost::crc_32_type crc;
+ for (pos_type i = row.pos(); i < row.endpos(); ++i) {
+ char_type const b[] = { par.getChar(i) };
+ crc.process_bytes(b, 1);
+ }
+ char_type const b[] = { x, y, row.width() };
+ crc.process_bytes(b, 3);
+ return crc.checksum();
+}
+
+
+bool CursorOnRow(PainterInfo & pi, pit_type const pit,
+ RowList::const_iterator rit, LyXText const & text)
+{
+ // Is there a cursor on this row (or inside inset on row)
+ LCursor & cur = pi.base.bv->cursor();
+ for (size_type d = 0; d < cur.depth(); ++d) {
+ CursorSlice const & sl = cur[d];
+ if (sl.text() == &text
+ && sl.pit() == pit
+ && sl.pos() >= rit->pos()
+ && sl.pos() <= rit->endpos())
+ return true;
+ }
+ return false;
+}
+
+
+bool innerCursorOnRow(PainterInfo & pi, pit_type pit,
+ RowList::const_iterator rit, LyXText const & text)
+{
+ // Is there a cursor inside an inset on this row, and is this inset
+ // the only "character" on this row
+ LCursor & cur = pi.base.bv->cursor();
+ if (rit->pos() + 1 != rit->endpos())
+ return false;
+ for (size_type d = 0; d < cur.depth(); d++) {
+ CursorSlice const & sl = cur[d];
+ if (sl.text() == &text
+ && sl.pit() == pit
+ && sl.pos() == rit->pos())
+ return d < cur.depth() - 1;
+ }
+ return false;
+}
+
+