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 "math_deliminset.h"
43 #include "support/lyxlib.h"
44 #include "mathed/support.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 bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
82 LyXText * lt = bv->getLyXText();
86 if (!bv->insertInset(new_inset)) {
90 new_inset->edit(bv, 0, 0, 0);
98 LyXFont WhichFont(short type, int size)
135 case LM_TC_SPECIAL: //f = Math_Fonts[0]; break;
148 if (type == LM_TC_BSYM) {
161 case LM_ST_SCRIPTSCRIPT:
167 lyxerr << "Math Error: wrong font size: " << size << endl;
171 if (type != LM_TC_TEXTRM)
172 f.setColor(LColor::math);
180 void mathed_init_fonts()
182 Math_Fonts = new LyXFont[8]; //DEC cxx cannot initialize all fonts
185 for (int i = 0 ; i < 8 ; ++i) {
186 Math_Fonts[i] = LyXFont(LyXFont::ALL_SANE);
189 Math_Fonts[0].setShape(LyXFont::ITALIC_SHAPE);
191 Math_Fonts[1].setFamily(LyXFont::SYMBOL_FAMILY);
193 Math_Fonts[2].setFamily(LyXFont::SYMBOL_FAMILY);
194 Math_Fonts[2].setShape(LyXFont::ITALIC_SHAPE);
196 Math_Fonts[3].setSeries(LyXFont::BOLD_SERIES);
198 Math_Fonts[4].setFamily(LyXFont::SANS_FAMILY);
199 Math_Fonts[4].setShape(LyXFont::ITALIC_SHAPE);
201 Math_Fonts[5].setFamily(LyXFont::TYPEWRITER_FAMILY);
203 Math_Fonts[6].setFamily(LyXFont::ROMAN_FAMILY);
205 Math_Fonts[7].setFamily(LyXFont::SANS_FAMILY);
209 // returns the nearest enclosing matrix
210 MathArrayInset * matrixpar(int & idx)
214 static_cast<MathArrayInset *>
215 (mathcursor ? mathcursor->enclosing(LM_OT_MATRIX, idx) : 0);
222 InsetFormulaBase::InsetFormulaBase(MathInset * par)
227 InsetFormulaBase::InsetFormulaBase(InsetFormulaBase const & f)
228 : UpdatableInset(f), par_(static_cast<MathInset *>(f.par_->clone()))
232 InsetFormulaBase::~InsetFormulaBase()
235 #warning leak this for a while...
241 void InsetFormulaBase::read(Buffer const *, LyXLex & lex)
246 void InsetFormulaBase::write(Buffer const *, ostream & os) const
251 int InsetFormulaBase::latex(Buffer const *, ostream & os,
252 bool fragile, bool spacing) const
254 return latex(os, fragile, spacing);
257 int InsetFormulaBase::ascii(Buffer const *, ostream & os, int spacing) const
259 return ascii(os, spacing);
262 int InsetFormulaBase::linuxdoc(Buffer const *, ostream & os) const
267 int InsetFormulaBase::docBook(Buffer const *, ostream & os) const
274 // Check if uses AMS macros
275 void InsetFormulaBase::validate(LaTeXFeatures &) const
279 string const InsetFormulaBase::editMessage() const
281 return _("Math editor mode");
285 void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int)
287 mathcursor = new MathCursor(this);
289 if (!bv->lockInset(this))
290 lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
292 par_->Metrics(LM_ST_TEXT);
293 bv->updateInset(this, false);
305 void InsetFormulaBase::insetUnlock(BufferView * bv)
308 if (mathcursor->InMacroMode()) {
309 mathcursor->MacroModeClose();
315 bv->updateInset(this, false);
319 void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
321 mathcursor->GetPos(x, y);
327 void InsetFormulaBase::toggleInsetCursor(BufferView * bv)
332 if (isCursorVisible())
333 bv->hideLockedInsetCursor();
337 mathcursor->GetPos(x, y);
341 LyXFont font = WhichFont(LM_TC_TEXTRM, LM_ST_TEXT);
342 int const asc = lyxfont::maxAscent(font);
343 int const desc = lyxfont::maxDescent(font);
345 bv->showLockedInsetCursor(x, y, asc, desc);
348 toggleCursorVisible();
352 void InsetFormulaBase::showInsetCursor(BufferView * bv, bool)
354 if (!isCursorVisible()) {
358 mathcursor->GetPos(x, y);
361 LyXFont font = WhichFont(LM_TC_TEXTRM, LM_ST_TEXT);
362 int const asc = lyxfont::maxAscent(font);
363 int const desc = lyxfont::maxDescent(font);
364 bv->fitLockedInsetCursor(x, y, asc, desc);
366 toggleInsetCursor(bv);
371 void InsetFormulaBase::hideInsetCursor(BufferView * bv)
373 if (isCursorVisible())
374 toggleInsetCursor(bv);
378 void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
383 bv->updateInset(this, false);
387 vector<string> const InsetFormulaBase::getLabelList() const
389 return std::vector<string>();
393 void InsetFormulaBase::updateLocal(BufferView * bv)
395 par_->Metrics(LM_ST_TEXT);
396 bv->updateInset(this, true);
400 void InsetFormulaBase::insetButtonRelease(BufferView * bv,
401 int x, int y, int /*button*/)
407 mathcursor->SetPos(x, y);
414 bv->updateInset(this, false);
419 void InsetFormulaBase::insetButtonPress(BufferView * bv,
420 int x, int y, int /*button*/)
425 if (mathcursor && mathcursor->Selection()) {
426 mathcursor->SelClear();
427 bv->updateInset(this, false);
432 void InsetFormulaBase::insetMotionNotify(BufferView * bv,
433 int x, int y, int /*button*/)
435 if (sel_x && sel_y && abs(x-sel_x) > 4 && !sel_flag) {
438 mathcursor->SetPos(sel_x + par_->xo(), sel_y + par_->yo());
439 mathcursor->SelStart();
441 mathcursor->GetPos(sel_x, sel_y);
442 } else if (sel_flag) {
446 mathcursor->SetPos(x, y);
448 mathcursor->GetPos(x, y);
449 if (sel_x != x || sel_y != y)
450 bv->updateInset(this, false);
457 void InsetFormulaBase::insetKeyPress(XKeyEvent *)
459 lyxerr[Debug::MATHED]
460 << "Used InsetFormulaBase::InsetKeyPress." << endl;
465 UpdatableInset::RESULT
466 InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
469 //lyxerr << "InsetFormulaBase::LocalDispatch: act: " << action
470 // << " arg: '" << arg << "' cursor: " << mathcursor << "\n";
471 // extern char *dispatch_result;
476 MathTextCodes varcode = LM_TC_MIN;
477 bool was_macro = mathcursor->InMacroMode();
479 bool space_on = false;
480 bool was_selection = mathcursor->Selection();
481 RESULT result = DISPATCHED;
482 static MathSpaceInset * sp = 0;
486 if (mathcursor->getLastCode() == LM_TC_TEX)
489 mathcursor->normalize();
493 // --- Cursor Movements ---------------------------------------------
496 sel = true; // fall through...
499 result = DISPATCH_RESULT(mathcursor->Right(sel));
505 sel = true; // fall through
508 result = DISPATCH_RESULT(mathcursor->Left(sel));
517 result = DISPATCH_RESULT(mathcursor->Up(sel));
526 result = DISPATCH_RESULT(mathcursor->Down(sel));
540 case LFUN_DELETE_LINE_FORWARD:
541 bv->lockedInsetStoreUndo(Undo::DELETE);
542 mathcursor->DelLine();
547 mathcursor->idxNext();
552 mathcursor->idxPrev();
557 bv->lockedInsetStoreUndo(Undo::EDIT);
558 mathcursor->splitCell();
563 if (!mathcursor->InMacroMode() && mathcursor->pos() == 0) {
564 bv->lockedInsetStoreUndo(Undo::DELETE);
565 mathcursor->pullArg();
566 bv->updateInset(this, true);
569 if (!mathcursor->Left())
574 bv->lockedInsetStoreUndo(Undo::DELETE);
575 mathcursor->Delete();
576 bv->updateInset(this, true);
580 // sprintf(dispatch_buffer, "%d %d",);
581 // dispatch_result = dispatch_buffer;
585 lyxerr << "LFUN_SETXY broken!\n";
590 istringstream is(arg.c_str());
593 mathcursor->SetPos(x1 + x, y1 + y);
598 // cursor selection ----------------------------
602 mathcursor->MacroModeClose();
603 bv->lockedInsetStoreUndo(Undo::INSERT);
604 mathcursor->SelPaste();
609 bv->lockedInsetStoreUndo(Undo::DELETE);
610 mathcursor->SelCut();
615 mathcursor->SelCopy();
620 case LFUN_WORDRIGHTSEL:
621 case LFUN_WORDLEFTSEL:
624 // --- accented characters ------------------------------
626 case LFUN_UMLAUT: mathcursor->setAccent(LM_ddot); break;
627 case LFUN_CIRCUMFLEX: mathcursor->setAccent(LM_hat); break;
628 case LFUN_GRAVE: mathcursor->setAccent(LM_grave); break;
629 case LFUN_ACUTE: mathcursor->setAccent(LM_acute); break;
630 case LFUN_TILDE: mathcursor->setAccent(LM_tilde); break;
631 case LFUN_MACRON: mathcursor->setAccent(LM_bar); break;
632 case LFUN_DOT: mathcursor->setAccent(LM_dot); break;
633 case LFUN_CARON: mathcursor->setAccent(LM_check); break;
634 case LFUN_BREVE: mathcursor->setAccent(LM_breve); break;
635 case LFUN_VECTOR: mathcursor->setAccent(LM_vec); break;
639 if (!greek_kb_flag) {
641 bv->owner()->message(_("Math greek mode on"));
647 case LFUN_GREEK_TOGGLE:
648 greek_kb_flag = greek_kb_flag ? 0 : 2;
650 bv->owner()->message(_("Math greek keyboard on"));
652 bv->owner()->message(_("Math greek keyboard off"));
656 case LFUN_BOLD: handleFont(bv, LM_TC_BF); break;
657 case LFUN_SANS: handleFont(bv, LM_TC_SF); break;
658 case LFUN_EMPH: handleFont(bv, LM_TC_CAL); break;
659 case LFUN_ROMAN: handleFont(bv, LM_TC_RM); break;
660 case LFUN_CODE: handleFont(bv, LM_TC_TT); break;
661 case LFUN_DEFAULT: handleFont(bv, LM_TC_VAR); break;
664 handleFont(bv, LM_TC_TEXTRM);
665 //bv->owner()->message(_("math text mode toggled"));
670 if (!mathcursor->Selection()) {
671 mathcursor->handleFont(LM_TC_TEX);
672 //bv->owner()->message(_("TeX mode toggled"));
677 case LFUN_MATH_LIMITS:
678 bv->lockedInsetStoreUndo(Undo::INSERT);
679 if (mathcursor->toggleLimits())
685 bv->lockedInsetStoreUndo(Undo::INSERT);
686 latexkeys const * l = in_word_set(arg);
687 mathcursor->SetSize(MathStyles(l ? l->id : static_cast<unsigned int>(-1)));
692 case LFUN_INSERT_MATH:
694 bv->lockedInsetStoreUndo(Undo::INSERT);
695 mathcursor->Interpret(arg);
700 case LFUN_INSERT_MATRIX:
702 bv->lockedInsetStoreUndo(Undo::INSERT);
707 istringstream is(arg.c_str());
708 is >> m >> n >> v_align >> h_align;
709 MathArrayInset * p = new MathArrayInset(m, n);
710 p->valign(v_align[0]);
712 mathcursor->insert(p);
717 case LFUN_MATH_DELIM:
719 bv->lockedInsetStoreUndo(Undo::INSERT);
722 static const string vdelim("(){}[]./|");
723 lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
728 istringstream is(arg.c_str());
732 lyxerr << "formulabase::LFUN_MATH_DELIM, lt: '" << lt << "'\n";
733 lyxerr << "formulabase::LFUN_MATH_DELIM, rt: '" << rt << "'\n";
736 latexkeys const * l = in_word_set(lt);
739 } else if (vdelim.find(lt[0]) != string::npos)
743 latexkeys const * l = in_word_set(rt);
746 } else if (vdelim.find(rt[0]) != string::npos)
749 if (mathcursor->selection) {
750 MathDelimInset * p = new MathDelimInset(ilt, irt);
752 mathcursor->selArray(ar);
753 lyxerr << "selarray: " << ar << "\n";
755 mathcursor->insert(p);
757 mathcursor->insert(new MathDelimInset(ilt, irt));
763 case LFUN_PROTECTEDSPACE:
764 bv->lockedInsetStoreUndo(Undo::INSERT);
765 mathcursor->insert(new MathSpaceInset(1));
771 bv->owner()->message(_("Invalid action in math mode!"));
775 case LFUN_MATH_HALIGN:
777 bv->lockedInsetStoreUndo(Undo::INSERT);
778 lyxerr << "handling halign '" << arg << "'\n";
780 MathArrayInset * p = matrixpar(idx);
783 p->halign(arg.size() ? arg[0] : 'c', p->col(idx));
788 case LFUN_MATH_VALIGN:
790 bv->lockedInsetStoreUndo(Undo::INSERT);
791 lyxerr << "handling valign '" << arg << "'\n";
793 MathArrayInset * p = matrixpar(idx);
796 p->valign(arg.size() ? arg[0] : 'c');
801 case LFUN_MATH_ROW_INSERT:
803 bv->lockedInsetStoreUndo(Undo::INSERT);
805 MathArrayInset * p = matrixpar(idx);
806 lyxerr << " calling LFUN_MATH_ROW_INSERT on " << p << endl;
809 p->addRow(p->row(idx));
814 case LFUN_MATH_ROW_DELETE:
816 bv->lockedInsetStoreUndo(Undo::INSERT);
818 MathArrayInset * p = matrixpar(idx);
819 lyxerr << " calling LFUN_MATH_ROW_DELETE on " << p << endl;
822 p->delRow(p->row(idx));
827 case LFUN_MATH_COLUMN_INSERT:
829 bv->lockedInsetStoreUndo(Undo::INSERT);
831 MathArrayInset * p = matrixpar(idx);
834 p->addCol(p->col(idx));
839 case LFUN_MATH_COLUMN_DELETE:
841 bv->lockedInsetStoreUndo(Undo::INSERT);
843 MathArrayInset * p = matrixpar(idx);
846 p->delCol(p->col(idx));
851 case LFUN_EXEC_COMMAND:
852 result = UNDISPATCHED;
856 if ((action == -1 || action == LFUN_SELFINSERT) && !arg.empty()) {
857 unsigned char c = arg[0];
858 lyxerr << "char: '" << c << "' int: " << int(c) << endl;
859 //owner_->getIntl()->getTrans().TranslateAndInsert(c, lt);
860 lyxerr << "trans: '" << c << "' int: " << int(c) << endl;
861 bv->lockedInsetStoreUndo(Undo::INSERT);
863 if (c == ' ' && mathcursor->getAccent() == LM_hat) {
865 mathcursor->setAccent(0);
868 if (c == 0) { // Dead key, do nothing
869 //lyxerr << "deadkey" << endl;
874 if (mathcursor->getLastCode() == LM_TC_TEX) {
875 mathcursor->MacroModeOpen();
876 mathcursor->clearLastCode();
878 } else if (!varcode) {
879 short f = mathcursor->getLastCode() ?
880 mathcursor->getLastCode() :
881 mathcursor->nextCode();
882 varcode = MathIsAlphaFont(f) ?
883 static_cast<MathTextCodes>(f) :
887 // lyxerr << "Varcode << vardoce;
888 MathTextCodes char_code = varcode;
891 {'A', 'B', 'X', 0 , 'E', 0 , 0 , 'H', 'I', 0 ,
892 'K', 0 , 'M', 'N', 'O', 0 , 0 , 'P', 0 , 'T',
893 'Y', 0, 0, 0, 0 , 'Z' };
895 if ('A' <= c && c <= 'Z' && greek[c - 'A']) {
896 char_code = LM_TC_RM;
899 char_code = LM_TC_SYMB;
902 mathcursor->insert(c, char_code);
904 if (greek_kb_flag && char_code == LM_TC_RM )
905 mathcursor->setLastCode(LM_TC_VAR);
909 if (greek_kb_flag < 2)
912 } else if (strchr("!,:;{}", c) && (varcode == LM_TC_TEX||was_macro)) {
913 mathcursor->insert(c, LM_TC_TEX);
915 mathcursor->insert('}', LM_TC_TEX);
918 mathcursor->clearLastCode();
919 // varcode = LM_TC_MIN;
920 } else if (c == '_' && varcode == LM_TC_TEX) {
921 mathcursor->insert(c, LM_TC_SPECIAL);
922 mathcursor->clearLastCode();
923 // varcode = LM_TC_MIN;
924 } else if ('0' <= c && c <= '9' && (varcode == LM_TC_TEX||was_macro)) {
925 mathcursor->MacroModeOpen();
926 mathcursor->clearLastCode();
927 mathcursor->insert(c, LM_TC_MIN);
928 } else if (('0' <= c && c <= '9') || strchr(";:!|[]().,?", c)) {
929 MathTextCodes code = mathcursor->getLastCode();
930 if (code != LM_TC_TEXTRM)
932 mathcursor->insert(c, code);
933 } else if (strchr("+/-*<>=", c)) {
934 MathTextCodes code = mathcursor->getLastCode();
935 if (code != LM_TC_TEXTRM)
937 mathcursor->insert(c, code);
938 } else if (strchr(latex_special_chars, c) && c!= '_') {
939 MathTextCodes code = mathcursor->getLastCode();
940 if (code != LM_TC_TEXTRM)
941 code = LM_TC_SPECIAL;
942 mathcursor->insert(c, code);
943 } else if (c == '_' || c == '^') {
947 mathcursor->Interpret(s);
948 } else if (c == ' ') {
950 short f = (mathcursor->getLastCode()) ?
951 mathcursor->getLastCode() :
952 mathcursor->nextCode();
953 varcode = MathIsAlphaFont(f) ?
954 static_cast<MathTextCodes>(f) :
958 if (varcode == LM_TC_TEXTRM) {
959 mathcursor->insert(c, LM_TC_TEXTRM);
960 } else if (was_macro) {
961 mathcursor->MacroModeClose();
963 int isp = (sp->GetSpace()<5) ? sp->GetSpace()+1: 0;
967 if (!mathcursor->pop())
969 mathcursor->plainRight();
971 } else if (c == '\'' || c == '@') {
972 mathcursor->insert (c, LM_TC_VAR);
973 } else if (c == '\\') {
975 mathcursor->MacroModeClose();
976 bv->owner()->message(_("TeX mode"));
977 mathcursor->setLastCode(LM_TC_TEX);
980 } else if (action == LFUN_MATH_PANEL) {
981 result = UNDISPATCHED;
983 lyxerr << "Closed by action " << action << endl;
989 mathcursor->normalize();
991 if (mathcursor && was_macro != mathcursor->InMacroMode()
993 && action != LFUN_BACKSPACE)
1002 if (mathcursor && (mathcursor->Selection() || was_selection))
1003 toggleInsetSelection(bv);
1005 if (result == DISPATCHED || result == DISPATCHED_NOUPDATE ||
1006 result == UNDISPATCHED)
1007 showInsetCursor(bv);
1009 bv->unlockInset(this);
1011 return result; // original version
1016 /* FIXME: math-greek-toggle seems to work OK, but math-greek doesn't turn
1018 bool math_insert_greek(BufferView * bv, char c)
1020 if (!bv->available())
1028 if (!bv->theLockingInset() || bv->theLockingInset()->isTextInset()) {
1029 int greek_kb_flag_save = greek_kb_flag;
1030 InsetFormula * new_inset = new InsetFormula();
1031 bv->beforeChange(bv->text);
1032 if (!bv->insertInset(new_inset)) {
1037 new_inset->edit(bv, 0, 0, 0);
1038 new_inset->localDispatch(bv, LFUN_SELFINSERT, tmp);
1039 if (greek_kb_flag_save < 2) {
1040 bv->unlockInset(new_inset); // bv->theLockingInset());
1041 bv->text->cursorRight(bv, true);
1044 if (bv->theLockingInset()->lyxCode() == Inset::MATH_CODE ||
1045 bv->theLockingInset()->lyxCode() == Inset::MATHMACRO_CODE)
1046 static_cast<InsetFormula*>(bv->theLockingInset())->localDispatch(bv, LFUN_SELFINSERT, tmp);
1048 lyxerr << "Math error: attempt to write on a wrong "
1049 "class of inset." << endl;
1055 Inset::Code InsetFormulaBase::lyxCode() const
1057 return Inset::MATH_CODE;
1061 LyXFont const InsetFormulaBase::convertFont(LyXFont const & f) const
1063 // We have already discussed what was here
1066 font.setLatex(LyXFont::OFF);
1071 MathInset * InsetFormulaBase::par() const
1077 void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
1079 if (bv->available()) {
1080 // Feature "Read math inset from selection" disabled.
1081 // // use selection if available..
1083 // if (action == LFUN_MATH_IMPORT_SELECTION)
1086 // sel = bv->getLyXText()->selectionAsString(bv->buffer());
1089 // if (sel.empty()) {
1090 f = new InsetFormula;
1091 openNewInset(bv, f);
1092 // don't do that also for LFUN_MATH_MODE unless you want end up with
1093 // always changing to mathrm when opening an inlined inset
1094 // -- I really hate "LyXfunc overloading"...
1096 f->localDispatch(bv, LFUN_MATH_DISPLAY, string());
1097 f->localDispatch(bv, LFUN_INSERT_MATH, arg);
1099 // f = new InsetFormula(sel);
1100 // bv->getLyXText()->cutSelection(bv);
1101 // openNewInset(bv, f);
1104 bv->owner()->getLyXFunc()->setMessage(N_("Math editor mode"));
1107 void mathDispatchMathDisplay(BufferView * bv, string const & arg)
1109 mathDispatchCreation(bv, arg, true);
1112 void mathDispatchMathMode(BufferView * bv, string const & arg)
1114 mathDispatchCreation(bv, arg, false);
1117 void mathDispatchMathImportSelection(BufferView * bv, string const & arg)
1119 mathDispatchCreation(bv, arg, true);
1122 void mathDispatchMathMacro(BufferView * bv, string const & arg)
1124 if (bv->available()) {
1127 bv->owner()->getLyXFunc()->setErrorMessage(N_("Missing argument"));
1129 string const s1 = token(s, ' ', 1);
1130 int const na = s1.empty() ? 0 : lyx::atoi(s1);
1131 openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na));
1136 void mathDispatchMathDelim(BufferView * bv, string const & arg)
1138 if (bv->available()) {
1139 if (openNewInset(bv, new InsetFormula))
1140 bv->theLockingInset()->localDispatch(bv, LFUN_MATH_DELIM, arg);
1145 void mathDispatchInsertMatrix(BufferView * bv, string const & arg)
1147 if (bv->available()) {
1148 if (openNewInset(bv, new InsetFormula))
1149 bv->theLockingInset()->localDispatch(bv, LFUN_INSERT_MATRIX, arg);
1153 void mathDispatchInsertMath(BufferView * bv, string const & arg)
1155 if (bv->available()) {
1156 if (arg.size() && arg[0] == '\\') {
1157 InsetFormula * f = new InsetFormula(arg);
1158 openNewInset(bv, f);
1160 return mathDispatchMathDisplay(bv, arg);