3 * Purpose: Implementation of formula inset
4 * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
5 * Created: January 1996
6 * Description: Allows the edition of math paragraphs inside Lyx.
8 * Copyright: 1996-1998 Alejandro Aguilar Sierra
10 * Version: 0.4, Lyx project.
12 * You are free to use and modify this code under the terms of
13 * the GNU General Public Licence version 2 or later.
22 #pragma implementation
26 #include "formulamacro.h"
27 #include "commandtags.h"
28 #include "math_cursor.h"
29 #include "math_parser.h"
30 #include "BufferView.h"
34 #include "LaTeXFeatures.h"
36 #include "support/LOstream.h"
40 #include "math_arrayinset.h"
41 #include "math_spaceinset.h"
42 #include "support/lyxlib.h"
43 #include "mathed/support.h"
44 #include "undo_funcs.h"
50 extern char const * latex_special_chars;
52 int greek_kb_flag = 0;
53 extern char const * latex_mathenv[];
54 MathCursor * mathcursor = 0;
65 void mathed_init_fonts();
67 string nicelabel(string const & label)
69 return "(" + (label.empty() ? "#" : label) + ")";
72 void handleFont(BufferView * bv, MathTextCodes t)
74 if (mathcursor->Selection())
75 bv->lockedInsetStoreUndo(Undo::EDIT);
76 mathcursor->handleFont(t);
79 void handleAccent(BufferView * bv, string const & name, int code)
81 bv->lockedInsetStoreUndo(Undo::EDIT);
82 mathcursor->handleAccent(name, code);
85 void handleDelim(BufferView * bv, int l, int r)
87 bv->lockedInsetStoreUndo(Undo::EDIT);
88 mathcursor->handleDelim(l, r);
91 bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
93 LyXText * lt = bv->getLyXText();
97 if (!bv->insertInset(new_inset)) {
101 new_inset->edit(bv, 0, 0, 0);
113 // returns the nearest enclosing matrix
114 MathArrayInset * matrixpar(int & idx)
118 static_cast<MathArrayInset *>
119 (mathcursor ? mathcursor->enclosing(LM_OT_MATRIX, idx) : 0);
126 InsetFormulaBase::InsetFormulaBase(MathInset * par)
131 InsetFormulaBase::InsetFormulaBase(InsetFormulaBase const & f)
132 : UpdatableInset(f), par_(static_cast<MathInset *>(f.par_->clone()))
136 InsetFormulaBase::~InsetFormulaBase()
142 void InsetFormulaBase::read(Buffer const *, LyXLex & lex)
147 void InsetFormulaBase::write(Buffer const *, ostream & os) const
152 int InsetFormulaBase::latex(Buffer const *, ostream & os,
153 bool fragile, bool spacing) const
155 return latex(os, fragile, spacing);
158 int InsetFormulaBase::ascii(Buffer const *, ostream & os, int spacing) const
160 return ascii(os, spacing);
163 int InsetFormulaBase::linuxdoc(Buffer const *, ostream & os) const
168 int InsetFormulaBase::docBook(Buffer const *, ostream & os) const
175 // Check if uses AMS macros
176 void InsetFormulaBase::validate(LaTeXFeatures &) const
180 string const InsetFormulaBase::editMessage() const
182 return _("Math editor mode");
186 void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int)
188 mathcursor = new MathCursor(this);
190 if (!bv->lockInset(this))
191 lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
194 //bv->updateInset(this, false);
205 void InsetFormulaBase::edit(BufferView * bv, bool front)
207 #warning Please have a look if this is right (Jug)
208 edit(bv, front ? 0 : 1, 0, 0);
212 void InsetFormulaBase::insetUnlock(BufferView * bv)
215 if (mathcursor->InMacroMode()) {
216 mathcursor->MacroModeClose();
217 updateLocal(bv, true);
222 bv->updateInset(this, false);
226 void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
228 mathcursor->GetPos(x, y);
234 void InsetFormulaBase::toggleInsetCursor(BufferView * bv)
239 if (isCursorVisible())
240 bv->hideLockedInsetCursor();
244 mathcursor->GetPos(x, y);
249 math_font_max_dim(LM_TC_TEXTRM, LM_ST_TEXT, asc, desc);
250 bv->showLockedInsetCursor(x, y, asc, desc);
253 toggleCursorVisible();
257 void InsetFormulaBase::showInsetCursor(BufferView * bv, bool)
259 if (!isCursorVisible()) {
263 mathcursor->GetPos(x, y);
268 math_font_max_dim(LM_TC_TEXTRM, LM_ST_TEXT, asc, desc);
269 bv->fitLockedInsetCursor(x, y, asc, desc);
271 toggleInsetCursor(bv);
276 void InsetFormulaBase::hideInsetCursor(BufferView * bv)
278 if (isCursorVisible())
279 toggleInsetCursor(bv);
283 void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
286 bv->updateInset(this, false);
290 vector<string> const InsetFormulaBase::getLabelList() const
292 return std::vector<string>();
296 void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
299 bv->updateInset(this, dirty);
303 void InsetFormulaBase::metrics() const
305 const_cast<MathInset *>(par_)->metrics(LM_ST_TEXT);
309 void InsetFormulaBase::insetButtonRelease(BufferView * bv,
310 int x, int y, int /*button*/)
316 mathcursor->SetPos(x, y);
323 bv->updateInset(this, false);
328 void InsetFormulaBase::insetButtonPress(BufferView * bv,
329 int x, int y, int /*button*/)
334 if (mathcursor && mathcursor->Selection()) {
335 mathcursor->SelClear();
336 bv->updateInset(this, false);
341 void InsetFormulaBase::insetMotionNotify(BufferView * bv,
342 int x, int y, int /*button*/)
344 if (sel_x && sel_y && abs(x-sel_x) > 4 && !sel_flag) {
347 mathcursor->SetPos(sel_x + par_->xo(), sel_y + par_->yo());
348 mathcursor->SelStart();
350 mathcursor->GetPos(sel_x, sel_y);
351 } else if (sel_flag) {
355 mathcursor->SetPos(x, y);
357 mathcursor->GetPos(x, y);
358 if (sel_x != x || sel_y != y)
359 bv->updateInset(this, false);
366 void InsetFormulaBase::insetKeyPress(XKeyEvent *)
368 lyxerr[Debug::MATHED]
369 << "Used InsetFormulaBase::InsetKeyPress." << endl;
374 UpdatableInset::RESULT
375 InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
378 //lyxerr << "InsetFormulaBase::LocalDispatch: act: " << action
379 // << " arg: '" << arg << "' cursor: " << mathcursor << "\n";
384 MathTextCodes varcode = LM_TC_MIN;
385 bool was_macro = mathcursor->InMacroMode();
387 bool was_selection = mathcursor->Selection();
388 RESULT result = DISPATCHED;
392 if (mathcursor->getLastCode() == LM_TC_TEX)
395 mathcursor->normalize();
399 // --- Cursor Movements ---------------------------------------------
402 sel = true; // fall through...
405 result = DISPATCH_RESULT(mathcursor->Right(sel));
406 updateLocal(bv, false);
411 sel = true; // fall through
414 result = DISPATCH_RESULT(mathcursor->Left(sel));
415 updateLocal(bv, false);
423 result = DISPATCH_RESULT(mathcursor->Up(sel));
424 updateLocal(bv, false);
432 result = DISPATCH_RESULT(mathcursor->Down(sel));
433 updateLocal(bv, false);
438 updateLocal(bv, false);
443 updateLocal(bv, false);
446 case LFUN_DELETE_LINE_FORWARD:
447 bv->lockedInsetStoreUndo(Undo::DELETE);
448 mathcursor->DelLine();
449 updateLocal(bv, true);
453 mathcursor->idxNext();
454 updateLocal(bv, false);
458 mathcursor->idxPrev();
459 updateLocal(bv, false);
463 bv->lockedInsetStoreUndo(Undo::EDIT);
464 mathcursor->splitCell();
465 updateLocal(bv, true);
469 // if (!mathcursor->InMacroMode() && mathcursor->pos() == 0)
470 if (mathcursor->pos() == 0) {
471 bv->lockedInsetStoreUndo(Undo::DELETE);
472 mathcursor->pullArg(false);
473 bv->updateInset(this, true);
476 if (mathcursor->InMacroMode())
479 mathcursor->plainLeft();
483 bv->lockedInsetStoreUndo(Undo::DELETE);
484 if (mathcursor->pos() == mathcursor->array().size())
485 mathcursor->pullArg(true);
487 mathcursor->Delete();
488 bv->updateInset(this, true);
492 // sprintf(dispatch_buffer, "%d %d",);
493 // dispatch_result = dispatch_buffer;
497 lyxerr << "LFUN_SETXY broken!\n";
502 istringstream is(arg.c_str());
505 mathcursor->SetPos(x1 + x, y1 + y);
506 updateLocal(bv, false);
513 mathcursor->MacroModeClose();
514 bv->lockedInsetStoreUndo(Undo::INSERT);
515 mathcursor->SelPaste();
516 updateLocal(bv, true);
520 bv->lockedInsetStoreUndo(Undo::DELETE);
521 mathcursor->SelCut();
522 updateLocal(bv, true);
526 mathcursor->SelCopy();
531 case LFUN_WORDRIGHTSEL:
532 case LFUN_WORDLEFTSEL:
535 // --- accented characters ------------------------------
537 case LFUN_UMLAUT: handleAccent(bv, "ddot", LM_ddot); break;
538 case LFUN_CIRCUMFLEX: handleAccent(bv, "hat", LM_hat); break;
539 case LFUN_GRAVE: handleAccent(bv, "grave", LM_grave); break;
540 case LFUN_ACUTE: handleAccent(bv, "acute", LM_acute); break;
541 case LFUN_TILDE: handleAccent(bv, "tilde", LM_tilde); break;
542 case LFUN_MACRON: handleAccent(bv, "bar", LM_bar); break;
543 case LFUN_DOT: handleAccent(bv, "dot", LM_dot); break;
544 case LFUN_CARON: handleAccent(bv, "check", LM_check); break;
545 case LFUN_BREVE: handleAccent(bv, "breve", LM_breve); break;
546 case LFUN_VECTOR: handleAccent(bv, "vec", LM_vec); break;
550 if (!greek_kb_flag) {
552 bv->owner()->message(_("Math greek mode on"));
558 case LFUN_GREEK_TOGGLE:
559 greek_kb_flag = greek_kb_flag ? 0 : 2;
561 bv->owner()->message(_("Math greek keyboard on"));
563 bv->owner()->message(_("Math greek keyboard off"));
567 case LFUN_BOLD: handleFont(bv, LM_TC_BF); break;
568 case LFUN_SANS: handleFont(bv, LM_TC_SF); break;
569 case LFUN_EMPH: handleFont(bv, LM_TC_CAL); break;
570 case LFUN_ROMAN: handleFont(bv, LM_TC_RM); break;
571 case LFUN_CODE: handleFont(bv, LM_TC_TT); break;
572 case LFUN_DEFAULT: handleFont(bv, LM_TC_VAR); break;
575 handleFont(bv, LM_TC_TEXTRM);
576 //bv->owner()->message(_("math text mode toggled"));
581 if (!mathcursor->Selection()) {
582 mathcursor->handleFont(LM_TC_TEX);
583 //bv->owner()->message(_("TeX mode toggled"));
588 case LFUN_MATH_LIMITS:
589 bv->lockedInsetStoreUndo(Undo::INSERT);
590 if (mathcursor->toggleLimits())
591 updateLocal(bv, true);
596 bv->lockedInsetStoreUndo(Undo::INSERT);
597 latexkeys const * l = in_word_set(arg);
598 mathcursor->SetSize(MathStyles(l ? l->id : static_cast<unsigned int>(-1)));
599 updateLocal(bv, true);
603 case LFUN_INSERT_MATRIX:
605 bv->lockedInsetStoreUndo(Undo::INSERT);
606 mathcursor->Interpret("matrix " + arg);
607 updateLocal(bv, true);
611 case LFUN_INSERT_MATH:
613 bv->lockedInsetStoreUndo(Undo::INSERT);
614 mathcursor->Interpret(arg);
615 updateLocal(bv, true);
619 case LFUN_MATH_SPACE:
621 bv->lockedInsetStoreUndo(Undo::EDIT);
622 MathSpaceInset * p = mathcursor->prevSpaceInset();
626 mathcursor->insert(new MathSpaceInset(1));
627 updateLocal(bv, true);
631 case LFUN_MATH_DELIM:
633 bv->lockedInsetStoreUndo(Undo::INSERT);
634 static const string vdelim("(){}[]./|");
635 //lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
640 // try to read integers first
643 istringstream is(arg.c_str());
646 if (!is) { // ok, the beasties are no integers... try something else
650 istringstream is(arg.c_str());
654 //lyxerr << "formulabase::LFUN_MATH_DELIM, lt: '" << lt << "'\n";
655 //lyxerr << "formulabase::LFUN_MATH_DELIM, rt: '" << rt << "'\n";
658 latexkeys const * l = in_word_set(lt);
661 } else if (vdelim.find(lt[0]) != string::npos)
665 latexkeys const * l = in_word_set(rt);
668 } else if (vdelim.find(rt[0]) != string::npos)
672 handleDelim(bv, ilt, irt);
673 updateLocal(bv, true);
677 case LFUN_PROTECTEDSPACE:
678 //lyxerr << " called LFUN_PROTECTEDSPACE\n";
679 bv->lockedInsetStoreUndo(Undo::INSERT);
680 mathcursor->insert(new MathSpaceInset(1));
681 updateLocal(bv, true);
685 bv->owner()->message(_("Invalid action in math mode!"));
689 case LFUN_MATH_HALIGN:
691 bv->lockedInsetStoreUndo(Undo::INSERT);
692 lyxerr << "handling halign '" << arg << "'\n";
694 MathArrayInset * p = matrixpar(idx);
697 p->halign(arg.size() ? arg[0] : 'c', p->col(idx));
698 updateLocal(bv, true);
702 case LFUN_MATH_VALIGN:
704 bv->lockedInsetStoreUndo(Undo::INSERT);
705 lyxerr << "handling valign '" << arg << "'\n";
707 MathArrayInset * p = matrixpar(idx);
710 p->valign(arg.size() ? arg[0] : 'c');
711 updateLocal(bv, true);
715 case LFUN_MATH_ROW_INSERT:
717 bv->lockedInsetStoreUndo(Undo::INSERT);
719 MathArrayInset * p = matrixpar(idx);
720 lyxerr << " calling LFUN_MATH_ROW_INSERT on " << p << endl;
723 p->addRow(p->row(idx));
724 updateLocal(bv, true);
728 case LFUN_MATH_ROW_DELETE:
730 bv->lockedInsetStoreUndo(Undo::INSERT);
732 MathArrayInset * p = matrixpar(idx);
733 lyxerr << " calling LFUN_MATH_ROW_DELETE on " << p << endl;
736 p->delRow(p->row(idx));
737 updateLocal(bv, true);
741 case LFUN_MATH_COLUMN_INSERT:
743 bv->lockedInsetStoreUndo(Undo::INSERT);
745 MathArrayInset * p = matrixpar(idx);
748 p->addCol(p->col(idx));
749 updateLocal(bv, true);
753 case LFUN_MATH_COLUMN_DELETE:
755 bv->lockedInsetStoreUndo(Undo::INSERT);
757 MathArrayInset * p = matrixpar(idx);
760 p->delCol(p->col(idx));
761 updateLocal(bv, true);
765 case LFUN_EXEC_COMMAND:
766 result = UNDISPATCHED;
770 if ((action == -1 || action == LFUN_SELFINSERT) && !arg.empty()) {
771 unsigned char c = arg[0];
773 lyxerr << "Action: " << action << endl;
775 lyxerr << "char: '" << c << "' int: " << int(c) << endl;
776 //owner_->getIntl()->getTrans().TranslateAndInsert(c, lt);
777 //lyxerr << "trans: '" << c << "' int: " << int(c) << endl;
778 bv->lockedInsetStoreUndo(Undo::INSERT);
780 if (c == 0) { // Dead key, do nothing
781 //lyxerr << "deadkey" << endl;
786 if (mathcursor->getLastCode() == LM_TC_TEX) {
787 mathcursor->MacroModeOpen();
788 mathcursor->clearLastCode();
790 } else if (!varcode) {
791 MathTextCodes f = mathcursor->getLastCode() ?
792 mathcursor->getLastCode() :
793 mathcursor->nextCode();
794 varcode = MathIsAlphaFont(f) ?
795 static_cast<MathTextCodes>(f) :
799 // lyxerr << "Varcode << vardoce;
800 MathTextCodes char_code = varcode;
803 {'A', 'B', 'X', 0 , 'E', 0 , 0 , 'H', 'I', 0 ,
804 'K', 0 , 'M', 'N', 'O', 0 , 0 , 'P', 0 , 'T',
805 'Y', 0, 0, 0, 0 , 'Z' };
807 if ('A' <= c && c <= 'Z' && greek[c - 'A']) {
808 char_code = LM_TC_RM;
811 char_code = LM_TC_SYMB;
814 mathcursor->insert(c, char_code);
816 if (greek_kb_flag && char_code == LM_TC_RM )
817 mathcursor->setLastCode(LM_TC_VAR);
821 if (greek_kb_flag < 2)
824 } else if (strchr("!,:;{}", c) && (varcode == LM_TC_TEX||was_macro)) {
825 mathcursor->insert(c, LM_TC_TEX);
827 mathcursor->insert('}', LM_TC_TEX);
830 mathcursor->clearLastCode();
831 // varcode = LM_TC_MIN;
832 } else if (c == '_' && varcode == LM_TC_TEX) {
833 mathcursor->insert(c, LM_TC_SPECIAL);
834 mathcursor->clearLastCode();
835 // varcode = LM_TC_MIN;
836 } else if ('0' <= c && c <= '9' && (varcode == LM_TC_TEX||was_macro)) {
837 mathcursor->MacroModeOpen();
838 mathcursor->clearLastCode();
839 mathcursor->insert(c, LM_TC_MIN);
840 } else if (('0' <= c && c <= '9') || strchr(";:!|[]().,?", c)) {
841 MathTextCodes code = mathcursor->getLastCode();
842 if (code != LM_TC_TEXTRM)
844 mathcursor->insert(c, code);
845 } else if (strchr("+/-*<>=", c)) {
846 MathTextCodes code = mathcursor->getLastCode();
847 if (code != LM_TC_TEXTRM)
849 mathcursor->insert(c, code);
850 } else if (strchr(latex_special_chars, c) && c != '_') {
851 MathTextCodes code = mathcursor->getLastCode();
852 if (code != LM_TC_TEXTRM)
853 code = LM_TC_SPECIAL;
854 mathcursor->insert(c, code);
855 } else if (c == '_' || c == '^') {
859 mathcursor->Interpret(s);
860 } else if (c == ' ') {
862 MathTextCodes f = (mathcursor->getLastCode()) ?
863 mathcursor->getLastCode() :
864 mathcursor->nextCode();
865 varcode = MathIsAlphaFont(f) ? f : LM_TC_VAR;
868 if (varcode == LM_TC_TEXTRM)
869 mathcursor->insert(c, LM_TC_TEXTRM);
871 mathcursor->MacroModeClose();
872 else if (mathcursor->pop())
873 mathcursor->plainRight();
875 // this would not work if the inset is in an table!
876 //bv->text->cursorRight(bv, true);
879 } else if (c == '\'' || c == '@') {
880 mathcursor->insert(c, LM_TC_VAR);
881 } else if (c == '\\') {
883 mathcursor->MacroModeClose();
884 bv->owner()->message(_("TeX mode"));
885 mathcursor->setLastCode(LM_TC_TEX);
887 updateLocal(bv, true);
888 } else if (action == LFUN_MATH_PANEL) {
889 result = UNDISPATCHED;
891 lyxerr << "Closed by action " << action << endl;
896 mathcursor->normalize();
898 if (was_macro != mathcursor->InMacroMode()
899 && action >= 0 && action != LFUN_BACKSPACE)
900 updateLocal(bv, true);
902 if (mathcursor->Selection() || was_selection)
903 toggleInsetSelection(bv);
905 if (result == DISPATCHED || result == DISPATCHED_NOUPDATE ||
906 result == UNDISPATCHED)
909 bv->unlockInset(this);
911 return result; // original version
916 /* FIXME: math-greek-toggle seems to work OK, but math-greek doesn't turn
918 bool math_insert_greek(BufferView * bv, char c)
920 if (!bv->available())
928 if (!bv->theLockingInset() || bv->theLockingInset()->isTextInset()) {
929 int greek_kb_flag_save = greek_kb_flag;
930 InsetFormula * new_inset = new InsetFormula();
931 bv->beforeChange(bv->text);
932 if (!bv->insertInset(new_inset)) {
937 new_inset->edit(bv, 0, 0, 0);
938 new_inset->localDispatch(bv, LFUN_SELFINSERT, tmp);
939 if (greek_kb_flag_save < 2) {
940 bv->unlockInset(new_inset); // bv->theLockingInset());
941 bv->text->cursorRight(bv, true);
944 if (bv->theLockingInset()->lyxCode() == Inset::MATH_CODE ||
945 bv->theLockingInset()->lyxCode() == Inset::MATHMACRO_CODE)
946 static_cast<InsetFormula*>(bv->theLockingInset())->localDispatch(bv, LFUN_SELFINSERT, tmp);
948 lyxerr << "Math error: attempt to write on a wrong "
949 "class of inset." << endl;
955 Inset::Code InsetFormulaBase::lyxCode() const
957 return Inset::MATH_CODE;
961 LyXFont const InsetFormulaBase::convertFont(LyXFont const & f) const
963 // We have already discussed what was here
966 font.setLatex(LyXFont::OFF);
971 MathInset * InsetFormulaBase::par() const
977 void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
979 if (bv->available()) {
980 // Feature "Read math inset from selection" disabled.
981 // // use selection if available..
983 // if (action == LFUN_MATH_IMPORT_SELECTION)
986 // sel = bv->getLyXText()->selectionAsString(bv->buffer());
989 // if (sel.empty()) {
990 f = new InsetFormula;
991 if (openNewInset(bv, f)) {
992 // don't do that also for LFUN_MATH_MODE unless you want end up with
993 // always changing to mathrm when opening an inlined inset
994 // -- I really hate "LyXfunc overloading"...
996 f->localDispatch(bv, LFUN_MATH_DISPLAY, string());
997 f->localDispatch(bv, LFUN_INSERT_MATH, arg);
1000 // f = new InsetFormula(sel);
1001 // bv->getLyXText()->cutSelection(bv);
1002 // openNewInset(bv, f);
1005 bv->owner()->getLyXFunc()->setMessage(N_("Math editor mode"));
1008 void mathDispatchMathDisplay(BufferView * bv, string const & arg)
1010 mathDispatchCreation(bv, arg, true);
1013 void mathDispatchMathMode(BufferView * bv, string const & arg)
1015 mathDispatchCreation(bv, arg, false);
1018 void mathDispatchMathImportSelection(BufferView * bv, string const & arg)
1020 mathDispatchCreation(bv, arg, true);
1023 void mathDispatchMathMacro(BufferView * bv, string const & arg)
1025 if (bv->available()) {
1027 bv->owner()->getLyXFunc()->setErrorMessage(N_("Missing argument"));
1030 string const s1 = token(s, ' ', 1);
1031 int const na = s1.empty() ? 0 : lyx::atoi(s1);
1032 openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na));
1037 void mathDispatchMathDelim(BufferView * bv, string const & arg)
1039 if (bv->available()) {
1040 if (openNewInset(bv, new InsetFormula))
1041 bv->theLockingInset()->localDispatch(bv, LFUN_MATH_DELIM, arg);
1046 void mathDispatchInsertMatrix(BufferView * bv, string const & arg)
1048 if (bv->available()) {
1049 if (openNewInset(bv, new InsetFormula))
1050 bv->theLockingInset()->localDispatch(bv, LFUN_INSERT_MATRIX, arg);
1054 void mathDispatchInsertMath(BufferView * bv, string const & arg)
1056 if (bv->available()) {
1057 if (arg.size() && arg[0] == '\\')
1058 openNewInset(bv, new InsetFormula(arg));
1060 mathDispatchMathMode(bv, arg);