3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Matthias Ettrich
7 * \author Lars Gullik Bjønnes
10 * Full author contact details are available in file CREDITS.
17 #include "support/debug.h"
33 void TexRow::start(int id, int pos)
44 void TexRow::newline()
46 int const id = lastid;
47 RowList::value_type tmp(id, lastpos);
48 rowlist.push_back(tmp);
52 void TexRow::newlines(int num_lines)
54 for (int i = 0; i < num_lines; ++i) {
59 bool TexRow::getIdFromRow(int row, int & id, int & pos) const
61 if (row <= 0 || row > int(rowlist.size())) {
67 id = rowlist[row - 1].id();
68 pos = rowlist[row - 1].pos();
73 int TexRow::getRowFromIdPos(int id, int pos) const
77 // this loop finds the last *nonempty* row with the same id
78 // and position <= pos
79 RowList::const_iterator bestrow = rowlist.begin();
80 RowList::const_iterator it = rowlist.begin();
81 RowList::const_iterator const end = rowlist.end();
82 for (; it != end; ++it) {
83 if (it->id() == id && it->pos() <= pos) {
85 if (bestrow->id() != id || it->pos() > bestrow->pos())
91 return rowlist.size();
92 return distance(rowlist.begin(), bestrow) + 1;