#include "mathed/math_support.h"
#include "support/limited_stack.h"
+#include "support/std_sstream.h"
+
#include "frontends/LyXView.h"
#include <boost/assert.hpp>
asc = 10;
des = 10;
} else {
- Row const & row = *text()->cursorRow();
+ Row const & row = textRow();
asc = row.baseline();
des = row.height() - asc;
}
}
-void LCursor::info(std::ostream & os)
+void LCursor::info(std::ostream & os) const
{
for (int i = 1, n = depth(); i < n; ++i) {
cursor_[i].inset()->infoize(os);
if (inMathed())
insert(MathAtom(inset));
else
- text()->insertInset(inset);
+ text()->insertInset(*this, inset);
}
return 0;
if (inMathed())
return nextAtom().nucleus();
- Paragraph & par = paragraph();
- return par.isInset(pos()) ? par.getInset(pos()) : 0;
+ return paragraph().isInset(pos()) ? paragraph().getInset(pos()) : 0;
}
return 0;
if (inMathed())
return prevAtom().nucleus();
- Paragraph & par = paragraph();
- return par.isInset(pos() - 1) ? par.getInset(pos() - 1) : 0;
+ return paragraph().isInset(pos() - 1) ? paragraph().getInset(pos() - 1) : 0;
+}
+
+
+InsetBase const * LCursor::prevInset() const
+{
+ if (pos() == 0)
+ return 0;
+ if (inMathed())
+ return prevAtom().nucleus();
+ return paragraph().isInset(pos() - 1) ? paragraph().getInset(pos() - 1) : 0;
}
#warning an mathed?
return string();
}
+
+
+string LCursor::currentState()
+{
+ if (inMathed()) {
+ std::ostringstream os;
+ info(os);
+ return os.str();
+ }
+ return text()->currentState(*this);
+}
+
+
+// only used by the spellchecker
+void LCursor::replaceWord(string const & replacestring)
+{
+ LyXText * t = text();
+
+ t->replaceSelectionWithString(*this, replacestring);
+ t->setSelectionRange(*this, replacestring.length());
+
+ // Go back so that replacement string is also spellchecked
+ for (string::size_type i = 0; i < replacestring.length() + 1; ++i)
+ t->cursorLeft(*this, true);
+}
+