+ if (this != bv()->cursor().text()) {
+ lyxerr << "cursor: " << bv()->cursor()
+ << "\ntext: " << bv()->cursor().text()
+ << "\nthis: " << this << endl;
+ BOOST_ASSERT(false);
+ }
+ return bv()->cursor().current();
+}
+
+
+void LyXText::replaceSelection(LCursor & cur)
+{
+ BOOST_ASSERT(this == cur.text());
+ if (cur.selection()) {
+ cutSelection(cur, true, false);
+ cur.update();
+ }
+}
+
+
+// Returns the current font and depth as a message.
+string LyXText::currentState(LCursor & cur)
+{
+ BOOST_ASSERT(this == cur.text());
+ Buffer * buffer = bv()->buffer();
+ Paragraph const & par = cur.paragraph();
+ std::ostringstream os;
+
+ bool const show_change = buffer->params().tracking_changes
+ && cur.pos() != cur.lastpos()
+ && par.lookupChange(cur.pos()) != Change::UNCHANGED;
+
+ if (show_change) {
+ Change change = par.lookupChangeFull(cur.pos());
+ Author const & a = buffer->params().authors().get(change.author);
+ os << _("Change: ") << a.name();
+ if (!a.email().empty())
+ os << " (" << a.email() << ")";
+ if (change.changetime)
+ os << _(" at ") << ctime(&change.changetime);
+ os << " : ";
+ }
+
+ // I think we should only show changes from the default
+ // font. (Asger)
+ LyXFont font = real_current_font;
+ font.reduce(buffer->params().getLyXTextClass().defaultfont());
+
+ // avoid _(...) re-entrance problem
+ string const s = font.stateText(&buffer->params());
+ os << bformat(_("Font: %1$s"), s);
+
+ // os << bformat(_("Font: %1$s"), font.stateText(&buffer->params));
+
+ // The paragraph depth
+ int depth = getDepth();
+ if (depth > 0)
+ os << bformat(_(", Depth: %1$s"), tostr(depth));
+
+ // The paragraph spacing, but only if different from
+ // buffer spacing.
+ Spacing const & spacing = par.params().spacing();
+ if (!spacing.isDefault()) {
+ os << _(", Spacing: ");
+ switch (spacing.getSpace()) {
+ case Spacing::Single:
+ os << _("Single");
+ break;
+ case Spacing::Onehalf:
+ os << _("OneHalf");
+ break;
+ case Spacing::Double:
+ os << _("Double");
+ break;
+ case Spacing::Other:
+ os << _("Other (") << spacing.getValue() << ')';
+ break;
+ case Spacing::Default:
+ // should never happen, do nothing
+ break;
+ }
+ }
+#ifdef DEVEL_VERSION
+ os << _(", Paragraph: ") << par.id();
+ os << _(", Position: ") << cur.pos();
+ Row & row = cur.textRow();
+ os << bformat(_(", Row b:%1$d e:%2$d"), row.pos(), row.endpos());
+ os << _(", Inset: ");
+ InsetOld * inset = par.inInset();
+ if (inset)
+ os << inset << " owner: " << inset->owner();
+ else
+ os << -1;
+#endif
+ return os.str();