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(otexstream & os, OutputParams const & runparams) const
+void InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
{
WriteStream wi(os.os(), runparams.moving_arg, true,
runparams.dryrun ? WriteStream::wsDryrun : WriteStream::wsDefault,
wi.canBreakLine(os.canBreakLine());
write(wi);
os.canBreakLine(wi.canBreakLine());
- return wi.line();
+
+ 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;
act == LFUN_UP_SELECT;
cur.selHandle(select);
+ // handle autocorrect:
+ cur.autocorrect() = false;
+ cur.message(_("Autocorrect Off ('!' to enter)"));
+
// go up/down
bool up = act == LFUN_UP || act == LFUN_UP_SELECT;
bool successful = cur.upDownInMath(up);
if (cur.pos() == 0)
// May affect external cell:
cur.recordUndoInset();
- else
+ else if (!cur.inMacroMode())
cur.recordUndoSelection();
// if the inset can not be removed from within, delete it
if (!cur.backspace()) {
// if relevant. Think typing "\frac<space>".
if (cmd.argument()[0] == ' '
&& cur.inMacroMode() && cur.macroName() != "\\"
- && cur.macroModeClose()) {
+ && cur.macroModeClose() && cur.pos() > 0) {
MathAtom const atom = cur.prevAtom();
if (atom->asNestInset() && atom->isActive()) {
cur.posBackward();
break;
}
- case LFUN_SPACE_INSERT:
+ case LFUN_SPACE_INSERT: {
cur.recordUndoSelection();
- cur.insert(MathAtom(new InsetMathSpace));
+ string const name = cmd.getArg(0);
+ if (name == "normal")
+ cur.insert(MathAtom(new InsetMathSpace(" ", "")));
+ else if (name == "protected")
+ cur.insert(MathAtom(new InsetMathSpace("~", "")));
+ else if (name == "thin" || name == "med" || name == "thick")
+ cur.insert(MathAtom(new InsetMathSpace(name + "space", "")));
+ else if (name == "hfill*")
+ cur.insert(MathAtom(new InsetMathSpace("hspace*{\\fill}", "")));
+ else if (name == "quad" || name == "qquad" ||
+ name == "enspace" || name == "enskip" ||
+ name == "negthinspace" || name == "negmedspace" ||
+ name == "negthickspace" || name == "hfill")
+ cur.insert(MathAtom(new InsetMathSpace(name, "")));
+ else if (name == "hspace" || name == "hspace*") {
+ string const len = cmd.getArg(1);
+ if (len.empty() || !isValidLength(len)) {
+ lyxerr << "LyX function 'space-insert " << name << "' "
+ "needs a valid length argument." << endl;
+ break;
+ }
+ cur.insert(MathAtom(new InsetMathSpace(name, len)));
+ } else
+ cur.insert(MathAtom(new InsetMathSpace));
break;
+ }
case LFUN_MATH_SPACE:
cur.recordUndoSelection();
// we just need to be in math mode to enable that
case LFUN_MATH_SIZE:
case LFUN_MATH_SPACE:
- case LFUN_MATH_LIMITS:
case LFUN_MATH_EXTERN:
flag.setEnabled(true);
break;
break;
}
+ case LFUN_DIALOG_SHOW_NEW_INSET: {
+ docstring const & name = cmd.argument();
+ if (name == "space")
+ flag.setEnabled(false);
+ break;
+ }
+
+
case LFUN_MATH_DELIM:
case LFUN_MATH_BIGDELIM:
// Don't do this with multi-cell selections
flag.setEnabled(false);
break;
+ case LFUN_CAPTION_INSERT:
+ flag.setEnabled(false);
+ break;
+
+ case LFUN_SPACE_INSERT: {
+ docstring const & name = cmd.argument();
+ if (name == "visible")
+ flag.setEnabled(false);
+ break;
+ }
+
case LFUN_INSET_DISSOLVE:
flag.setEnabled(!asHullInset());
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);
//lyxerr << "starting with macro" << endl;
bool reduced = cap::reduceSelectionToOneCell(cur);
if (reduced || !cur.selection()) {
+ cur.recordUndoInset();
docstring const safe = cap::grabAndEraseSelection(cur);
- cur.insert(MathAtom(new InsetMathUnknown(from_ascii("\\"), safe, false)));
+ if (!cur.inRegexped())
+ cur.insert(MathAtom(new InsetMathUnknown(from_ascii("\\"), safe, false)));
+ else
+ cur.niceInsert(createInsetMath("backslash", buf));
}
return true;
}
}
// These should be treated differently when not in text mode:
- if (currentMode() != InsetMath::TEXT_MODE) {
+ if (cur.inRegexped()) {
+ switch (c) {
+ case '\\':
+ cur.niceInsert(createInsetMath("backslash", buf));
+ break;
+ case '^':
+ cur.niceInsert(createInsetMath("mathcircumflex", buf));
+ break;
+ case '{':
+ case '}':
+ case '#':
+ case '%':
+ case '_':
+ cur.niceInsert(createInsetMath(docstring(1, c), buf));
+ break;
+ case '~':
+ cur.niceInsert(createInsetMath("sim", buf));
+ break;
+ default:
+ cur.insert(c);
+ }
+ return true;
+ } else if (currentMode() != InsetMath::TEXT_MODE) {
if (c == '_') {
script(cur, false, save_selection);
return true;
}
sort(locals.begin(), locals.end());
- if (globals.size() > 0)
+ if (!globals.empty())
return;
// fill in global macros
globals.push_back(from_ascii("\\root"));
globals.push_back(from_ascii("\\tabular"));
globals.push_back(from_ascii("\\stackrel"));
+ globals.push_back(from_ascii("\\stackrelthree"));
globals.push_back(from_ascii("\\binom"));
globals.push_back(from_ascii("\\choose"));
globals.push_back(from_ascii("\\brace"));
globals.push_back(from_ascii("\\hphantom"));
globals.push_back(from_ascii("\\phantom"));
globals.push_back(from_ascii("\\vphantom"));
+ globals.push_back(from_ascii("\\cancel"));
+ globals.push_back(from_ascii("\\bcancel"));
+ globals.push_back(from_ascii("\\xcancel"));
+ globals.push_back(from_ascii("\\cancelto"));
+ globals.push_back(from_ascii("\\smash"));
+ globals.push_back(from_ascii("\\mathclap"));
+ globals.push_back(from_ascii("\\mathllap"));
+ globals.push_back(from_ascii("\\mathrlap"));
MathWordList const & words = mathedWordList();
MathWordList::const_iterator it2;
//lyxerr << "Globals completion commands: ";