- lyx::Assert(pos < size());
- // if it is an inset, delete the inset entry
- if (text[pos] == LyXParagraph::META_INSET) {
- // find the entry
- InsetTable search_inset(pos, 0);
- InsetList::iterator it =
- lower_bound(insetlist.begin(),
- insetlist.end(),
- search_inset, matchIT());
- if (it != insetlist.end() && (*it).pos == pos) {
- delete (*it).inset;
- insetlist.erase(it);
- }
- }
-
- text.erase(text.begin() + pos);
-
- // Erase entries in the tables.
- FontTable search_font(pos, LyXFont());
-
- FontList::iterator it =
- lower_bound(fontlist.begin(),
- fontlist.end(),
- search_font, matchFT());
- if (it != fontlist.end() && (*it).pos() == pos &&
- (pos == 0 ||
- (it != fontlist.begin() && (*(it - 1)).pos() == pos - 1))) {
- // If it is a multi-character font
- // entry, we just make it smaller
- // (see update below), otherwise we
- // should delete it.
- unsigned int const i = it - fontlist.begin();
- fontlist.erase(fontlist.begin() + i);
- it = fontlist.begin() + i;
- if (i > 0 && i < fontlist.size() &&
- fontlist[i - 1].font() == fontlist[i].font()) {
- fontlist.erase(fontlist.begin() + i - 1);
- it = fontlist.begin() + i - 1;
- }
- }
-
- // Update all other entries.
- FontList::iterator fend = fontlist.end();
- for (; it != fend; ++it)
- (*it).pos((*it).pos() - 1);
-
- // Update the inset table.
- InsetTable search_inset(pos, 0);
- InsetList::iterator lend = insetlist.end();
- for (InsetList::iterator it =
- upper_bound(insetlist.begin(),
- lend,
- search_inset, matchIT());
- it != lend; ++it)
- --(*it).pos;