3 * Purpose: Implementation of common parts of the LyX math insets
4 * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
5 * Created: January 1996
7 * Copyright: 1996-1998 Alejandro Aguilar Sierra
9 * Version: 0.4, Lyx project.
11 * You are free to use and modify this code under the terms of
12 * the GNU General Public Licence version 2 or later.
19 #include "support/LAssert.h"
23 #include "formulamacro.h"
25 #include "funcrequest.h"
26 #include "BufferView.h"
29 #include "LaTeXFeatures.h"
31 #include "math_support.h"
32 #include "math_metricsinfo.h"
33 #include "support/lstrings.h"
34 #include "frontends/LyXView.h"
35 #include "frontends/font_metrics.h"
36 #include "frontends/mouse_state.h"
38 #include "math_arrayinset.h"
39 #include "math_charinset.h"
40 #include "math_deliminset.h"
41 #include "math_cursor.h"
42 #include "math_factory.h"
43 #include "math_fontinset.h"
44 #include "math_hullinset.h"
45 #include "math_iterator.h"
46 #include "math_macrotable.h"
47 #include "math_parser.h"
49 #include "math_spaceinset.h"
50 #include "undo_funcs.h"
51 #include "textpainter.h"
52 #include "frontends/Dialogs.h"
54 #include "ref_inset.h"
62 MathCursor * mathcursor = 0;
73 bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
75 if (!bv->insertInset(new_inset)) {
79 new_inset->edit(bv, true);
88 InsetFormulaBase::InsetFormulaBase()
89 : font_(), xo_(0), yo_(0)
91 // This is needed as long the math parser is not re-entrant
93 //lyxerr << "sizeof MathInset: " << sizeof(MathInset) << "\n";
94 //lyxerr << "sizeof MathMetricsInfo: " << sizeof(MathMetricsInfo) << "\n";
95 //lyxerr << "sizeof MathCharInset: " << sizeof(MathCharInset) << "\n";
96 //lyxerr << "sizeof LyXFont: " << sizeof(LyXFont) << "\n";
100 // simply scrap this function if you want
101 void InsetFormulaBase::mutateToText()
104 // translate to latex
106 latex(NULL, os, false, false);
107 string str = os.str();
110 LyXText * lt = view_->getLyXText();
111 string::const_iterator cit = str.begin();
112 string::const_iterator end = str.end();
113 for (; cit != end; ++cit)
114 view_->owner()->getIntl()->getTransManager().TranslateAndInsert(*cit, lt);
117 //view_->owner()->dispatch(LFUN_ESCAPE);
122 void InsetFormulaBase::handleFont
123 (BufferView * bv, string const & arg, string const & font)
125 // this whole function is a hack and won't work for incremental font
127 bv->lockedInsetStoreUndo(Undo::EDIT);
128 if (mathcursor->par()->name() == font) {
129 mathcursor->handleFont(font);
130 bv->updateInset(this);
132 bool sel = mathcursor->selection();
134 bv->updateInset(this);
135 mathcursor->handleNest(createMathInset(font));
136 mathcursor->insert(arg);
138 bv->updateInset(this);
143 BufferView * InsetFormulaBase::view() const
145 return view_.lock().get();
149 void InsetFormulaBase::validate(LaTeXFeatures &) const
153 void InsetFormulaBase::metrics(BufferView * bv, LyXFont const & f) const
160 void InsetFormulaBase::metrics(BufferView * bv) const
163 view_ = bv->owner()->view();
165 mi.base.style = LM_ST_TEXT;
166 mi.base.font = font_;
167 mi.base.font.setColor(LColor::math);
172 string const InsetFormulaBase::editMessage() const
174 return _("Math editor mode");
178 void InsetFormulaBase::edit(BufferView * bv, int x, int y, mouse_button::state)
180 if (!bv->lockInset(this))
181 lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
182 releaseMathCursor(bv);
183 mathcursor = new MathCursor(this, true);
185 mathcursor->setPos(x + xo_, y + yo_);
186 // if that is removed, we won't get the magenta box when entering an
187 // inset for the first time
188 bv->updateInset(this);
192 void InsetFormulaBase::edit(BufferView * bv, bool front)
194 if (!bv->lockInset(this))
195 lyxerr << "Cannot lock math inset in edit call!\n";
196 releaseMathCursor(bv);
197 mathcursor = new MathCursor(this, front);
199 bv->updateInset(this);
203 void InsetFormulaBase::insetUnlock(BufferView * bv)
206 if (mathcursor->inMacroMode()) {
207 mathcursor->macroModeClose();
208 bv->updateInset(this);
210 releaseMathCursor(bv);
213 bv->updateInset(this);
217 void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
219 // calling metrics here destroys the cached xo,yo positions e.g. in
220 // MathParboxinset. And it would be too expensive anyway...
223 lyxerr << "getCursorPos - should not happen";
227 mathcursor->getPos(x, y);
228 x = mathcursor->targetX();
231 //lyxerr << "getCursorPos: " << x << ' ' << y << endl;
235 void InsetFormulaBase::toggleInsetCursor(BufferView * bv)
238 lyxerr[Debug::MATHED] << "toggleInsetCursor impossible" << endl;
241 //lyxerr << "toggleInsetCursor: " << isCursorVisible() << endl;
242 if (isCursorVisible())
249 void InsetFormulaBase::showInsetCursor(BufferView * bv, bool)
252 lyxerr << "showInsetCursor impossible" << endl;
255 if (isCursorVisible())
258 mathcursor->getPos(x, y);
259 math_font_max_dim(font_, asc, des);
260 bv->showLockedInsetCursor(x, y - yo_, asc, des);
261 setCursorVisible(true);
262 //lyxerr << "showInsetCursor: " << x << ' ' << y << endl;
266 void InsetFormulaBase::hideInsetCursor(BufferView * bv)
270 if (!isCursorVisible())
272 bv->hideLockedInsetCursor();
273 setCursorVisible(false);
274 //lyxerr << "hideInsetCursor: " << endl;
278 void InsetFormulaBase::fitInsetCursor(BufferView * bv) const
283 math_font_max_dim(font_, asc, des);
284 getCursorPos(bv, x, y);
286 //lyxerr << "fitInsetCursor: x: " << x << " y: " << y << " yo: " << yo_ << endl;
287 bv->fitLockedInsetCursor(x, y, asc, des);
291 void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
294 bv->updateInset(this);
298 vector<string> const InsetFormulaBase::getLabelList() const
300 return vector<string>();
304 dispatch_result InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
309 BufferView * bv = cmd.view();
312 bv->updateInset(this);
313 //lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
315 if (cmd.button() == mouse_button::button3) {
316 // try to dispatch to enclosed insets first
317 if (mathcursor->dispatch(cmd) == UNDISPATCHED) {
318 // launch math panel for right mouse button
319 lyxerr << "lfunMouseRelease: undispatched: " << cmd.button() << endl;
320 bv->owner()->getDialogs().showMathPanel();
325 if (cmd.button() == mouse_button::button2) {
326 mathcursor->selClear();
327 mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
328 mathcursor->insert(asArray(bv->getClipboard()));
329 bv->updateInset(this);
333 if (cmd.button() == mouse_button::button1) {
334 // try to dispatch to enclosed insets first
335 mathcursor->dispatch(cmd);
336 cmd.view()->stuffClipboard(mathcursor->grabSelection());
337 // try to set the cursor
339 //mathcursor = new MathCursor(this, x == 0);
341 //mathcursor->setPos(x + xo_, y + yo_);
349 dispatch_result InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
351 BufferView * bv = cmd.view();
352 //lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
354 if (!mathcursor || mathcursor->formula() != this) {
355 lyxerr[Debug::MATHED] << "re-create cursor" << endl;
356 releaseMathCursor(bv);
357 mathcursor = new MathCursor(this, cmd.x == 0);
359 mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
362 if (cmd.button() == mouse_button::button3) {
363 mathcursor->dispatch(cmd);
367 if (cmd.button() == mouse_button::button1) {
370 mathcursor->selClear();
371 mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
372 mathcursor->dispatch(cmd);
376 bv->updateInset(this);
381 dispatch_result InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
386 if (mathcursor->dispatch(FuncRequest(cmd)) != UNDISPATCHED)
389 // only select with button 1
390 if (cmd.button() != mouse_button::button1)
393 if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
399 if (!mathcursor->selection())
400 mathcursor->selStart();
402 BufferView * bv = cmd.view();
404 mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
406 bv->updateInset(this);
411 dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
413 //lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action
414 // << " arg: '" << cmd.argument
415 // << " x: '" << cmd.x
416 // << " y: '" << cmd.y
417 // << "' button: " << cmd.button() << endl;
419 // delete empty mathbox (LFUN_BACKSPACE and LFUN_DELETE)
420 bool remove_inset = false;
422 switch (cmd.action) {
423 case LFUN_MOUSE_PRESS:
424 //lyxerr << "Mouse single press\n";
425 return lfunMousePress(cmd);
426 case LFUN_MOUSE_MOTION:
427 //return lfunMouseMotion(cmd);
428 case LFUN_MOUSE_RELEASE:
429 //lyxerr << "Mouse single release\n";
430 return lfunMouseRelease(cmd);
431 case LFUN_MOUSE_DOUBLE:
432 //lyxerr << "Mouse double\n";
433 return localDispatch(FuncRequest(LFUN_WORDSEL));
441 BufferView * bv = cmd.view();
442 string argument = cmd.argument;
443 RESULT result = DISPATCHED;
445 bool was_macro = mathcursor->inMacroMode();
446 bool was_selection = mathcursor->selection();
450 mathcursor->normalize();
453 switch (cmd.action) {
455 case LFUN_MATH_MUTATE:
456 case LFUN_MATH_DISPLAY:
457 case LFUN_MATH_NUMBER:
458 case LFUN_MATH_NONUMBER:
461 case LFUN_DELETE_LINE_FORWARD:
462 case LFUN_INSERT_LABEL:
463 case LFUN_MATH_EXTERN:
464 case LFUN_TABULAR_FEATURE:
465 case LFUN_PASTESELECTION:
466 case LFUN_MATH_LIMITS:
467 bv->lockedInsetStoreUndo(Undo::EDIT);
468 mathcursor->dispatch(cmd);
469 bv->updateInset(this);
473 sel = true; // fall through...
475 result = mathcursor->right(sel) ? DISPATCHED : FINISHED_RIGHT;
476 //lyxerr << "calling scroll 20\n";
478 bv->updateInset(this);
479 // write something to the minibuffer
480 //bv->owner()->message(mathcursor->info());
484 sel = true; // fall through
486 result = mathcursor->left(sel) ? DISPATCHED : FINISHED;
487 bv->updateInset(this);
491 sel = true; // fall through
493 result = mathcursor->up(sel) ? DISPATCHED : FINISHED_UP;
494 bv->updateInset(this);
498 sel = true; // fall through
500 result = mathcursor->down(sel) ? DISPATCHED : FINISHED_DOWN;
501 bv->updateInset(this);
505 mathcursor->home(false);
506 mathcursor->end(true);
507 bv->updateInset(this);
510 case LFUN_UP_PARAGRAPHSEL:
511 case LFUN_UP_PARAGRAPH:
512 case LFUN_DOWN_PARAGRAPHSEL:
513 case LFUN_DOWN_PARAGRAPH:
515 bv->updateInset(this);
519 case LFUN_WORDLEFTSEL:
520 sel = true; // fall through
523 result = mathcursor->home(sel) ? DISPATCHED : FINISHED;
524 bv->updateInset(this);
528 case LFUN_WORDRIGHTSEL:
529 sel = true; // fall through
532 result = mathcursor->end(sel) ? DISPATCHED : FINISHED_RIGHT;
533 bv->updateInset(this);
538 case LFUN_BEGINNINGBUFSEL:
539 case LFUN_BEGINNINGBUF:
541 bv->updateInset(this);
548 result = FINISHED_RIGHT;
549 bv->updateInset(this);
553 mathcursor->idxNext();
554 bv->updateInset(this);
558 mathcursor->idxPrev();
559 bv->updateInset(this);
562 case LFUN_DELETE_WORD_BACKWARD:
564 bv->lockedInsetStoreUndo(Undo::EDIT);
565 if (mathcursor->backspace()) {
571 bv->updateInset(this);
574 case LFUN_DELETE_WORD_FORWARD:
576 bv->lockedInsetStoreUndo(Undo::EDIT);
577 if (mathcursor->erase()) {
583 bv->updateInset(this);
587 // sprintf(dispatch_buffer, "%d %d",);
588 // dispatch_result = dispatch_buffer;
591 lyxerr << "LFUN_SETXY broken!\n";
594 istringstream is(cmd.argument.c_str());
596 mathcursor->setPos(x, y);
597 bv->updateInset(this);
603 mathcursor->macroModeClose();
604 bv->lockedInsetStoreUndo(Undo::EDIT);
605 mathcursor->selPaste();
606 bv->updateInset(this);
610 bv->lockedInsetStoreUndo(Undo::DELETE);
611 mathcursor->selCut();
612 bv->updateInset(this);
616 mathcursor->selCopy();
620 // Special casing for superscript in case of LyX handling
622 case LFUN_CIRCUMFLEX:
623 if (cmd.argument.empty()) {
624 // do superscript if LyX handles
626 bv->lockedInsetStoreUndo(Undo::EDIT);
627 mathcursor->script(true);
628 bv->updateInset(this);
645 case LFUN_HUNG_UMLAUT:
649 //case LFUN_GREEK_TOGGLE: handleFont(bv, cmd.argument, "lyxgreek"); break;
650 case LFUN_BOLD: handleFont(bv, cmd.argument, "mathbf"); break;
651 case LFUN_SANS: handleFont(bv, cmd.argument, "mathsf"); break;
652 case LFUN_EMPH: handleFont(bv, cmd.argument, "mathcal"); break;
653 case LFUN_ROMAN: handleFont(bv, cmd.argument, "mathrm"); break;
654 case LFUN_CODE: handleFont(bv, cmd.argument, "texttt"); break;
655 case LFUN_FRAK: handleFont(bv, cmd.argument, "mathfrak"); break;
656 case LFUN_ITAL: handleFont(bv, cmd.argument, "mathit"); break;
657 case LFUN_NOUN: handleFont(bv, cmd.argument, "mathbb"); break;
658 case LFUN_FREEFONT_APPLY: handleFont(bv, cmd.argument, "textrm"); break;
659 case LFUN_DEFAULT: handleFont(bv, cmd.argument, "textnormal"); break;
662 // handleFont(bv, cmd.argument, "lyxgreek1");
663 // if (cmd.argument.size())
664 // mathcursor->insert(asArray(cmd.argument));
668 if (mathcursor->currentMode() == MathInset::TEXT_MODE) {
669 mathcursor->niceInsert(MathAtom(new MathHullInset("simple")));
670 bv->updateInset(this);
672 handleFont(bv, cmd.argument, "textrm");
674 //bv->owner()->message(_("math text mode toggled"));
680 bv->lockedInsetStoreUndo(Undo::EDIT);
681 mathcursor->setSize(arg);
682 bv->updateInset(this);
687 case LFUN_INSERT_MATRIX: {
688 bv->lockedInsetStoreUndo(Undo::EDIT);
693 istringstream is(STRCONV(argument));
694 is >> m >> n >> v_align >> h_align;
698 mathcursor->niceInsert(
699 MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
700 bv->updateInset(this);
704 case LFUN_SUPERSCRIPT:
707 bv->lockedInsetStoreUndo(Undo::EDIT);
708 mathcursor->script(cmd.action == LFUN_SUPERSCRIPT);
709 bv->updateInset(this);
713 case LFUN_MATH_DELIM:
715 //lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
717 string rs = split(cmd.argument, ls, ' ');
718 // Reasonable default values
724 bv->lockedInsetStoreUndo(Undo::EDIT);
725 mathcursor->handleNest(MathAtom(new MathDelimInset(ls, rs)));
726 bv->updateInset(this);
730 case LFUN_PROTECTEDSPACE:
731 case LFUN_MATH_SPACE:
732 bv->lockedInsetStoreUndo(Undo::EDIT);
733 mathcursor->insert(MathAtom(new MathSpaceInset(",")));
734 bv->updateInset(this);
738 bv->owner()->message(_("Invalid action in math mode!"));
742 case LFUN_EXEC_COMMAND:
743 result = UNDISPATCHED;
747 // interpret this as if a backslash was typed
748 bv->lockedInsetStoreUndo(Undo::EDIT);
749 mathcursor->interpret('\\');
750 bv->updateInset(this);
753 case LFUN_BREAKPARAGRAPH:
754 case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
755 case LFUN_BREAKPARAGRAPH_SKIP:
759 // FIXME: We probably should swap parts of "math-insert" and "self-insert"
760 // handling such that "self-insert" works on "arbitrary stuff" too, and
761 // math-insert only handles special math things like "matrix".
762 case LFUN_INSERT_MATH:
763 bv->lockedInsetStoreUndo(Undo::EDIT);
764 mathcursor->niceInsert(argument);
765 bv->updateInset(this);
769 case LFUN_SELFINSERT:
770 if (!argument.empty()) {
771 bv->lockedInsetStoreUndo(Undo::EDIT);
772 if (argument.size() == 1)
773 result = mathcursor->interpret(argument[0]) ? DISPATCHED : FINISHED_RIGHT;
775 mathcursor->insert(asArray(argument));
776 bv->updateInset(this);
780 case LFUN_MATH_PANEL:
781 result = UNDISPATCHED;
785 if (mathcursor->selection())
786 mathcursor->selClear();
788 result = UNDISPATCHED;
791 case LFUN_INSET_TOGGLE:
792 mathcursor->insetToggle();
793 bv->updateInset(this);
796 case LFUN_DIALOG_SHOW_NEW_INSET: {
797 string const & name = argument;
801 data = tmp.createDialogStr(name);
805 result = UNDISPATCHED;
807 bv->owner()->getDialogs().show(name, data, 0);
812 case LFUN_INSET_APPLY: {
813 string const name = cmd.getArg(0);
815 bv->owner()->getDialogs().getOpenInset(name);
818 FuncRequest fr(bv, LFUN_INSET_MODIFY, cmd.argument);
819 result = base->localDispatch(fr);
822 if (createMathInset_fromDialogStr(cmd.argument, ar)) {
823 mathcursor->insert(ar);
826 result = UNDISPATCHED;
829 if (result == DISPATCHED)
830 bv->updateInset(this);
835 result = UNDISPATCHED;
838 mathcursor->normalize();
841 lyx::Assert(mathcursor);
843 if (mathcursor->selection() || was_selection)
844 toggleInsetSelection(bv);
846 if (result == DISPATCHED || result == DISPATCHED_NOUPDATE ||
847 result == UNDISPATCHED) {
851 cmd.view()->stuffClipboard(mathcursor->grabSelection());
853 releaseMathCursor(bv);
854 bv->unlockInset(this);
856 bv->owner()->dispatch(FuncRequest(LFUN_DELETE));
859 return result; // original version
863 void InsetFormulaBase::revealCodes(BufferView * bv) const
867 bv->owner()->message(mathcursor->info());
870 // write something to the minibuffer
871 // translate to latex
872 mathcursor->markInsert();
875 string str = os.str();
876 mathcursor->markErase();
877 string::size_type pos = 0;
879 for (string::iterator it = str.begin(); it != str.end(); ++it) {
882 else if (*it == '\0') {
884 pos = it - str.begin();
890 res = res.substr(pos - 30);
892 res = res.substr(0, 60);
893 bv->owner()->message(res);
898 Inset::Code InsetFormulaBase::lyxCode() const
900 return Inset::MATH_CODE;
904 int InsetFormulaBase::ylow() const
906 return yo_ - ascent(view(), font_);
910 int InsetFormulaBase::yhigh() const
912 return yo_ + descent(view(), font_);
916 int InsetFormulaBase::xlow() const
922 int InsetFormulaBase::xhigh() const
924 return xo_ + width(view(), font_);
928 /////////////////////////////////////////////////////////////////////
931 bool InsetFormulaBase::searchForward(BufferView * bv, string const & str,
937 static InsetFormulaBase * lastformula = 0;
938 static MathIterator current = MathIterator(ibegin(par().nucleus()));
940 static string laststr;
942 if (lastformula != this || laststr != str) {
943 //lyxerr << "reset lastformula to " << this << "\n";
946 current = ibegin(par().nucleus());
948 mathed_parse_cell(ar, str);
952 //lyxerr << "searching '" << str << "' in " << this << ar << endl;
954 for (MathIterator it = current; it != iend(par().nucleus()); ++it) {
955 if (it.cell().matchpart(ar, it.back().pos_)) {
956 bv->unlockInset(bv->theLockingInset());
957 if (!bv->lockInset(this)) {
958 lyxerr << "Cannot lock inset" << endl;
962 mathcursor = new MathCursor(this, true);
964 mathcursor->setSelection(it, ar.size());
967 bv->updateInset(this);
972 //lyxerr << "not found!\n";
978 bool InsetFormulaBase::searchBackward(BufferView * bv, string const & what,
981 lyxerr[Debug::MATHED] << "searching backward not implemented in mathed\n";
982 return searchForward(bv, what, a, b);
986 bool InsetFormulaBase::display() const
988 return par()->asHullInset() && par()->asHullInset()->display();
992 string InsetFormulaBase::selectionAsString() const
994 return mathcursor ? mathcursor->grabSelection() : string();
997 /////////////////////////////////////////////////////////////////////
1000 void mathDispatchCreation(FuncRequest const & cmd, bool display)
1002 BufferView * bv = cmd.view();
1003 // use selection if available..
1005 //if (action == LFUN_MATH_IMPORT_SELECTION)
1009 string sel = bv->getLyXText()->selectionAsString(bv->buffer(), false);
1012 InsetFormula * f = new InsetFormula(bv);
1013 if (openNewInset(bv, f)) {
1014 bv->theLockingInset()->
1015 localDispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
1016 // don't do that also for LFUN_MATH_MODE unless you want end up with
1017 // always changing to mathrm when opening an inlined inset
1018 // -- I really hate "LyXfunc overloading"...
1020 f->localDispatch(FuncRequest(bv, LFUN_MATH_DISPLAY));
1021 f->localDispatch(FuncRequest(bv, LFUN_INSERT_MATH, cmd.argument));
1024 // create a macro if we see "\\newcommand" somewhere, and an ordinary
1025 // formula otherwise
1026 InsetFormulaBase * f;
1027 if (sel.find("\\newcommand") == string::npos &&
1028 sel.find("\\def") == string::npos)
1029 f = new InsetFormula(sel);
1031 f = new InsetFormulaMacro(sel);
1032 bv->getLyXText()->cutSelection(bv);
1033 openNewInset(bv, f);
1035 cmd.message(N_("Math editor mode"));
1039 void mathDispatch(FuncRequest const & cmd)
1041 BufferView * bv = cmd.view();
1042 if (!bv->available())
1045 switch (cmd.action) {
1047 case LFUN_MATH_DISPLAY:
1048 mathDispatchCreation(cmd, true);
1051 case LFUN_MATH_MODE:
1052 mathDispatchCreation(cmd, false);
1055 case LFUN_MATH_IMPORT_SELECTION:
1056 mathDispatchCreation(cmd, false);
1059 case LFUN_MATH_MACRO:
1060 if (cmd.argument.empty())
1061 cmd.errorMessage(N_("Missing argument"));
1063 string s = cmd.argument;
1064 string const s1 = token(s, ' ', 1);
1065 int const na = s1.empty() ? 0 : lyx::atoi(s1);
1066 openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na));
1071 case LFUN_INSERT_MATH:
1072 case LFUN_INSERT_MATRIX:
1073 case LFUN_MATH_DELIM: {
1074 InsetFormula * f = new InsetFormula(bv);
1075 if (openNewInset(bv, f)) {
1076 bv->theLockingInset()->
1077 localDispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
1078 bv->theLockingInset()->localDispatch(cmd);