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 LyXFont * Math_Fonts = 0;
55 MathCursor * mathcursor = 0;
66 void mathed_init_fonts();
68 string nicelabel(string const & label)
70 return "(" + (label.empty() ? "#" : label) + ")";
73 void handleFont(BufferView * bv, MathTextCodes t)
75 if (mathcursor->Selection())
76 bv->lockedInsetStoreUndo(Undo::EDIT);
77 mathcursor->handleFont(t);
80 void handleAccent(BufferView * bv, string const & name, int code)
82 bv->lockedInsetStoreUndo(Undo::EDIT);
83 mathcursor->handleAccent(name, code);
86 void handleDelim(BufferView * bv, int l, int r)
88 bv->lockedInsetStoreUndo(Undo::EDIT);
89 mathcursor->handleDelim(l, r);
92 bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
94 LyXText * lt = bv->getLyXText();
98 if (!bv->insertInset(new_inset)) {
102 new_inset->edit(bv, 0, 0, 0);
111 LyXFont WhichFont(short type, int size)
148 case LM_TC_SPECIAL: //f = Math_Fonts[0]; break;
162 if (type == LM_TC_BSYM) {
175 case LM_ST_SCRIPTSCRIPT:
181 lyxerr << "Math Error: wrong font size: " << size << endl;
185 if (type != LM_TC_TEXTRM)
186 f.setColor(LColor::math);
188 if (type == LM_TC_TEX)
189 f.setColor(LColor::latex);
197 void mathed_init_fonts()
199 Math_Fonts = new LyXFont[8]; //DEC cxx cannot initialize all fonts
202 for (int i = 0 ; i < 8 ; ++i) {
203 Math_Fonts[i] = LyXFont(LyXFont::ALL_SANE);
206 Math_Fonts[0].setShape(LyXFont::ITALIC_SHAPE);
208 Math_Fonts[1].setFamily(LyXFont::SYMBOL_FAMILY);
210 Math_Fonts[2].setFamily(LyXFont::SYMBOL_FAMILY);
211 Math_Fonts[2].setShape(LyXFont::ITALIC_SHAPE);
213 Math_Fonts[3].setSeries(LyXFont::BOLD_SERIES);
215 Math_Fonts[4].setFamily(LyXFont::SANS_FAMILY);
216 Math_Fonts[4].setShape(LyXFont::ITALIC_SHAPE);
218 Math_Fonts[5].setFamily(LyXFont::TYPEWRITER_FAMILY);
220 Math_Fonts[6].setFamily(LyXFont::ROMAN_FAMILY);
222 Math_Fonts[7].setFamily(LyXFont::SANS_FAMILY);
226 // returns the nearest enclosing matrix
227 MathArrayInset * matrixpar(int & idx)
231 static_cast<MathArrayInset *>
232 (mathcursor ? mathcursor->enclosing(LM_OT_MATRIX, idx) : 0);
239 InsetFormulaBase::InsetFormulaBase(MathInset * par)
244 InsetFormulaBase::InsetFormulaBase(InsetFormulaBase const & f)
245 : UpdatableInset(f), par_(static_cast<MathInset *>(f.par_->clone()))
249 InsetFormulaBase::~InsetFormulaBase()
252 #warning leak this for a while...
258 void InsetFormulaBase::read(Buffer const *, LyXLex & lex)
263 void InsetFormulaBase::write(Buffer const *, ostream & os) const
268 int InsetFormulaBase::latex(Buffer const *, ostream & os,
269 bool fragile, bool spacing) const
271 return latex(os, fragile, spacing);
274 int InsetFormulaBase::ascii(Buffer const *, ostream & os, int spacing) const
276 return ascii(os, spacing);
279 int InsetFormulaBase::linuxdoc(Buffer const *, ostream & os) const
284 int InsetFormulaBase::docBook(Buffer const *, ostream & os) const
291 // Check if uses AMS macros
292 void InsetFormulaBase::validate(LaTeXFeatures &) const
296 string const InsetFormulaBase::editMessage() const
298 return _("Math editor mode");
302 void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int)
304 mathcursor = new MathCursor(this);
306 if (!bv->lockInset(this))
307 lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
310 //bv->updateInset(this, false);
321 void InsetFormulaBase::insetUnlock(BufferView * bv)
324 if (mathcursor->InMacroMode()) {
325 mathcursor->MacroModeClose();
331 bv->updateInset(this, false);
335 void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
337 mathcursor->GetPos(x, y);
343 void InsetFormulaBase::toggleInsetCursor(BufferView * bv)
348 if (isCursorVisible())
349 bv->hideLockedInsetCursor();
353 mathcursor->GetPos(x, y);
357 LyXFont font = WhichFont(LM_TC_TEXTRM, LM_ST_TEXT);
358 int const asc = lyxfont::maxAscent(font);
359 int const desc = lyxfont::maxDescent(font);
361 bv->showLockedInsetCursor(x, y, asc, desc);
364 toggleCursorVisible();
368 void InsetFormulaBase::showInsetCursor(BufferView * bv, bool)
370 if (!isCursorVisible()) {
374 mathcursor->GetPos(x, y);
377 LyXFont font = WhichFont(LM_TC_TEXTRM, LM_ST_TEXT);
378 int const asc = lyxfont::maxAscent(font);
379 int const desc = lyxfont::maxDescent(font);
380 bv->fitLockedInsetCursor(x, y, asc, desc);
382 toggleInsetCursor(bv);
387 void InsetFormulaBase::hideInsetCursor(BufferView * bv)
389 if (isCursorVisible())
390 toggleInsetCursor(bv);
394 void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
399 bv->updateInset(this, false);
403 vector<string> const InsetFormulaBase::getLabelList() const
405 return std::vector<string>();
409 void InsetFormulaBase::updateLocal(BufferView * bv)
412 bv->updateInset(this, true);
416 void InsetFormulaBase::Metrics() const
418 const_cast<MathInset *>(par_)->Metrics(LM_ST_TEXT);
422 void InsetFormulaBase::insetButtonRelease(BufferView * bv,
423 int x, int y, int /*button*/)
429 mathcursor->SetPos(x, y);
436 bv->updateInset(this, false);
441 void InsetFormulaBase::insetButtonPress(BufferView * bv,
442 int x, int y, int /*button*/)
447 if (mathcursor && mathcursor->Selection()) {
448 mathcursor->SelClear();
449 bv->updateInset(this, false);
454 void InsetFormulaBase::insetMotionNotify(BufferView * bv,
455 int x, int y, int /*button*/)
457 if (sel_x && sel_y && abs(x-sel_x) > 4 && !sel_flag) {
460 mathcursor->SetPos(sel_x + par_->xo(), sel_y + par_->yo());
461 mathcursor->SelStart();
463 mathcursor->GetPos(sel_x, sel_y);
464 } else if (sel_flag) {
468 mathcursor->SetPos(x, y);
470 mathcursor->GetPos(x, y);
471 if (sel_x != x || sel_y != y)
472 bv->updateInset(this, false);
479 void InsetFormulaBase::insetKeyPress(XKeyEvent *)
481 lyxerr[Debug::MATHED]
482 << "Used InsetFormulaBase::InsetKeyPress." << endl;
487 UpdatableInset::RESULT
488 InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
491 //lyxerr << "InsetFormulaBase::LocalDispatch: act: " << action
492 // << " arg: '" << arg << "' cursor: " << mathcursor << "\n";
497 MathTextCodes varcode = LM_TC_MIN;
498 bool was_macro = mathcursor->InMacroMode();
500 bool was_selection = mathcursor->Selection();
501 RESULT result = DISPATCHED;
505 if (mathcursor->getLastCode() == LM_TC_TEX)
508 mathcursor->normalize();
512 // --- Cursor Movements ---------------------------------------------
515 sel = true; // fall through...
518 result = DISPATCH_RESULT(mathcursor->Right(sel));
524 sel = true; // fall through
527 result = DISPATCH_RESULT(mathcursor->Left(sel));
536 result = DISPATCH_RESULT(mathcursor->Up(sel));
545 result = DISPATCH_RESULT(mathcursor->Down(sel));
559 case LFUN_DELETE_LINE_FORWARD:
560 bv->lockedInsetStoreUndo(Undo::DELETE);
561 mathcursor->DelLine();
566 mathcursor->idxNext();
571 mathcursor->idxPrev();
576 bv->lockedInsetStoreUndo(Undo::EDIT);
577 mathcursor->splitCell();
582 // if (!mathcursor->InMacroMode() && mathcursor->pos() == 0)
583 if (mathcursor->pos() == 0) {
584 bv->lockedInsetStoreUndo(Undo::DELETE);
585 mathcursor->pullArg();
586 bv->updateInset(this, true);
589 if (mathcursor->InMacroMode())
592 mathcursor->plainLeft();
596 bv->lockedInsetStoreUndo(Undo::DELETE);
597 mathcursor->Delete();
598 bv->updateInset(this, true);
602 // sprintf(dispatch_buffer, "%d %d",);
603 // dispatch_result = dispatch_buffer;
607 lyxerr << "LFUN_SETXY broken!\n";
612 istringstream is(arg.c_str());
615 mathcursor->SetPos(x1 + x, y1 + y);
620 // cursor selection ----------------------------
624 mathcursor->MacroModeClose();
625 bv->lockedInsetStoreUndo(Undo::INSERT);
626 mathcursor->SelPaste();
631 bv->lockedInsetStoreUndo(Undo::DELETE);
632 mathcursor->SelCut();
637 mathcursor->SelCopy();
642 case LFUN_WORDRIGHTSEL:
643 case LFUN_WORDLEFTSEL:
646 // --- accented characters ------------------------------
648 case LFUN_UMLAUT: handleAccent(bv, "ddot", LM_ddot); break;
649 case LFUN_CIRCUMFLEX: handleAccent(bv, "hat", LM_hat); break;
650 case LFUN_GRAVE: handleAccent(bv, "grave", LM_grave); break;
651 case LFUN_ACUTE: handleAccent(bv, "acute", LM_acute); break;
652 case LFUN_TILDE: handleAccent(bv, "tilde", LM_tilde); break;
653 case LFUN_MACRON: handleAccent(bv, "bar", LM_bar); break;
654 case LFUN_DOT: handleAccent(bv, "dot", LM_dot); break;
655 case LFUN_CARON: handleAccent(bv, "check", LM_check); break;
656 case LFUN_BREVE: handleAccent(bv, "breve", LM_breve); break;
657 case LFUN_VECTOR: handleAccent(bv, "vec", LM_vec); break;
661 if (!greek_kb_flag) {
663 bv->owner()->message(_("Math greek mode on"));
669 case LFUN_GREEK_TOGGLE:
670 greek_kb_flag = greek_kb_flag ? 0 : 2;
672 bv->owner()->message(_("Math greek keyboard on"));
674 bv->owner()->message(_("Math greek keyboard off"));
678 case LFUN_BOLD: handleFont(bv, LM_TC_BF); break;
679 case LFUN_SANS: handleFont(bv, LM_TC_SF); break;
680 case LFUN_EMPH: handleFont(bv, LM_TC_CAL); break;
681 case LFUN_ROMAN: handleFont(bv, LM_TC_RM); break;
682 case LFUN_CODE: handleFont(bv, LM_TC_TT); break;
683 case LFUN_DEFAULT: handleFont(bv, LM_TC_VAR); break;
686 handleFont(bv, LM_TC_TEXTRM);
687 //bv->owner()->message(_("math text mode toggled"));
692 if (!mathcursor->Selection()) {
693 mathcursor->handleFont(LM_TC_TEX);
694 //bv->owner()->message(_("TeX mode toggled"));
699 case LFUN_MATH_LIMITS:
700 bv->lockedInsetStoreUndo(Undo::INSERT);
701 if (mathcursor->toggleLimits())
707 bv->lockedInsetStoreUndo(Undo::INSERT);
708 latexkeys const * l = in_word_set(arg);
709 mathcursor->SetSize(MathStyles(l ? l->id : static_cast<unsigned int>(-1)));
714 case LFUN_INSERT_MATRIX:
716 bv->lockedInsetStoreUndo(Undo::INSERT);
717 mathcursor->Interpret("matrix " + arg);
722 case LFUN_INSERT_MATH:
724 bv->lockedInsetStoreUndo(Undo::INSERT);
725 mathcursor->Interpret(arg);
730 case LFUN_MATH_DELIM:
732 bv->lockedInsetStoreUndo(Undo::INSERT);
735 static const string vdelim("(){}[]./|");
736 //lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
741 istringstream is(arg.c_str());
745 //lyxerr << "formulabase::LFUN_MATH_DELIM, lt: '" << lt << "'\n";
746 //lyxerr << "formulabase::LFUN_MATH_DELIM, rt: '" << rt << "'\n";
749 latexkeys const * l = in_word_set(lt);
752 } else if (vdelim.find(lt[0]) != string::npos)
756 latexkeys const * l = in_word_set(rt);
759 } else if (vdelim.find(rt[0]) != string::npos)
762 handleDelim(bv, ilt, irt);
767 case LFUN_PROTECTEDSPACE:
768 bv->lockedInsetStoreUndo(Undo::INSERT);
769 mathcursor->insert(new MathSpaceInset(1));
774 bv->owner()->message(_("Invalid action in math mode!"));
778 case LFUN_MATH_HALIGN:
780 bv->lockedInsetStoreUndo(Undo::INSERT);
781 lyxerr << "handling halign '" << arg << "'\n";
783 MathArrayInset * p = matrixpar(idx);
786 p->halign(arg.size() ? arg[0] : 'c', p->col(idx));
791 case LFUN_MATH_VALIGN:
793 bv->lockedInsetStoreUndo(Undo::INSERT);
794 lyxerr << "handling valign '" << arg << "'\n";
796 MathArrayInset * p = matrixpar(idx);
799 p->valign(arg.size() ? arg[0] : 'c');
804 case LFUN_MATH_ROW_INSERT:
806 bv->lockedInsetStoreUndo(Undo::INSERT);
808 MathArrayInset * p = matrixpar(idx);
809 lyxerr << " calling LFUN_MATH_ROW_INSERT on " << p << endl;
812 p->addRow(p->row(idx));
817 case LFUN_MATH_ROW_DELETE:
819 bv->lockedInsetStoreUndo(Undo::INSERT);
821 MathArrayInset * p = matrixpar(idx);
822 lyxerr << " calling LFUN_MATH_ROW_DELETE on " << p << endl;
825 p->delRow(p->row(idx));
830 case LFUN_MATH_COLUMN_INSERT:
832 bv->lockedInsetStoreUndo(Undo::INSERT);
834 MathArrayInset * p = matrixpar(idx);
837 p->addCol(p->col(idx));
842 case LFUN_MATH_COLUMN_DELETE:
844 bv->lockedInsetStoreUndo(Undo::INSERT);
846 MathArrayInset * p = matrixpar(idx);
849 p->delCol(p->col(idx));
854 case LFUN_EXEC_COMMAND:
855 result = UNDISPATCHED;
859 if ((action == -1 || action == LFUN_SELFINSERT) && !arg.empty()) {
860 unsigned char c = arg[0];
861 //lyxerr << "char: '" << c << "' int: " << int(c) << endl;
862 //owner_->getIntl()->getTrans().TranslateAndInsert(c, lt);
863 //lyxerr << "trans: '" << c << "' int: " << int(c) << endl;
864 bv->lockedInsetStoreUndo(Undo::INSERT);
866 if (c == 0) { // Dead key, do nothing
867 //lyxerr << "deadkey" << endl;
872 if (mathcursor->getLastCode() == LM_TC_TEX) {
873 mathcursor->MacroModeOpen();
874 mathcursor->clearLastCode();
876 } else if (!varcode) {
877 short f = mathcursor->getLastCode() ?
878 mathcursor->getLastCode() :
879 mathcursor->nextCode();
880 varcode = MathIsAlphaFont(f) ?
881 static_cast<MathTextCodes>(f) :
885 // lyxerr << "Varcode << vardoce;
886 MathTextCodes char_code = varcode;
889 {'A', 'B', 'X', 0 , 'E', 0 , 0 , 'H', 'I', 0 ,
890 'K', 0 , 'M', 'N', 'O', 0 , 0 , 'P', 0 , 'T',
891 'Y', 0, 0, 0, 0 , 'Z' };
893 if ('A' <= c && c <= 'Z' && greek[c - 'A']) {
894 char_code = LM_TC_RM;
897 char_code = LM_TC_SYMB;
900 mathcursor->insert(c, char_code);
902 if (greek_kb_flag && char_code == LM_TC_RM )
903 mathcursor->setLastCode(LM_TC_VAR);
907 if (greek_kb_flag < 2)
910 } else if (strchr("!,:;{}", c) && (varcode == LM_TC_TEX||was_macro)) {
911 mathcursor->insert(c, LM_TC_TEX);
913 mathcursor->insert('}', LM_TC_TEX);
916 mathcursor->clearLastCode();
917 // varcode = LM_TC_MIN;
918 } else if (c == '_' && varcode == LM_TC_TEX) {
919 mathcursor->insert(c, LM_TC_SPECIAL);
920 mathcursor->clearLastCode();
921 // varcode = LM_TC_MIN;
922 } else if ('0' <= c && c <= '9' && (varcode == LM_TC_TEX||was_macro)) {
923 mathcursor->MacroModeOpen();
924 mathcursor->clearLastCode();
925 mathcursor->insert(c, LM_TC_MIN);
926 } else if (('0' <= c && c <= '9') || strchr(";:!|[]().,?", c)) {
927 MathTextCodes code = mathcursor->getLastCode();
928 if (code != LM_TC_TEXTRM)
930 mathcursor->insert(c, code);
931 } else if (strchr("+/-*<>=", c)) {
932 MathTextCodes code = mathcursor->getLastCode();
933 if (code != LM_TC_TEXTRM)
935 mathcursor->insert(c, code);
936 } else if (strchr(latex_special_chars, c) && c != '_') {
937 MathTextCodes code = mathcursor->getLastCode();
938 if (code != LM_TC_TEXTRM)
939 code = LM_TC_SPECIAL;
940 mathcursor->insert(c, code);
941 } else if (c == '_' || c == '^') {
945 mathcursor->Interpret(s);
946 } else if (c == ' ') {
948 short f = (mathcursor->getLastCode()) ?
949 mathcursor->getLastCode() :
950 mathcursor->nextCode();
951 varcode = MathIsAlphaFont(f) ?
952 static_cast<MathTextCodes>(f) :
956 if (varcode == LM_TC_TEXTRM) {
957 mathcursor->insert(c, LM_TC_TEXTRM);
958 } else if (was_macro) {
959 mathcursor->MacroModeClose();
961 if (!mathcursor->pop())
963 mathcursor->plainRight();
965 } else if (c == '\'' || c == '@') {
966 mathcursor->insert (c, LM_TC_VAR);
967 } else if (c == '\\') {
969 mathcursor->MacroModeClose();
970 bv->owner()->message(_("TeX mode"));
971 mathcursor->setLastCode(LM_TC_TEX);
974 } else if (action == LFUN_MATH_PANEL) {
975 result = UNDISPATCHED;
977 lyxerr << "Closed by action " << action << endl;
982 mathcursor->normalize();
984 if (mathcursor && was_macro != mathcursor->InMacroMode()
986 && action != LFUN_BACKSPACE)
992 if (mathcursor && (mathcursor->Selection() || was_selection))
993 toggleInsetSelection(bv);
995 if (result == DISPATCHED || result == DISPATCHED_NOUPDATE ||
996 result == UNDISPATCHED)
999 bv->unlockInset(this);
1001 return result; // original version
1006 /* FIXME: math-greek-toggle seems to work OK, but math-greek doesn't turn
1008 bool math_insert_greek(BufferView * bv, char c)
1010 if (!bv->available())
1018 if (!bv->theLockingInset() || bv->theLockingInset()->isTextInset()) {
1019 int greek_kb_flag_save = greek_kb_flag;
1020 InsetFormula * new_inset = new InsetFormula();
1021 bv->beforeChange(bv->text);
1022 if (!bv->insertInset(new_inset)) {
1027 new_inset->edit(bv, 0, 0, 0);
1028 new_inset->localDispatch(bv, LFUN_SELFINSERT, tmp);
1029 if (greek_kb_flag_save < 2) {
1030 bv->unlockInset(new_inset); // bv->theLockingInset());
1031 bv->text->cursorRight(bv, true);
1034 if (bv->theLockingInset()->lyxCode() == Inset::MATH_CODE ||
1035 bv->theLockingInset()->lyxCode() == Inset::MATHMACRO_CODE)
1036 static_cast<InsetFormula*>(bv->theLockingInset())->localDispatch(bv, LFUN_SELFINSERT, tmp);
1038 lyxerr << "Math error: attempt to write on a wrong "
1039 "class of inset." << endl;
1045 Inset::Code InsetFormulaBase::lyxCode() const
1047 return Inset::MATH_CODE;
1051 LyXFont const InsetFormulaBase::convertFont(LyXFont const & f) const
1053 // We have already discussed what was here
1056 font.setLatex(LyXFont::OFF);
1061 MathInset * InsetFormulaBase::par() const
1067 void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
1069 if (bv->available()) {
1070 // Feature "Read math inset from selection" disabled.
1071 // // use selection if available..
1073 // if (action == LFUN_MATH_IMPORT_SELECTION)
1076 // sel = bv->getLyXText()->selectionAsString(bv->buffer());
1079 // if (sel.empty()) {
1080 f = new InsetFormula;
1081 if (openNewInset(bv, f)) {
1082 // don't do that also for LFUN_MATH_MODE unless you want end up with
1083 // always changing to mathrm when opening an inlined inset
1084 // -- I really hate "LyXfunc overloading"...
1086 f->localDispatch(bv, LFUN_MATH_DISPLAY, string());
1087 f->localDispatch(bv, LFUN_INSERT_MATH, arg);
1090 // f = new InsetFormula(sel);
1091 // bv->getLyXText()->cutSelection(bv);
1092 // openNewInset(bv, f);
1095 bv->owner()->getLyXFunc()->setMessage(N_("Math editor mode"));
1098 void mathDispatchMathDisplay(BufferView * bv, string const & arg)
1100 mathDispatchCreation(bv, arg, true);
1103 void mathDispatchMathMode(BufferView * bv, string const & arg)
1105 mathDispatchCreation(bv, arg, false);
1108 void mathDispatchMathImportSelection(BufferView * bv, string const & arg)
1110 mathDispatchCreation(bv, arg, true);
1113 void mathDispatchMathMacro(BufferView * bv, string const & arg)
1115 if (bv->available()) {
1118 bv->owner()->getLyXFunc()->setErrorMessage(N_("Missing argument"));
1120 string const s1 = token(s, ' ', 1);
1121 int const na = s1.empty() ? 0 : lyx::atoi(s1);
1122 openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na));
1127 void mathDispatchMathDelim(BufferView * bv, string const & arg)
1129 if (bv->available()) {
1130 if (openNewInset(bv, new InsetFormula))
1131 bv->theLockingInset()->localDispatch(bv, LFUN_MATH_DELIM, arg);
1136 void mathDispatchInsertMatrix(BufferView * bv, string const & arg)
1138 if (bv->available()) {
1139 if (openNewInset(bv, new InsetFormula))
1140 bv->theLockingInset()->localDispatch(bv, LFUN_INSERT_MATRIX, arg);
1144 void mathDispatchInsertMath(BufferView * bv, string const & arg)
1146 if (bv->available()) {
1147 if (arg.size() && arg[0] == '\\') {
1148 InsetFormula * f = new InsetFormula(arg);
1149 openNewInset(bv, f);
1151 mathDispatchMathMode(bv, arg);