#include "insets/insetenv.h"
+#include "mathed/InsetMathHull.h"
+
#include "support/textutils.h"
#include <boost/current_function.hpp>
for (pit_type pit = 0; pit != end; ++pit)
pars_[pit].rows().clear();
- current_font = getFont(pars_[0], 0);
updateLabels(*bv->buffer());
}
if (font == LyXFont(LyXFont::ALL_IGNORE)) {
// Could only happen with user style
cur.message(_("No font change defined. "
- "Use Character under the Layout menu to define font change."));
+ "Use Character under the Layout menu to define font change."));
return;
}
{
BOOST_ASSERT(this == cur.text());
- string idxstring;
- if (cur.selection()) {
+ docstring idxstring;
+ if (cur.selection())
idxstring = cur.selectionAsString(false);
- } else {
+ else {
// Try implicit word selection. If there is a change
// in the language the implicit word selection is
// disabled.
idxstring = tmpcur.selectionAsString(false);
}
- return idxstring;
+ return lyx::to_utf8(idxstring);
}
// needed to insert the selection
-void LyXText::insertStringAsLines(LCursor & cur, string const & str)
+void LyXText::insertStringAsLines(LCursor & cur, docstring const & str)
{
cur.buffer().insertStringAsLines(pars_, cur.pit(), cur.pos(),
current_font, str, autoBreakRows_);
// turn double CR to single CR, others are converted into one
// blank. Then insertStringAsLines is called
-void LyXText::insertStringAsParagraphs(LCursor & cur, string const & str)
+void LyXText::insertStringAsParagraphs(LCursor & cur, docstring const & str)
{
- string linestr = str;
+ docstring linestr = str;
bool newline_inserted = false;
for (string::size_type i = 0, siz = linestr.size(); i < siz; ++i) {
void LyXText::setCursorIntern(LCursor & cur,
pit_type par, pos_type pos, bool setfont, bool boundary)
{
+ BOOST_ASSERT(this == cur.text());
cur.boundary(boundary);
setCursor(cur.top(), par, pos);
cur.setTargetX();
c = bidi.vis2log(vc);
last_tmpx = tmpx;
if (body_pos > 0 && c == body_pos - 1) {
- string lsep = layout->labelsep;
- docstring dlsep(lsep.begin(), lsep.end());
+ string lsep = layout->labelsep;
+ docstring dlsep(lsep.begin(), lsep.end());
tmpx += r.label_hfill +
font_metrics::width(dlsep, getLabelFont(par));
if (par.isLineSeparator(body_pos - 1))
if (!cur.selection()) {
int const y = bv_funcs::getPos(cur, cur.boundary()).y_;
LCursor old = cur;
- editXY(cur, x, y - par.rows()[row].ascent() - 1);
+ // Go to middle of previous row. 16 found to work OK;
+ // 12 = top/bottom margin of display math
+ int const margin = 3 * InsetMathHull::displayMargin() / 2;
+ editXY(cur, x, y - par.rows()[row].ascent() - margin);
cur.clearSelection();
// This happens when you move out of an inset.
if (!cur.selection()) {
int const y = bv_funcs::getPos(cur, cur.boundary()).y_;
LCursor old = cur;
- editXY(cur, x, y + par.rows()[row].descent() + 1);
+ // To middle of next row
+ int const margin = 3 * InsetMathHull::displayMargin() / 2;
+ editXY(cur, x, y + par.rows()[row].descent() + margin);
cur.clearSelection();
// This happens when you move out of an inset.