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"
45 #include "undo_funcs.h"
51 extern char const * latex_special_chars;
53 int greek_kb_flag = 0;
54 extern char const * latex_mathenv[];
55 LyXFont * Math_Fonts = 0;
56 MathCursor * mathcursor = 0;
67 void mathed_init_fonts();
69 string nicelabel(string const & label)
71 return "(" + (label.empty() ? "#" : label) + ")";
74 void handleFont(BufferView * bv, MathTextCodes t)
76 if (mathcursor->Selection())
77 bv->lockedInsetStoreUndo(Undo::EDIT);
78 mathcursor->handleFont(t);
81 bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
83 LyXText * lt = bv->getLyXText();
87 if (!bv->insertInset(new_inset)) {
91 new_inset->edit(bv, 0, 0, 0);
99 LyXFont WhichFont(short type, int size)
136 case LM_TC_SPECIAL: //f = Math_Fonts[0]; break;
149 if (type == LM_TC_BSYM) {
162 case LM_ST_SCRIPTSCRIPT:
168 lyxerr << "Math Error: wrong font size: " << size << endl;
172 if (type != LM_TC_TEXTRM)
173 f.setColor(LColor::math);
181 void mathed_init_fonts()
183 Math_Fonts = new LyXFont[8]; //DEC cxx cannot initialize all fonts
186 for (int i = 0 ; i < 8 ; ++i) {
187 Math_Fonts[i] = LyXFont(LyXFont::ALL_SANE);
190 Math_Fonts[0].setShape(LyXFont::ITALIC_SHAPE);
192 Math_Fonts[1].setFamily(LyXFont::SYMBOL_FAMILY);
194 Math_Fonts[2].setFamily(LyXFont::SYMBOL_FAMILY);
195 Math_Fonts[2].setShape(LyXFont::ITALIC_SHAPE);
197 Math_Fonts[3].setSeries(LyXFont::BOLD_SERIES);
199 Math_Fonts[4].setFamily(LyXFont::SANS_FAMILY);
200 Math_Fonts[4].setShape(LyXFont::ITALIC_SHAPE);
202 Math_Fonts[5].setFamily(LyXFont::TYPEWRITER_FAMILY);
204 Math_Fonts[6].setFamily(LyXFont::ROMAN_FAMILY);
206 Math_Fonts[7].setFamily(LyXFont::SANS_FAMILY);
210 // returns the nearest enclosing matrix
211 MathArrayInset * matrixpar(int & idx)
215 static_cast<MathArrayInset *>
216 (mathcursor ? mathcursor->enclosing(LM_OT_MATRIX, idx) : 0);
223 InsetFormulaBase::InsetFormulaBase(MathInset * par)
228 InsetFormulaBase::InsetFormulaBase(InsetFormulaBase const & f)
229 : UpdatableInset(f), par_(static_cast<MathInset *>(f.par_->clone()))
233 InsetFormulaBase::~InsetFormulaBase()
236 #warning leak this for a while...
242 void InsetFormulaBase::read(Buffer const *, LyXLex & lex)
247 void InsetFormulaBase::write(Buffer const *, ostream & os) const
252 int InsetFormulaBase::latex(Buffer const *, ostream & os,
253 bool fragile, bool spacing) const
255 return latex(os, fragile, spacing);
258 int InsetFormulaBase::ascii(Buffer const *, ostream & os, int spacing) const
260 return ascii(os, spacing);
263 int InsetFormulaBase::linuxdoc(Buffer const *, ostream & os) const
268 int InsetFormulaBase::docBook(Buffer const *, ostream & os) const
275 // Check if uses AMS macros
276 void InsetFormulaBase::validate(LaTeXFeatures &) const
280 string const InsetFormulaBase::editMessage() const
282 return _("Math editor mode");
286 void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int)
288 mathcursor = new MathCursor(this);
290 if (!bv->lockInset(this))
291 lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
293 par_->Metrics(LM_ST_TEXT);
294 bv->updateInset(this, false);
306 void InsetFormulaBase::insetUnlock(BufferView * bv)
309 if (mathcursor->InMacroMode()) {
310 mathcursor->MacroModeClose();
316 bv->updateInset(this, false);
320 void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
322 mathcursor->GetPos(x, y);
328 void InsetFormulaBase::toggleInsetCursor(BufferView * bv)
333 if (isCursorVisible())
334 bv->hideLockedInsetCursor();
338 mathcursor->GetPos(x, y);
342 LyXFont font = WhichFont(LM_TC_TEXTRM, LM_ST_TEXT);
343 int const asc = lyxfont::maxAscent(font);
344 int const desc = lyxfont::maxDescent(font);
346 bv->showLockedInsetCursor(x, y, asc, desc);
349 toggleCursorVisible();
353 void InsetFormulaBase::showInsetCursor(BufferView * bv, bool)
355 if (!isCursorVisible()) {
359 mathcursor->GetPos(x, y);
362 LyXFont font = WhichFont(LM_TC_TEXTRM, LM_ST_TEXT);
363 int const asc = lyxfont::maxAscent(font);
364 int const desc = lyxfont::maxDescent(font);
365 bv->fitLockedInsetCursor(x, y, asc, desc);
367 toggleInsetCursor(bv);
372 void InsetFormulaBase::hideInsetCursor(BufferView * bv)
374 if (isCursorVisible())
375 toggleInsetCursor(bv);
379 void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
384 bv->updateInset(this, false);
388 vector<string> const InsetFormulaBase::getLabelList() const
390 return std::vector<string>();
394 void InsetFormulaBase::updateLocal(BufferView * bv)
396 par_->Metrics(LM_ST_TEXT);
397 bv->updateInset(this, true);
401 void InsetFormulaBase::insetButtonRelease(BufferView * bv,
402 int x, int y, int /*button*/)
408 mathcursor->SetPos(x, y);
415 bv->updateInset(this, false);
420 void InsetFormulaBase::insetButtonPress(BufferView * bv,
421 int x, int y, int /*button*/)
426 if (mathcursor && mathcursor->Selection()) {
427 mathcursor->SelClear();
428 bv->updateInset(this, false);
433 void InsetFormulaBase::insetMotionNotify(BufferView * bv,
434 int x, int y, int /*button*/)
436 if (sel_x && sel_y && abs(x-sel_x) > 4 && !sel_flag) {
439 mathcursor->SetPos(sel_x + par_->xo(), sel_y + par_->yo());
440 mathcursor->SelStart();
442 mathcursor->GetPos(sel_x, sel_y);
443 } else if (sel_flag) {
447 mathcursor->SetPos(x, y);
449 mathcursor->GetPos(x, y);
450 if (sel_x != x || sel_y != y)
451 bv->updateInset(this, false);
458 void InsetFormulaBase::insetKeyPress(XKeyEvent *)
460 lyxerr[Debug::MATHED]
461 << "Used InsetFormulaBase::InsetKeyPress." << endl;
466 UpdatableInset::RESULT
467 InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
470 //lyxerr << "InsetFormulaBase::LocalDispatch: act: " << action
471 // << " arg: '" << arg << "' cursor: " << mathcursor << "\n";
472 // extern char *dispatch_result;
477 MathTextCodes varcode = LM_TC_MIN;
478 bool was_macro = mathcursor->InMacroMode();
480 bool space_on = false;
481 bool was_selection = mathcursor->Selection();
482 RESULT result = DISPATCHED;
483 static MathSpaceInset * sp = 0;
487 if (mathcursor->getLastCode() == LM_TC_TEX)
490 mathcursor->normalize();
494 // --- Cursor Movements ---------------------------------------------
497 sel = true; // fall through...
500 result = DISPATCH_RESULT(mathcursor->Right(sel));
506 sel = true; // fall through
509 result = DISPATCH_RESULT(mathcursor->Left(sel));
518 result = DISPATCH_RESULT(mathcursor->Up(sel));
527 result = DISPATCH_RESULT(mathcursor->Down(sel));
541 case LFUN_DELETE_LINE_FORWARD:
542 bv->lockedInsetStoreUndo(Undo::DELETE);
543 mathcursor->DelLine();
548 mathcursor->idxNext();
553 mathcursor->idxPrev();
558 bv->lockedInsetStoreUndo(Undo::EDIT);
559 mathcursor->splitCell();
564 if (!mathcursor->InMacroMode() && mathcursor->pos() == 0) {
565 bv->lockedInsetStoreUndo(Undo::DELETE);
566 mathcursor->pullArg();
567 bv->updateInset(this, true);
570 if (!mathcursor->Left())
575 bv->lockedInsetStoreUndo(Undo::DELETE);
576 mathcursor->Delete();
577 bv->updateInset(this, true);
581 // sprintf(dispatch_buffer, "%d %d",);
582 // dispatch_result = dispatch_buffer;
586 lyxerr << "LFUN_SETXY broken!\n";
591 istringstream is(arg.c_str());
594 mathcursor->SetPos(x1 + x, y1 + y);
599 // cursor selection ----------------------------
603 mathcursor->MacroModeClose();
604 bv->lockedInsetStoreUndo(Undo::INSERT);
605 mathcursor->SelPaste();
610 bv->lockedInsetStoreUndo(Undo::DELETE);
611 mathcursor->SelCut();
616 mathcursor->SelCopy();
621 case LFUN_WORDRIGHTSEL:
622 case LFUN_WORDLEFTSEL:
625 // --- accented characters ------------------------------
627 case LFUN_UMLAUT: mathcursor->setAccent(LM_ddot); break;
628 case LFUN_CIRCUMFLEX: mathcursor->setAccent(LM_hat); break;
629 case LFUN_GRAVE: mathcursor->setAccent(LM_grave); break;
630 case LFUN_ACUTE: mathcursor->setAccent(LM_acute); break;
631 case LFUN_TILDE: mathcursor->setAccent(LM_tilde); break;
632 case LFUN_MACRON: mathcursor->setAccent(LM_bar); break;
633 case LFUN_DOT: mathcursor->setAccent(LM_dot); break;
634 case LFUN_CARON: mathcursor->setAccent(LM_check); break;
635 case LFUN_BREVE: mathcursor->setAccent(LM_breve); break;
636 case LFUN_VECTOR: mathcursor->setAccent(LM_vec); break;
640 if (!greek_kb_flag) {
642 bv->owner()->message(_("Math greek mode on"));
648 case LFUN_GREEK_TOGGLE:
649 greek_kb_flag = greek_kb_flag ? 0 : 2;
651 bv->owner()->message(_("Math greek keyboard on"));
653 bv->owner()->message(_("Math greek keyboard off"));
657 case LFUN_BOLD: handleFont(bv, LM_TC_BF); break;
658 case LFUN_SANS: handleFont(bv, LM_TC_SF); break;
659 case LFUN_EMPH: handleFont(bv, LM_TC_CAL); break;
660 case LFUN_ROMAN: handleFont(bv, LM_TC_RM); break;
661 case LFUN_CODE: handleFont(bv, LM_TC_TT); break;
662 case LFUN_DEFAULT: handleFont(bv, LM_TC_VAR); break;
665 handleFont(bv, LM_TC_TEXTRM);
666 //bv->owner()->message(_("math text mode toggled"));
671 if (!mathcursor->Selection()) {
672 mathcursor->handleFont(LM_TC_TEX);
673 //bv->owner()->message(_("TeX mode toggled"));
678 case LFUN_MATH_LIMITS:
679 bv->lockedInsetStoreUndo(Undo::INSERT);
680 if (mathcursor->toggleLimits())
686 bv->lockedInsetStoreUndo(Undo::INSERT);
687 latexkeys const * l = in_word_set(arg);
688 mathcursor->SetSize(MathStyles(l ? l->id : static_cast<unsigned int>(-1)));
693 case LFUN_INSERT_MATH:
695 bv->lockedInsetStoreUndo(Undo::INSERT);
696 mathcursor->Interpret(arg);
701 case LFUN_INSERT_MATRIX:
703 bv->lockedInsetStoreUndo(Undo::INSERT);
708 istringstream is(arg.c_str());
709 is >> m >> n >> v_align >> h_align;
710 MathArrayInset * p = new MathArrayInset(m, n);
711 p->valign(v_align[0]);
713 mathcursor->insert(p);
718 case LFUN_MATH_DELIM:
720 bv->lockedInsetStoreUndo(Undo::INSERT);
723 static const string vdelim("(){}[]./|");
724 lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
729 istringstream is(arg.c_str());
733 lyxerr << "formulabase::LFUN_MATH_DELIM, lt: '" << lt << "'\n";
734 lyxerr << "formulabase::LFUN_MATH_DELIM, rt: '" << rt << "'\n";
737 latexkeys const * l = in_word_set(lt);
740 } else if (vdelim.find(lt[0]) != string::npos)
744 latexkeys const * l = in_word_set(rt);
747 } else if (vdelim.find(rt[0]) != string::npos)
750 if (mathcursor->selection) {
751 MathDelimInset * p = new MathDelimInset(ilt, irt);
753 mathcursor->selArray(ar);
754 lyxerr << "selarray: " << ar << "\n";
756 mathcursor->insert(p);
758 mathcursor->insert(new MathDelimInset(ilt, irt));
764 case LFUN_PROTECTEDSPACE:
765 bv->lockedInsetStoreUndo(Undo::INSERT);
766 mathcursor->insert(new MathSpaceInset(1));
772 bv->owner()->message(_("Invalid action in math mode!"));
776 case LFUN_MATH_HALIGN:
778 bv->lockedInsetStoreUndo(Undo::INSERT);
779 lyxerr << "handling halign '" << arg << "'\n";
781 MathArrayInset * p = matrixpar(idx);
784 p->halign(arg.size() ? arg[0] : 'c', p->col(idx));
789 case LFUN_MATH_VALIGN:
791 bv->lockedInsetStoreUndo(Undo::INSERT);
792 lyxerr << "handling valign '" << arg << "'\n";
794 MathArrayInset * p = matrixpar(idx);
797 p->valign(arg.size() ? arg[0] : 'c');
802 case LFUN_MATH_ROW_INSERT:
804 bv->lockedInsetStoreUndo(Undo::INSERT);
806 MathArrayInset * p = matrixpar(idx);
807 lyxerr << " calling LFUN_MATH_ROW_INSERT on " << p << endl;
810 p->addRow(p->row(idx));
815 case LFUN_MATH_ROW_DELETE:
817 bv->lockedInsetStoreUndo(Undo::INSERT);
819 MathArrayInset * p = matrixpar(idx);
820 lyxerr << " calling LFUN_MATH_ROW_DELETE on " << p << endl;
823 p->delRow(p->row(idx));
828 case LFUN_MATH_COLUMN_INSERT:
830 bv->lockedInsetStoreUndo(Undo::INSERT);
832 MathArrayInset * p = matrixpar(idx);
835 p->addCol(p->col(idx));
840 case LFUN_MATH_COLUMN_DELETE:
842 bv->lockedInsetStoreUndo(Undo::INSERT);
844 MathArrayInset * p = matrixpar(idx);
847 p->delCol(p->col(idx));
852 case LFUN_EXEC_COMMAND:
853 result = UNDISPATCHED;
857 if ((action == -1 || action == LFUN_SELFINSERT) && !arg.empty()) {
858 unsigned char c = arg[0];
859 lyxerr << "char: '" << c << "' int: " << int(c) << endl;
860 //owner_->getIntl()->getTrans().TranslateAndInsert(c, lt);
861 lyxerr << "trans: '" << c << "' int: " << int(c) << endl;
862 bv->lockedInsetStoreUndo(Undo::INSERT);
864 if (c == ' ' && mathcursor->getAccent() == LM_hat) {
866 mathcursor->setAccent(0);
869 if (c == 0) { // Dead key, do nothing
870 //lyxerr << "deadkey" << endl;
875 if (mathcursor->getLastCode() == LM_TC_TEX) {
876 mathcursor->MacroModeOpen();
877 mathcursor->clearLastCode();
879 } else if (!varcode) {
880 short f = mathcursor->getLastCode() ?
881 mathcursor->getLastCode() :
882 mathcursor->nextCode();
883 varcode = MathIsAlphaFont(f) ?
884 static_cast<MathTextCodes>(f) :
888 // lyxerr << "Varcode << vardoce;
889 MathTextCodes char_code = varcode;
892 {'A', 'B', 'X', 0 , 'E', 0 , 0 , 'H', 'I', 0 ,
893 'K', 0 , 'M', 'N', 'O', 0 , 0 , 'P', 0 , 'T',
894 'Y', 0, 0, 0, 0 , 'Z' };
896 if ('A' <= c && c <= 'Z' && greek[c - 'A']) {
897 char_code = LM_TC_RM;
900 char_code = LM_TC_SYMB;
903 mathcursor->insert(c, char_code);
905 if (greek_kb_flag && char_code == LM_TC_RM )
906 mathcursor->setLastCode(LM_TC_VAR);
910 if (greek_kb_flag < 2)
913 } else if (strchr("!,:;{}", c) && (varcode == LM_TC_TEX||was_macro)) {
914 mathcursor->insert(c, LM_TC_TEX);
916 mathcursor->insert('}', LM_TC_TEX);
919 mathcursor->clearLastCode();
920 // varcode = LM_TC_MIN;
921 } else if (c == '_' && varcode == LM_TC_TEX) {
922 mathcursor->insert(c, LM_TC_SPECIAL);
923 mathcursor->clearLastCode();
924 // varcode = LM_TC_MIN;
925 } else if ('0' <= c && c <= '9' && (varcode == LM_TC_TEX||was_macro)) {
926 mathcursor->MacroModeOpen();
927 mathcursor->clearLastCode();
928 mathcursor->insert(c, LM_TC_MIN);
929 } else if (('0' <= c && c <= '9') || strchr(";:!|[]().,?", c)) {
930 MathTextCodes code = mathcursor->getLastCode();
931 if (code != LM_TC_TEXTRM)
933 mathcursor->insert(c, code);
934 } else if (strchr("+/-*<>=", c)) {
935 MathTextCodes code = mathcursor->getLastCode();
936 if (code != LM_TC_TEXTRM)
938 mathcursor->insert(c, code);
939 } else if (strchr(latex_special_chars, c) && c!= '_') {
940 MathTextCodes code = mathcursor->getLastCode();
941 if (code != LM_TC_TEXTRM)
942 code = LM_TC_SPECIAL;
943 mathcursor->insert(c, code);
944 } else if (c == '_' || c == '^') {
948 mathcursor->Interpret(s);
949 } else if (c == ' ') {
951 short f = (mathcursor->getLastCode()) ?
952 mathcursor->getLastCode() :
953 mathcursor->nextCode();
954 varcode = MathIsAlphaFont(f) ?
955 static_cast<MathTextCodes>(f) :
959 if (varcode == LM_TC_TEXTRM) {
960 mathcursor->insert(c, LM_TC_TEXTRM);
961 } else if (was_macro) {
962 mathcursor->MacroModeClose();
964 int isp = (sp->GetSpace()<5) ? sp->GetSpace()+1: 0;
968 if (!mathcursor->pop())
970 mathcursor->plainRight();
972 } else if (c == '\'' || c == '@') {
973 mathcursor->insert (c, LM_TC_VAR);
974 } else if (c == '\\') {
976 mathcursor->MacroModeClose();
977 bv->owner()->message(_("TeX mode"));
978 mathcursor->setLastCode(LM_TC_TEX);
981 } else if (action == LFUN_MATH_PANEL) {
982 result = UNDISPATCHED;
984 lyxerr << "Closed by action " << action << endl;
990 mathcursor->normalize();
992 if (mathcursor && was_macro != mathcursor->InMacroMode()
994 && action != LFUN_BACKSPACE)
1000 if (sp && !space_on)
1003 if (mathcursor && (mathcursor->Selection() || was_selection))
1004 toggleInsetSelection(bv);
1006 if (result == DISPATCHED || result == DISPATCHED_NOUPDATE ||
1007 result == UNDISPATCHED)
1008 showInsetCursor(bv);
1010 bv->unlockInset(this);
1012 return result; // original version
1017 /* FIXME: math-greek-toggle seems to work OK, but math-greek doesn't turn
1019 bool math_insert_greek(BufferView * bv, char c)
1021 if (!bv->available())
1029 if (!bv->theLockingInset() || bv->theLockingInset()->isTextInset()) {
1030 int greek_kb_flag_save = greek_kb_flag;
1031 InsetFormula * new_inset = new InsetFormula();
1032 bv->beforeChange(bv->text);
1033 if (!bv->insertInset(new_inset)) {
1038 new_inset->edit(bv, 0, 0, 0);
1039 new_inset->localDispatch(bv, LFUN_SELFINSERT, tmp);
1040 if (greek_kb_flag_save < 2) {
1041 bv->unlockInset(new_inset); // bv->theLockingInset());
1042 bv->text->cursorRight(bv, true);
1045 if (bv->theLockingInset()->lyxCode() == Inset::MATH_CODE ||
1046 bv->theLockingInset()->lyxCode() == Inset::MATHMACRO_CODE)
1047 static_cast<InsetFormula*>(bv->theLockingInset())->localDispatch(bv, LFUN_SELFINSERT, tmp);
1049 lyxerr << "Math error: attempt to write on a wrong "
1050 "class of inset." << endl;
1056 Inset::Code InsetFormulaBase::lyxCode() const
1058 return Inset::MATH_CODE;
1062 LyXFont const InsetFormulaBase::convertFont(LyXFont const & f) const
1064 // We have already discussed what was here
1067 font.setLatex(LyXFont::OFF);
1072 MathInset * InsetFormulaBase::par() const
1078 void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
1080 if (bv->available()) {
1081 // Feature "Read math inset from selection" disabled.
1082 // // use selection if available..
1084 // if (action == LFUN_MATH_IMPORT_SELECTION)
1087 // sel = bv->getLyXText()->selectionAsString(bv->buffer());
1090 // if (sel.empty()) {
1091 f = new InsetFormula;
1092 openNewInset(bv, f);
1093 // don't do that also for LFUN_MATH_MODE unless you want end up with
1094 // always changing to mathrm when opening an inlined inset
1095 // -- I really hate "LyXfunc overloading"...
1097 f->localDispatch(bv, LFUN_MATH_DISPLAY, string());
1098 f->localDispatch(bv, LFUN_INSERT_MATH, arg);
1100 // f = new InsetFormula(sel);
1101 // bv->getLyXText()->cutSelection(bv);
1102 // openNewInset(bv, f);
1105 bv->owner()->getLyXFunc()->setMessage(N_("Math editor mode"));
1108 void mathDispatchMathDisplay(BufferView * bv, string const & arg)
1110 mathDispatchCreation(bv, arg, true);
1113 void mathDispatchMathMode(BufferView * bv, string const & arg)
1115 mathDispatchCreation(bv, arg, false);
1118 void mathDispatchMathImportSelection(BufferView * bv, string const & arg)
1120 mathDispatchCreation(bv, arg, true);
1123 void mathDispatchMathMacro(BufferView * bv, string const & arg)
1125 if (bv->available()) {
1128 bv->owner()->getLyXFunc()->setErrorMessage(N_("Missing argument"));
1130 string const s1 = token(s, ' ', 1);
1131 int const na = s1.empty() ? 0 : lyx::atoi(s1);
1132 openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na));
1137 void mathDispatchMathDelim(BufferView * bv, string const & arg)
1139 if (bv->available()) {
1140 if (openNewInset(bv, new InsetFormula))
1141 bv->theLockingInset()->localDispatch(bv, LFUN_MATH_DELIM, arg);
1146 void mathDispatchInsertMatrix(BufferView * bv, string const & arg)
1148 if (bv->available()) {
1149 if (openNewInset(bv, new InsetFormula))
1150 bv->theLockingInset()->localDispatch(bv, LFUN_INSERT_MATRIX, arg);
1154 void mathDispatchInsertMath(BufferView * bv, string const & arg)
1156 if (bv->available()) {
1157 if (arg.size() && arg[0] == '\\') {
1158 InsetFormula * f = new InsetFormula(arg);
1159 openNewInset(bv, f);
1161 return mathDispatchMathDisplay(bv, arg);