else
text_entry_ = size();
}
+ forceAddEntry(entry);
+ return true;
+}
+
+
+void TexRow::RowEntryList::forceAddEntry(RowEntry const & entry)
+{
if (size() == 0 || !(operator[](size() - 1) == entry))
push_back(RowEntry(entry));
- return true;
}
}
+void TexRow::RowEntryList::append(RowEntryList const & row)
+{
+ if (text_entry_ >= size())
+ text_entry_ = row.text_entry_ + size();
+ insert(end(), row.begin(), row.end());
+}
+
+
TexRow::TextEntry const TexRow::text_none = { -1, 0 };
-TexRow::RowEntry const TexRow::row_none = { false, TexRow::text_none };
+TexRow::RowEntry const TexRow::row_none = { false, { TexRow::text_none } };
bool TexRow::isNone(TextEntry const & t)
}
-bool TexRow::startMath(uid_type id, idx_type cell)
+void TexRow::forceStart(int id, int pos)
+{
+ if (!enabled_)
+ return;
+ return current_row_.forceAddEntry(textEntry(id,pos));
+}
+
+
+void TexRow::startMath(uid_type id, idx_type cell)
{
- return start(mathEntry(id,cell));
+ start(mathEntry(id,cell));
}
}
+void TexRow::append(TexRow const & texrow)
+{
+ if (!enabled_ || !texrow.enabled_)
+ return;
+ RowList::const_iterator it = texrow.rowlist_.begin();
+ RowList::const_iterator const end = texrow.rowlist_.end();
+ if (it == end) {
+ current_row_.append(texrow.current_row_);
+ } else {
+ current_row_.append(*it++);
+ rowlist_.push_back(current_row_);
+ rowlist_.insert(rowlist_.end(), it, end);
+ current_row_ = texrow.current_row_;
+ }
+}
+
+
+
bool TexRow::getIdFromRow(int row, int & id, int & pos) const
{
TextEntry t = text_none;
- bool ret = false;
if (row <= int(rowlist_.size()))
while (row > 0 && isNone(t = rowlist_[row - 1].getTextEntry()))
--row;
- if (row > 0)
- ret = true;
id = t.id;
pos = t.pos;
- return ret;
+ return !isNone(t);
}
{
return row_it_ == row_end_;
}
-
-
+
+
bool operator==(RowListIterator const & a) const
{
return row_it_ == a.row_it_ && ((atEnd() && a.atEnd()) || it_ == a.it_);
end_offset = 1;
break;
case -1: {
- // ...or it is the row preceding the first that matches pos+1
+ // ...or it is the row preceding the first that matches pos+1
if (!end_is_next) {
end_is_next = true;
if (it.row() != best_end_entry.row())
std::pair<int,int> beg_rows = rowFromDocIterator(beg);
if (cur.selection()) {
DocIterator end = cur.selectionEnd();
- if (!cur.selIsMultiCell())
- end.top().backwardPos();
+ if (!cur.selIsMultiCell()
+ // backwardPos asserts without the following test, IMO it's not my
+ // duty to check this.
+ && (end.top().pit() != 0
+ || end.top().idx() != 0
+ || end.top().pos() != 0))
+ end.top().backwardPos();
std::pair<int,int> end_rows = rowFromDocIterator(end);
return std::make_pair(std::min(beg_rows.first, end_rows.first),
std::max(beg_rows.second, end_rows.second));
for (int i = 0; i < texrow.rows(); i++) {
int id,pos;
if (texrow.getIdFromRow(i+1,id,pos) && id>0)
- l << i+1 << ":" << id << ":" << pos << "\n";
+ l << i+1 << ":" << id << ":" << pos << "\n";
}
}
return l;