+ disp_.update(Update::None);
+}
+
+
+LyXFont LCursor::getFont() const
+{
+ // HACK. far from being perfect...
+ int s = 0;
+ // go up until first non-0 text is hit
+ // (innermost text is 0 in mathed)
+ for (s = depth() - 1; s >= 0; --s)
+ if (operator[](s).text())
+ break;
+ CursorSlice const & sl = operator[](s);
+ LyXText const & text = *sl.text();
+ LyXFont font = text.getPar(sl.pit()).getFont(
+ bv().buffer()->params(),
+ sl.pos(),
+ outerFont(sl.pit(), text.paragraphs()));
+
+ return font;
+}
+
+
+void LCursor::fixIfBroken()
+{
+ // find out last good level
+ LCursor copy = *this;
+ size_t newdepth = depth();
+ while (!copy.empty()) {
+ if (copy.idx() > copy.lastidx()) {
+ lyxerr << "wrong idx " << copy.idx()
+ << ", max is " << copy.lastidx()
+ << " at level " << copy.depth()
+ << ". Trying to correct this." << endl;
+ newdepth = copy.depth() - 1;
+ }
+ else if (copy.pit() > copy.lastpit()) {
+ lyxerr << "wrong pit " << copy.pit()
+ << ", max is " << copy.lastpit()
+ << " at level " << copy.depth()
+ << ". Trying to correct this." << endl;
+ newdepth = copy.depth() - 1;
+ }
+ else if (copy.pos() > copy.lastpos()) {
+ lyxerr << "wrong pos " << copy.pos()
+ << ", max is " << copy.lastpos()
+ << " at level " << copy.depth()
+ << ". Trying to correct this." << endl;
+ newdepth = copy.depth() - 1;
+ }
+ copy.pop();
+ }
+ // shrink cursor to a size where everything is valid, possibly
+ // leaving insets
+ while (depth() > newdepth) {
+ pop();
+ lyxerr << "correcting cursor to level " << depth() << endl;
+ }