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"
22 #pragma implementation
26 #include "formulamacro.h"
28 #include "funcrequest.h"
29 #include "BufferView.h"
33 #include "LaTeXFeatures.h"
35 #include "math_support.h"
36 #include "math_metricsinfo.h"
37 #include "support/lstrings.h"
38 #include "frontends/LyXView.h"
39 #include "frontends/font_metrics.h"
40 #include "frontends/mouse_state.h"
42 #include "math_arrayinset.h"
43 #include "math_charinset.h"
44 #include "math_deliminset.h"
45 #include "math_cursor.h"
46 #include "math_factory.h"
47 #include "math_fontinset.h"
48 #include "math_hullinset.h"
49 #include "math_iterator.h"
50 #include "math_macrotable.h"
51 #include "math_parser.h"
53 #include "math_spaceinset.h"
54 #include "undo_funcs.h"
55 #include "textpainter.h"
56 #include "frontends/Dialogs.h"
58 #include "insets/insetcommandparams.h"
59 #include "ref_inset.h"
66 MathCursor * mathcursor = 0;
77 bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
79 if (!bv->insertInset(new_inset)) {
83 new_inset->edit(bv, true);
92 InsetFormulaBase::InsetFormulaBase()
93 : font_(), xo_(0), yo_(0)
95 // This is needed as long the math parser is not re-entrant
97 //lyxerr << "sizeof MathInset: " << sizeof(MathInset) << "\n";
98 //lyxerr << "sizeof MathMetricsInfo: " << sizeof(MathMetricsInfo) << "\n";
99 //lyxerr << "sizeof MathCharInset: " << sizeof(MathCharInset) << "\n";
100 //lyxerr << "sizeof LyXFont: " << sizeof(LyXFont) << "\n";
104 // simply scrap this function if you want
105 void InsetFormulaBase::mutateToText()
108 // translate to latex
110 latex(NULL, os, false, false);
111 string str = os.str();
114 LyXText * lt = view_->getLyXText();
115 string::const_iterator cit = str.begin();
116 string::const_iterator end = str.end();
117 for (; cit != end; ++cit)
118 view_->owner()->getIntl()->getTransManager().TranslateAndInsert(*cit, lt);
121 //view_->owner()->dispatch(LFUN_ESCAPE);
126 void InsetFormulaBase::handleFont
127 (BufferView * bv, string const & arg, string const & font)
129 bv->lockedInsetStoreUndo(Undo::EDIT);
130 bool sel = mathcursor->selection();
132 updateLocal(bv, true);
133 mathcursor->handleNest(createMathInset(font));
134 mathcursor->insert(arg);
136 updateLocal(bv, false);
140 // Check if uses AMS macros
141 void InsetFormulaBase::validate(LaTeXFeatures &) const
145 void InsetFormulaBase::metrics(BufferView * bv, LyXFont const & f) const
152 void InsetFormulaBase::metrics(BufferView * bv) const
155 view_ = bv->owner()->view();
157 mi.base.style = LM_ST_TEXT;
158 mi.base.font = font_;
159 mi.base.font.setColor(LColor::math);
164 string const InsetFormulaBase::editMessage() const
166 return _("Math editor mode");
170 void InsetFormulaBase::edit(BufferView * bv, int x, int y, mouse_button::state)
172 if (!bv->lockInset(this))
173 lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
174 releaseMathCursor(bv);
175 mathcursor = new MathCursor(this, true);
177 mathcursor->setPos(x, y);
178 //lyxerr << "setting pos to " << x << "," << y << "\n";
180 // if that is removed, we won't get the magenta box when entering an
181 // inset for the first time
182 bv->updateInset(this, false);
186 void InsetFormulaBase::edit(BufferView * bv, bool front)
188 if (!bv->lockInset(this))
189 lyxerr << "Cannot lock math inset in edit call!\n";
190 releaseMathCursor(bv);
191 mathcursor = new MathCursor(this, front);
193 bv->updateInset(this, false);
197 void InsetFormulaBase::insetUnlock(BufferView * bv)
200 if (mathcursor->inMacroMode()) {
201 mathcursor->macroModeClose();
202 updateLocal(bv, true);
204 releaseMathCursor(bv);
207 bv->updateInset(this, false);
211 void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
213 // calling metrics here destroys the cached xo,yo positions e.g. in
214 // MathParboxinset. And it would be too expensive anyway...
216 mathcursor->getPos(x, y);
219 //lyxerr << "getCursorPos: " << x << " " << y << "\n";
223 void InsetFormulaBase::toggleInsetCursor(BufferView * bv)
225 //lyxerr << "toggleInsetCursor: " << isCursorVisible() << "\n";
226 if (isCursorVisible())
233 void InsetFormulaBase::showInsetCursor(BufferView * bv, bool)
235 if (isCursorVisible())
239 getCursorPos(bv, x, y);
240 math_font_max_dim(font_, asc, des);
241 bv->showLockedInsetCursor(x, y, asc, des);
242 setCursorVisible(true);
243 //lyxerr << "showInsetCursor: " << x << " " << y << "\n";
247 void InsetFormulaBase::hideInsetCursor(BufferView * bv)
249 if (!isCursorVisible())
251 bv->hideLockedInsetCursor();
252 setCursorVisible(false);
253 //lyxerr << "hideInsetCursor: \n";
257 void InsetFormulaBase::fitInsetCursor(BufferView * bv) const
262 math_font_max_dim(font_, asc, des);
263 getCursorPos(bv, x, y);
265 //lyxerr << "fitInsetCursor: x: " << x << " y: " << y << " yo: " << yo_ << "\n";
266 bv->fitLockedInsetCursor(x, y, asc, des);
270 void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
273 bv->updateInset(this, false);
277 vector<string> const InsetFormulaBase::getLabelList() const
279 return vector<string>();
283 void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
285 bv->updateInset(this, dirty);
289 bool InsetFormulaBase::insetButtonRelease(BufferView * bv,
290 int x, int y, mouse_button::state button)
295 //lyxerr << "insetButtonRelease: " << x << " " << y << "\n";
298 bv->updateInset(this, false);
300 if (button == mouse_button::button3) {
301 // try to dispatch to enclosed insets first
302 if (mathcursor->dispatch(FuncRequest(bv, LFUN_MOUSE_RELEASE, x, y, 3)))
305 // launch math panel for right mouse button
306 bv->owner()->getDialogs().showMathPanel();
310 if (button == mouse_button::button1) {
311 // try to dispatch to enclosed insets first
312 if (mathcursor->dispatch(FuncRequest(bv, LFUN_MOUSE_RELEASE, x, y, 1)))
315 // try to set the cursor
317 //mathcursor = new MathCursor(this, x == 0);
319 //mathcursor->setPos(x + xo_, y + yo_);
326 void InsetFormulaBase::insetButtonPress(BufferView * bv,
327 int x, int y, mouse_button::state button)
329 //lyxerr << "insetButtonPress: "
330 // << x << " " << y << " but: " << button << "\n";
331 //lyxerr << "formula: ";
334 releaseMathCursor(bv);
335 mathcursor = new MathCursor(this, x == 0);
337 if (button == mouse_button::button1) {
338 // just set the cursor here
339 //lyxerr << "setting cursor\n";
343 mathcursor->selClear();
344 mathcursor->setPos(x + xo_, y + yo_);
346 if (mathcursor->dispatch(FuncRequest(bv, LFUN_MOUSE_PRESS, x, y, 1))) {
352 if (button == mouse_button::button3) {
353 if (mathcursor->dispatch(FuncRequest(bv, LFUN_MOUSE_PRESS, x, y, 3))) {
358 bv->updateInset(this, false);
362 void InsetFormulaBase::insetMotionNotify(BufferView * bv,
363 int x, int y, mouse_button::state button)
368 if (button == mouse_button::button1)
369 if (mathcursor->dispatch(FuncRequest(bv, LFUN_MOUSE_MOTION, x, y, 1)))
372 if (button == mouse_button::button3)
373 if (mathcursor->dispatch(FuncRequest(bv, LFUN_MOUSE_MOTION, x, y, 3)))
376 if (abs(x - first_x) < 2 && abs(y - first_y) < 2) {
377 //lyxerr << "insetMotionNotify: ignored\n";
383 if (!mathcursor->selection())
384 mathcursor->selStart();
386 //lyxerr << "insetMotionNotify: " << x + xo_ << ' ' << y + yo_
387 // << ' ' << button << "\n";
389 mathcursor->setPos(x + xo_, y + yo_);
391 bv->updateInset(this, false);
395 UpdatableInset::RESULT
396 InsetFormulaBase::localDispatch(FuncRequest const & ev)
398 //lyxerr << "InsetFormulaBase::localDispatch: act: " << action
399 // << " arg: '" << arg
400 // << "' cursor: " << mathcursor << "\n";
405 BufferView * bv = ev.view();
406 string argument = ev.argument;
407 RESULT result = DISPATCHED;
409 bool was_macro = mathcursor->inMacroMode();
410 bool was_selection = mathcursor->selection();
414 mathcursor->normalize();
419 case LFUN_MATH_NUMBER:
420 case LFUN_MATH_NONUMBER:
423 case LFUN_DELETE_LINE_FORWARD:
424 bv->lockedInsetStoreUndo(Undo::EDIT);
425 mathcursor->dispatch(ev);
426 updateLocal(bv, true);
429 case LFUN_WORDRIGHTSEL:
431 sel = true; // fall through...
433 result = mathcursor->right(sel) ? DISPATCHED : FINISHED_RIGHT;
434 //lyxerr << "calling scroll 20\n";
436 updateLocal(bv, false);
437 // write something to the minibuffer
438 //bv->owner()->message(mathcursor->info());
441 case LFUN_WORDLEFTSEL:
443 sel = true; // fall through
445 result = mathcursor->left(sel) ? DISPATCHED : FINISHED;
446 updateLocal(bv, false);
450 sel = true; // fall through
452 result = mathcursor->up(sel) ? DISPATCHED : FINISHED_UP;
453 updateLocal(bv, false);
457 sel = true; // fall through
459 result = mathcursor->down(sel) ? DISPATCHED : FINISHED_DOWN;
460 updateLocal(bv, false);
464 sel = true; // fall through
466 result = mathcursor->home(sel) ? DISPATCHED : FINISHED;
467 updateLocal(bv, false);
471 sel = true; // fall through
473 result = mathcursor->end(sel) ? DISPATCHED : FINISHED_RIGHT;
474 updateLocal(bv, false);
479 result = FINISHED_UP;
480 updateLocal(bv, false);
485 result = FINISHED_DOWN;
486 updateLocal(bv, false);
490 mathcursor->idxNext();
491 updateLocal(bv, false);
495 mathcursor->idxPrev();
496 updateLocal(bv, false);
499 case LFUN_DELETE_WORD_BACKWARD:
501 bv->lockedInsetStoreUndo(Undo::DELETE);
502 mathcursor->backspace();
503 updateLocal(bv, true);
506 case LFUN_DELETE_WORD_FORWARD:
508 bv->lockedInsetStoreUndo(Undo::DELETE);
510 bv->updateInset(this, true);
514 // sprintf(dispatch_buffer, "%d %d",);
515 // dispatch_result = dispatch_buffer;
518 lyxerr << "LFUN_SETXY broken!\n";
521 istringstream is(ev.argument.c_str());
523 mathcursor->setPos(x, y);
524 updateLocal(bv, false);
530 mathcursor->macroModeClose();
531 bv->lockedInsetStoreUndo(Undo::EDIT);
532 mathcursor->selPaste();
533 updateLocal(bv, true);
537 bv->lockedInsetStoreUndo(Undo::DELETE);
538 mathcursor->selCut();
539 updateLocal(bv, true);
543 mathcursor->selCopy();
547 // Special casing for superscript in case of LyX handling
549 case LFUN_CIRCUMFLEX:
550 if (ev.argument.empty()) {
551 // do superscript if LyX handles
553 bv->lockedInsetStoreUndo(Undo::EDIT);
554 mathcursor->script(true);
555 updateLocal(bv, true);
572 case LFUN_HUNG_UMLAUT:
576 case LFUN_GREEK_TOGGLE: handleFont(bv, ev.argument, "lyxgreek"); break;
577 case LFUN_BOLD: handleFont(bv, ev.argument, "textbf"); break;
578 case LFUN_SANS: handleFont(bv, ev.argument, "textsf"); break;
579 case LFUN_EMPH: handleFont(bv, ev.argument, "mathcal"); break;
580 case LFUN_ROMAN: handleFont(bv, ev.argument, "mathrm"); break;
581 case LFUN_CODE: handleFont(bv, ev.argument, "texttt"); break;
582 case LFUN_FRAK: handleFont(bv, ev.argument, "mathfrak"); break;
583 case LFUN_ITAL: handleFont(bv, ev.argument, "mathit"); break;
584 case LFUN_NOUN: handleFont(bv, ev.argument, "mathbb"); break;
585 case LFUN_DEFAULT: handleFont(bv, ev.argument, "textnormal"); break;
586 case LFUN_FREE: handleFont(bv, ev.argument, "textrm"); break;
589 handleFont(bv, ev.argument, "lyxgreek1");
590 if (ev.argument.size())
591 mathcursor->interpret(ev.argument);
595 if (mathcursor->currentMode()) {
596 handleFont(bv, ev.argument, "textrm");
598 mathcursor->niceInsert(MathAtom(new MathHullInset("simple")));
599 updateLocal(bv, true);
601 //bv->owner()->message(_("math text mode toggled"));
604 case LFUN_MATH_LIMITS:
605 bv->lockedInsetStoreUndo(Undo::EDIT);
606 if (mathcursor->toggleLimits())
607 updateLocal(bv, true);
613 bv->lockedInsetStoreUndo(Undo::EDIT);
614 mathcursor->setSize(arg);
615 updateLocal(bv, true);
620 case LFUN_INSERT_MATRIX:
621 if (!ev.argument.empty()) {
622 bv->lockedInsetStoreUndo(Undo::EDIT);
623 mathcursor->interpret("matrix " + ev.argument);
624 updateLocal(bv, true);
628 case LFUN_SUPERSCRIPT:
631 bv->lockedInsetStoreUndo(Undo::EDIT);
632 mathcursor->script(ev.action == LFUN_SUPERSCRIPT);
633 updateLocal(bv, true);
637 case LFUN_MATH_DELIM:
639 //lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
641 string rs = split(ev.argument, ls, ' ');
642 // Reasonable default values
648 bv->lockedInsetStoreUndo(Undo::EDIT);
649 mathcursor->handleNest(MathAtom(new MathDelimInset(ls, rs)));
650 updateLocal(bv, true);
654 case LFUN_PROTECTEDSPACE:
655 case LFUN_MATH_SPACE:
656 bv->lockedInsetStoreUndo(Undo::EDIT);
657 mathcursor->insert(MathAtom(new MathSpaceInset(",")));
658 updateLocal(bv, true);
662 bv->owner()->message(_("Invalid action in math mode!"));
666 case LFUN_MATH_HALIGN:
667 case LFUN_MATH_VALIGN:
668 case LFUN_MATH_ROW_INSERT:
669 case LFUN_MATH_ROW_DELETE:
670 case LFUN_MATH_COLUMN_INSERT:
671 case LFUN_MATH_COLUMN_DELETE:
673 MathInset::idx_type idx = 0;
674 MathGridInset * p = mathcursor ? mathcursor->enclosingGrid(idx) : 0;
676 mathcursor->popToEnclosingGrid();
677 bv->lockedInsetStoreUndo(Undo::EDIT);
678 char align = ev.argument.size() ? ev.argument[0] : 'c';
680 case LFUN_MATH_HALIGN: p->halign(align, p->col(idx)); break;
681 case LFUN_MATH_VALIGN: p->valign(align); break;
682 case LFUN_MATH_ROW_INSERT: p->addRow(p->row(idx)); break;
683 case LFUN_MATH_ROW_DELETE: p->delRow(p->row(idx)); break;
684 case LFUN_MATH_COLUMN_INSERT: p->addFancyCol(p->col(idx)); break;
685 case LFUN_MATH_COLUMN_DELETE: p->delFancyCol(p->col(idx)); break;
688 updateLocal(bv, true);
693 case LFUN_EXEC_COMMAND:
694 result = UNDISPATCHED;
698 // interpret this as if a backslash was typed
699 bv->lockedInsetStoreUndo(Undo::EDIT);
700 mathcursor->interpret('\\');
701 updateLocal(bv, true);
704 case LFUN_BREAKPARAGRAPH:
705 case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
706 case LFUN_BREAKPARAGRAPH_SKIP:
711 case LFUN_INSERT_MATH:
712 case LFUN_SELFINSERT:
713 if (!argument.empty()) {
714 bv->lockedInsetStoreUndo(Undo::EDIT);
715 if (argument.size() == 1)
716 result = mathcursor->interpret(argument[0]) ? DISPATCHED : FINISHED_RIGHT;
718 result = mathcursor->interpret(argument) ? DISPATCHED : FINISHED_RIGHT;
719 updateLocal(bv, true);
723 case LFUN_MATH_PANEL:
724 result = UNDISPATCHED;
728 if (mathcursor->selection())
729 mathcursor->selClear();
731 result = UNDISPATCHED;
734 case LFUN_INSET_TOGGLE:
735 mathcursor->insetToggle();
736 updateLocal(bv, true);
739 case LFUN_REF_INSERT:
740 //if (argument.empty()) {
741 // InsetCommandParams p("ref");
742 // owner_->getDialogs().createRef(p.getAsString());
744 // InsetCommandParams p;
745 // p.setFromString(argument);
747 // InsetRef * inset = new InsetRef(p, *buffer_);
748 // if (!insertInset(inset))
751 // updateInset(inset, true);
754 if (ev.argument.empty()) {
755 InsetCommandParams p("ref");
756 bv->owner()->getDialogs().createRef(p.getAsString());
758 //mathcursor->handleNest(new InsetRef2);
759 //mathcursor->insert(arg);
760 mathcursor->insert(MathAtom(new RefInset(ev.argument)));
762 updateLocal(bv, true);
766 result = UNDISPATCHED;
769 mathcursor->normalize();
772 lyx::Assert(mathcursor);
774 if (mathcursor->selection() || was_selection)
775 toggleInsetSelection(bv);
777 if (result == DISPATCHED || result == DISPATCHED_NOUPDATE ||
778 result == UNDISPATCHED) {
783 releaseMathCursor(bv);
784 bv->unlockInset(this);
787 return result; // original version
791 void InsetFormulaBase::revealCodes(BufferView * bv) const
795 bv->owner()->message(mathcursor->info());
798 // write something to the minibuffer
799 // translate to latex
800 mathcursor->markInsert();
803 string str = os.str();
804 mathcursor->markErase();
805 string::size_type pos = 0;
807 for (string::iterator it = str.begin(); it != str.end(); ++it) {
810 else if (*it == '\0') {
812 pos = it - str.begin();
818 res = res.substr(pos - 30);
820 res = res.substr(0, 60);
821 bv->owner()->message(res);
826 Inset::Code InsetFormulaBase::lyxCode() const
828 return Inset::MATH_CODE;
832 int InsetFormulaBase::ylow() const
834 return yo_ - ascent(view(), font_);
838 int InsetFormulaBase::yhigh() const
840 return yo_ + descent(view(), font_);
844 int InsetFormulaBase::xlow() const
850 int InsetFormulaBase::xhigh() const
852 return xo_ + width(view(), font_);
856 /////////////////////////////////////////////////////////////////////
859 bool InsetFormulaBase::searchForward(BufferView * bv, string const & str,
865 static InsetFormulaBase * lastformula = 0;
866 static MathIterator current = MathIterator(ibegin(par().nucleus()));
868 static string laststr;
870 if (lastformula != this || laststr != str) {
871 //lyxerr << "reset lastformula to " << this << "\n";
874 current = ibegin(par().nucleus());
876 mathed_parse_cell(ar, str);
880 //lyxerr << "searching '" << str << "' in " << this << ar << endl;
882 for (MathIterator it = current; it != iend(par().nucleus()); ++it) {
883 if (it.cell().matchpart(ar, it.back().pos_)) {
884 bv->unlockInset(bv->theLockingInset());
885 if (!bv->lockInset(this)) {
886 lyxerr << "Cannot lock inset" << endl;
890 mathcursor = new MathCursor(this, true);
892 mathcursor->setSelection(it, ar.size());
895 updateLocal(bv, false);
900 //lyxerr << "not found!\n";
906 bool InsetFormulaBase::searchBackward(BufferView * bv, string const & what,
909 lyxerr[Debug::MATHED] << "searching backward not implemented in mathed\n";
910 return searchForward(bv, what, a, b);
914 /////////////////////////////////////////////////////////////////////
917 void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
919 if (!bv->available())
922 // use selection if available..
924 //if (action == LFUN_MATH_IMPORT_SELECTION)
928 string sel = bv->getLyXText()->selectionAsString(bv->buffer(), false);
931 InsetFormula * f = new InsetFormula(bv);
932 if (openNewInset(bv, f)) {
934 // don't do that also for LFUN_MATH_MODE unless you want end up with
935 // always changing to mathrm when opening an inlined inset
936 // -- I really hate "LyXfunc overloading"...
938 f->localDispatch(FuncRequest(bv, LFUN_MATH_DISPLAY));
939 f->localDispatch(FuncRequest(bv, LFUN_INSERT_MATH, arg));
942 // create a macro if we see "\\newcommand" somewhere, and an ordinary
944 InsetFormulaBase * f;
945 if (sel.find("\\newcommand") == string::npos &&
946 sel.find("\\def") == string::npos)
947 f = new InsetFormula(sel);
949 f = new InsetFormulaMacro(sel);
950 bv->getLyXText()->cutSelection(bv);
953 bv->owner()->getLyXFunc().setMessage(N_("Math editor mode"));
957 void mathDispatchMathDisplay(BufferView * bv, string const & arg)
959 mathDispatchCreation(bv, arg, true);
963 void mathDispatchMathMode(BufferView * bv, string const & arg)
965 mathDispatchCreation(bv, arg, false);
969 void mathDispatchMathImportSelection(BufferView * bv, string const & arg)
971 mathDispatchCreation(bv, arg, true);
975 void mathDispatchMathMacro(BufferView * bv, string const & arg)
977 if (!bv->available())
980 bv->owner()->getLyXFunc().setErrorMessage(N_("Missing argument"));
983 string const s1 = token(s, ' ', 1);
984 int const na = s1.empty() ? 0 : lyx::atoi(s1);
985 openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na));
990 void mathDispatchMathDelim(BufferView * bv, string const & arg)
992 if (!bv->available())
994 InsetFormula * f = new InsetFormula(bv);
995 if (openNewInset(bv, f)) {
997 bv->theLockingInset()->localDispatch(FuncRequest(bv, LFUN_MATH_DELIM, arg));
1002 void mathDispatchInsertMatrix(BufferView * bv, string const & arg)
1004 if (!bv->available())
1006 InsetFormula * f = new InsetFormula(bv);
1007 if (openNewInset(bv, f)) {
1008 f->mutate("simple");
1009 bv->theLockingInset()->localDispatch(FuncRequest(bv, LFUN_INSERT_MATRIX, arg));
1014 void mathDispatchInsertMath(BufferView * bv, string const & arg)
1016 if (!bv->available())
1018 InsetFormula * f = new InsetFormula(bv);
1019 if (openNewInset(bv, f)) {
1020 f->mutate("simple");
1021 bv->theLockingInset()->localDispatch(FuncRequest(bv, LFUN_INSERT_MATH, arg));
1026 void mathDispatchGreek(BufferView * bv, string const & arg)
1028 if (!bv->available())
1030 InsetFormula * f = new InsetFormula(bv);
1031 if (openNewInset(bv, f)) {
1032 f->mutate("simple");
1033 bv->theLockingInset()->localDispatch(FuncRequest(bv, LFUN_GREEK, arg));
1039 void mathDispatch(BufferView *, kb_action, string const &)
1043 void mathDispatch(BufferView *, string const &)