void InsetMathNest::write(WriteStream & os) const
{
+ MathEnsurer ensurer(os, currentMode() == MATH_MODE);
ModeSpecifier specifier(os, currentMode(), lockedMode());
docstring const latex_name = name();
os << '\\' << latex_name;
}
-int InsetMathNest::latex(odocstream & os, OutputParams const & runparams) const
+void InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
{
- WriteStream wi(os, runparams.moving_arg, true,
+ WriteStream wi(os.os(), runparams.moving_arg, true,
runparams.dryrun ? WriteStream::wsDryrun : WriteStream::wsDefault,
runparams.encoding);
+ wi.canBreakLine(os.canBreakLine());
write(wi);
- return wi.line();
+ os.canBreakLine(wi.canBreakLine());
+
+ int lf = wi.line();
+ if (lf > 0 && runparams.lastid != -1) {
+ --lf;
+ os.texrow().newline();
+ os.texrow().start(runparams.lastid, runparams.lastpos);
+ }
+ os.texrow().newlines(lf);
}
bool InsetMathNest::setMouseHover(BufferView const * bv, bool mouse_hover)
+ const
{
mouse_hover_[bv] = mouse_hover;
return true;
}
case LFUN_REGEXP_MODE: {
- InsetMathHull * i = dynamic_cast<InsetMathHull *>(cur.inset().asInsetMath());
- if (i && i->getType() == hullRegexp) {
- cur.message(_("Already in regular expression mode"));
- break;
+ InsetMath * im = cur.inset().asInsetMath();
+ if (im) {
+ InsetMathHull * i = im->asHullInset();
+ if (i && i->getType() == hullRegexp) {
+ cur.message(_("Already in regular expression mode"));
+ break;
+ }
}
cur.macroModeClose();
docstring const save_selection = grabAndEraseSelection(cur);
if (have_l)
cur.insert(MathAtom(new InsetMathBig(lname,
ldelim)));
- cur.niceInsert(selection);
- if (have_r)
+ // first insert the right delimiter and then go back
+ // and re-insert the selection (bug 7088)
+ if (have_r) {
cur.insert(MathAtom(new InsetMathBig(rname,
rdelim)));
+ cur.posBackward();
+ }
+ cur.niceInsert(selection);
}
// Don't call cur.undispatched() if we did nothing, this would
// lead to infinite recursion via Text::dispatch().
string data;
if (name == "ref") {
InsetMathRef tmp(buffer_, name);
- data = tmp.createDialogStr(to_utf8(name));
+ data = tmp.createDialogStr();
cur.bv().showDialog(to_utf8(name), data);
} else if (name == "mathspace") {
cur.bv().showDialog(to_utf8(name));
break;
}
+ case LFUN_MATH_MODE:
+ // forbid "math-mode on" in math mode to prevent irritating
+ // behaviour of menu entries (bug 6709)
+ flag.setEnabled(currentMode() == TEXT_MODE || arg != "on");
+ break;
+
case LFUN_MATH_INSERT:
flag.setEnabled(currentMode() != TEXT_MODE);
break;
}
case LFUN_SPECIALCHAR_INSERT:
+ case LFUN_SCRIPT_INSERT:
// FIXME: These would probably make sense in math-text mode
flag.setEnabled(false);
break;
{
//lyxerr << "## lfunMousePress: buttons: " << cmd.button() << endl;
BufferView & bv = cur.bv();
+ if (cmd.button() == mouse_button::button3) {
+ // Don't do anything if we right-click a
+ // selection, a context menu will popup.
+ if (bv.cursor().selection() && cur >= bv.cursor().selectionBegin()
+ && cur < bv.cursor().selectionEnd()) {
+ cur.noScreenUpdate();
+ return;
+ }
+ }
bool do_selection = cmd.button() == mouse_button::button1
&& cmd.argument() == "region-select";
bv.mouseSetCursor(cur, do_selection);
// position if needed
// cur.result().update(): don't overwrite previously set flags.
cur.screenUpdateFlags(Update::Decoration | Update::FitCursor
- | cur.result().update());
+ | cur.result().screenUpdate());
} else if (cmd.button() == mouse_button::button2) {
if (cap::selection()) {
// See comment in Text::dispatch why we do this