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"
32 #include "LaTeXFeatures.h"
34 #include "math_support.h"
35 #include "math_metricsinfo.h"
36 #include "support/lstrings.h"
37 #include "frontends/LyXView.h"
38 #include "frontends/font_metrics.h"
39 #include "frontends/mouse_state.h"
41 #include "math_arrayinset.h"
42 #include "math_charinset.h"
43 #include "math_deliminset.h"
44 #include "math_cursor.h"
45 #include "math_factory.h"
46 #include "math_fontinset.h"
47 #include "math_hullinset.h"
48 #include "math_iterator.h"
49 #include "math_macrotable.h"
50 #include "math_parser.h"
52 #include "math_spaceinset.h"
53 #include "undo_funcs.h"
54 #include "textpainter.h"
55 #include "frontends/Dialogs.h"
57 #include "insets/insetcommandparams.h"
58 #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 // this whole function is a hack and won't work for incremental font
131 bv->lockedInsetStoreUndo(Undo::EDIT);
132 if (mathcursor->par()->name() == font) {
133 mathcursor->handleFont(font);
134 updateLocal(bv, true);
136 bool sel = mathcursor->selection();
138 updateLocal(bv, true);
139 mathcursor->handleNest(createMathInset(font));
140 mathcursor->insert(arg);
142 updateLocal(bv, false);
147 // Check if uses AMS macros
148 void InsetFormulaBase::validate(LaTeXFeatures &) const
152 void InsetFormulaBase::metrics(BufferView * bv, LyXFont const & f) const
159 void InsetFormulaBase::metrics(BufferView * bv) const
162 view_ = bv->owner()->view();
164 mi.base.style = LM_ST_TEXT;
165 mi.base.font = font_;
166 mi.base.font.setColor(LColor::math);
171 string const InsetFormulaBase::editMessage() const
173 return _("Math editor mode");
177 void InsetFormulaBase::edit(BufferView * bv, int x, int y, mouse_button::state)
179 if (!bv->lockInset(this))
180 lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
181 releaseMathCursor(bv);
182 mathcursor = new MathCursor(this, true);
184 mathcursor->setPos(x + xo_, y + yo_);
185 // if that is removed, we won't get the magenta box when entering an
186 // inset for the first time
187 bv->updateInset(this, false);
191 void InsetFormulaBase::edit(BufferView * bv, bool front)
193 if (!bv->lockInset(this))
194 lyxerr << "Cannot lock math inset in edit call!\n";
195 releaseMathCursor(bv);
196 mathcursor = new MathCursor(this, front);
198 bv->updateInset(this, false);
202 void InsetFormulaBase::insetUnlock(BufferView * bv)
205 if (mathcursor->inMacroMode()) {
206 mathcursor->macroModeClose();
207 updateLocal(bv, true);
209 releaseMathCursor(bv);
212 bv->updateInset(this, false);
216 void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
218 // calling metrics here destroys the cached xo,yo positions e.g. in
219 // MathParboxinset. And it would be too expensive anyway...
222 lyxerr << "getCursorPos - should not happen";
226 mathcursor->getPos(x, y);
227 x = mathcursor->targetX();
230 //lyxerr << "getCursorPos: " << x << ' ' << y << endl;
234 void InsetFormulaBase::toggleInsetCursor(BufferView * bv)
237 lyxerr << "toggleInsetCursor impossible" << endl;
240 //lyxerr << "toggleInsetCursor: " << isCursorVisible() << endl;
241 if (isCursorVisible())
248 void InsetFormulaBase::showInsetCursor(BufferView * bv, bool)
251 lyxerr << "showInsetCursor impossible" << endl;
254 if (isCursorVisible())
257 mathcursor->getPos(x, y);
258 math_font_max_dim(font_, asc, des);
259 bv->showLockedInsetCursor(x, y - yo_, asc, des);
260 setCursorVisible(true);
261 //lyxerr << "showInsetCursor: " << x << ' ' << y << endl;
265 void InsetFormulaBase::hideInsetCursor(BufferView * bv)
269 if (!isCursorVisible())
271 bv->hideLockedInsetCursor();
272 setCursorVisible(false);
273 //lyxerr << "hideInsetCursor: " << endl;
277 void InsetFormulaBase::fitInsetCursor(BufferView * bv) const
282 math_font_max_dim(font_, asc, des);
283 getCursorPos(bv, x, y);
285 //lyxerr << "fitInsetCursor: x: " << x << " y: " << y << " yo: " << yo_ << endl;
286 bv->fitLockedInsetCursor(x, y, asc, des);
290 void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
293 bv->updateInset(this, false);
297 vector<string> const InsetFormulaBase::getLabelList() const
299 return vector<string>();
303 void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
305 bv->updateInset(this, dirty);
309 Inset::RESULT InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
314 BufferView * bv = cmd.view();
317 bv->updateInset(this, false);
318 //lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
320 if (cmd.button() == mouse_button::button3) {
321 // try to dispatch to enclosed insets first
322 if (mathcursor->dispatch(cmd) == MathInset::UNDISPATCHED) {
323 // launch math panel for right mouse button
324 bv->owner()->getDialogs().showMathPanel();
329 if (cmd.button() == mouse_button::button2) {
330 mathcursor->selClear();
331 mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
332 mathcursor->insert(asArray(bv->getClipboard()));
333 bv->updateInset(this, true);
337 if (cmd.button() == mouse_button::button1) {
338 // try to dispatch to enclosed insets first
339 mathcursor->dispatch(cmd);
340 cmd.view()->stuffClipboard(mathcursor->grabSelection());
341 // try to set the cursor
343 //mathcursor = new MathCursor(this, x == 0);
345 //mathcursor->setPos(x + xo_, y + yo_);
353 Inset::RESULT InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
355 BufferView * bv = cmd.view();
356 //lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
358 if (!mathcursor || mathcursor->formula() != this) {
359 lyxerr << "re-create cursor" << endl;
360 releaseMathCursor(bv);
361 mathcursor = new MathCursor(this, cmd.x == 0);
363 mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
366 if (cmd.button() == mouse_button::button3) {
367 mathcursor->dispatch(cmd);
371 if (cmd.button() == mouse_button::button1) {
374 mathcursor->selClear();
375 mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
376 mathcursor->dispatch(cmd);
380 bv->updateInset(this, false);
385 Inset::RESULT InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
390 if (mathcursor->dispatch(FuncRequest(cmd)) != MathInset::UNDISPATCHED)
393 // only select with button 1
394 if (cmd.button() != mouse_button::button1)
397 if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
403 if (!mathcursor->selection())
404 mathcursor->selStart();
406 BufferView * bv = cmd.view();
408 mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
410 bv->updateInset(this, false);
415 Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
417 //lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action
418 // << " arg: '" << cmd.argument
419 // << " x: '" << cmd.x
420 // << " y: '" << cmd.y
421 // << "' button: " << cmd.button() << endl;
423 switch (cmd.action) {
424 case LFUN_MOUSE_PRESS:
425 return lfunMousePress(cmd);
426 case LFUN_MOUSE_MOTION:
427 return lfunMouseMotion(cmd);
428 case LFUN_MOUSE_RELEASE:
429 return lfunMouseRelease(cmd);
430 case LFUN_MOUSE_DOUBLE:
431 //lyxerr << "Mouse double\n";
432 return localDispatch(FuncRequest(LFUN_WORDSEL));
440 BufferView * bv = cmd.view();
441 string argument = cmd.argument;
442 RESULT result = DISPATCHED;
444 bool was_macro = mathcursor->inMacroMode();
445 bool was_selection = mathcursor->selection();
449 mathcursor->normalize();
452 switch (cmd.action) {
454 case LFUN_MATH_MUTATE:
455 case LFUN_MATH_DISPLAY:
456 case LFUN_MATH_NUMBER:
457 case LFUN_MATH_NONUMBER:
460 case LFUN_DELETE_LINE_FORWARD:
461 case LFUN_INSERT_LABEL:
462 case LFUN_MATH_EXTERN:
463 case LFUN_TABULAR_FEATURE:
464 case LFUN_PASTESELECTION:
465 case LFUN_MATH_LIMITS:
466 bv->lockedInsetStoreUndo(Undo::EDIT);
467 mathcursor->dispatch(cmd);
468 updateLocal(bv, true);
472 sel = true; // fall through...
474 result = mathcursor->right(sel) ? DISPATCHED : FINISHED_RIGHT;
475 //lyxerr << "calling scroll 20\n";
477 updateLocal(bv, false);
478 // write something to the minibuffer
479 //bv->owner()->message(mathcursor->info());
483 sel = true; // fall through
485 result = mathcursor->left(sel) ? DISPATCHED : FINISHED;
486 updateLocal(bv, false);
490 sel = true; // fall through
492 result = mathcursor->up(sel) ? DISPATCHED : FINISHED_UP;
493 updateLocal(bv, false);
497 sel = true; // fall through
499 result = mathcursor->down(sel) ? DISPATCHED : FINISHED_DOWN;
500 updateLocal(bv, false);
504 mathcursor->home(false);
505 mathcursor->end(true);
506 updateLocal(bv, false);
510 case LFUN_WORDLEFTSEL:
511 sel = true; // fall through
514 result = mathcursor->home(sel) ? DISPATCHED : FINISHED;
515 updateLocal(bv, false);
519 case LFUN_WORDRIGHTSEL:
520 sel = true; // fall through
523 result = mathcursor->end(sel) ? DISPATCHED : FINISHED_RIGHT;
524 updateLocal(bv, false);
529 case LFUN_BEGINNINGBUFSEL:
530 case LFUN_BEGINNINGBUF:
531 result = FINISHED_UP;
532 updateLocal(bv, false);
539 result = FINISHED_DOWN;
540 updateLocal(bv, false);
544 mathcursor->idxNext();
545 updateLocal(bv, false);
549 mathcursor->idxPrev();
550 updateLocal(bv, false);
553 case LFUN_DELETE_WORD_BACKWARD:
555 bv->lockedInsetStoreUndo(Undo::DELETE);
556 mathcursor->backspace();
557 updateLocal(bv, true);
560 case LFUN_DELETE_WORD_FORWARD:
562 bv->lockedInsetStoreUndo(Undo::DELETE);
564 bv->updateInset(this, true);
568 // sprintf(dispatch_buffer, "%d %d",);
569 // dispatch_result = dispatch_buffer;
572 lyxerr << "LFUN_SETXY broken!\n";
575 istringstream is(cmd.argument.c_str());
577 mathcursor->setPos(x, y);
578 updateLocal(bv, false);
584 mathcursor->macroModeClose();
585 bv->lockedInsetStoreUndo(Undo::EDIT);
586 mathcursor->selPaste();
587 updateLocal(bv, true);
591 bv->lockedInsetStoreUndo(Undo::DELETE);
592 mathcursor->selCut();
593 updateLocal(bv, true);
597 mathcursor->selCopy();
601 // Special casing for superscript in case of LyX handling
603 case LFUN_CIRCUMFLEX:
604 if (cmd.argument.empty()) {
605 // do superscript if LyX handles
607 bv->lockedInsetStoreUndo(Undo::EDIT);
608 mathcursor->script(true);
609 updateLocal(bv, true);
626 case LFUN_HUNG_UMLAUT:
630 case LFUN_GREEK_TOGGLE: handleFont(bv, cmd.argument, "lyxgreek"); break;
631 case LFUN_BOLD: handleFont(bv, cmd.argument, "mathbf"); break;
632 case LFUN_SANS: handleFont(bv, cmd.argument, "mathsf"); break;
633 case LFUN_EMPH: handleFont(bv, cmd.argument, "mathcal"); break;
634 case LFUN_ROMAN: handleFont(bv, cmd.argument, "mathrm"); break;
635 case LFUN_CODE: handleFont(bv, cmd.argument, "texttt"); break;
636 case LFUN_FRAK: handleFont(bv, cmd.argument, "mathfrak"); break;
637 case LFUN_ITAL: handleFont(bv, cmd.argument, "mathit"); break;
638 case LFUN_NOUN: handleFont(bv, cmd.argument, "mathbb"); break;
639 case LFUN_FREE: handleFont(bv, cmd.argument, "textrm"); break;
640 case LFUN_DEFAULT: handleFont(bv, cmd.argument, "textnormal"); break;
643 handleFont(bv, cmd.argument, "lyxgreek1");
644 if (cmd.argument.size())
645 mathcursor->insert(asArray(cmd.argument));
649 if (mathcursor->currentMode() == MathInset::TEXT_MODE) {
650 mathcursor->niceInsert(MathAtom(new MathHullInset("simple")));
651 updateLocal(bv, true);
653 handleFont(bv, cmd.argument, "textrm");
655 //bv->owner()->message(_("math text mode toggled"));
661 bv->lockedInsetStoreUndo(Undo::EDIT);
662 mathcursor->setSize(arg);
663 updateLocal(bv, true);
668 case LFUN_INSERT_MATRIX: {
669 bv->lockedInsetStoreUndo(Undo::EDIT);
674 istringstream is(STRCONV(argument));
675 is >> m >> n >> v_align >> h_align;
679 mathcursor->niceInsert(
680 MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
681 updateLocal(bv, true);
685 case LFUN_SUPERSCRIPT:
688 bv->lockedInsetStoreUndo(Undo::EDIT);
689 mathcursor->script(cmd.action == LFUN_SUPERSCRIPT);
690 updateLocal(bv, true);
694 case LFUN_MATH_DELIM:
696 //lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
698 string rs = split(cmd.argument, ls, ' ');
699 // Reasonable default values
705 bv->lockedInsetStoreUndo(Undo::EDIT);
706 mathcursor->handleNest(MathAtom(new MathDelimInset(ls, rs)));
707 updateLocal(bv, true);
711 case LFUN_PROTECTEDSPACE:
712 case LFUN_MATH_SPACE:
713 bv->lockedInsetStoreUndo(Undo::EDIT);
714 mathcursor->insert(MathAtom(new MathSpaceInset(",")));
715 updateLocal(bv, true);
719 bv->owner()->message(_("Invalid action in math mode!"));
723 case LFUN_EXEC_COMMAND:
724 result = UNDISPATCHED;
728 // interpret this as if a backslash was typed
729 bv->lockedInsetStoreUndo(Undo::EDIT);
730 mathcursor->interpret('\\');
731 updateLocal(bv, true);
734 case LFUN_BREAKPARAGRAPH:
735 case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
736 case LFUN_BREAKPARAGRAPH_SKIP:
740 // FIXME: We probably should swap parts of "math-insert" and "self-insert"
741 // handling such that "self-insert" works on "arbitrary stuff" too, and
742 // math-insert only handles special math things like "matrix".
743 case LFUN_INSERT_MATH:
744 bv->lockedInsetStoreUndo(Undo::EDIT);
745 mathcursor->niceInsert(argument);
746 updateLocal(bv, true);
750 case LFUN_SELFINSERT:
751 if (!argument.empty()) {
752 bv->lockedInsetStoreUndo(Undo::EDIT);
753 if (argument.size() == 1)
754 result = mathcursor->interpret(argument[0]) ? DISPATCHED : FINISHED_RIGHT;
756 mathcursor->insert(asArray(argument));
757 updateLocal(bv, true);
761 case LFUN_MATH_PANEL:
762 result = UNDISPATCHED;
766 if (mathcursor->selection())
767 mathcursor->selClear();
769 result = UNDISPATCHED;
772 case LFUN_INSET_TOGGLE:
773 mathcursor->insetToggle();
774 updateLocal(bv, true);
777 case LFUN_REF_INSERT:
778 //if (argument.empty()) {
779 // InsetCommandParams p("ref");
780 // owner_->getDialogs().createRef(p.getAsString());
782 // InsetCommandParams p;
783 // p.setFromString(argument);
785 // InsetRef * inset = new InsetRef(p, *buffer_);
786 // if (!insertInset(inset))
789 // updateInset(inset, true);
792 if (cmd.argument.empty()) {
793 InsetCommandParams p("ref");
794 bv->owner()->getDialogs().createRef(p.getAsString());
796 //mathcursor->handleNest(new InsetRef2);
797 //mathcursor->insert(arg);
798 mathcursor->insert(MathAtom(new RefInset(cmd.argument)));
800 updateLocal(bv, true);
804 result = UNDISPATCHED;
807 mathcursor->normalize();
810 lyx::Assert(mathcursor);
812 if (mathcursor->selection() || was_selection)
813 toggleInsetSelection(bv);
815 if (result == DISPATCHED || result == DISPATCHED_NOUPDATE ||
816 result == UNDISPATCHED) {
820 cmd.view()->stuffClipboard(mathcursor->grabSelection());
822 releaseMathCursor(bv);
823 bv->unlockInset(this);
826 return result; // original version
830 void InsetFormulaBase::revealCodes(BufferView * bv) const
834 bv->owner()->message(mathcursor->info());
837 // write something to the minibuffer
838 // translate to latex
839 mathcursor->markInsert();
842 string str = os.str();
843 mathcursor->markErase();
844 string::size_type pos = 0;
846 for (string::iterator it = str.begin(); it != str.end(); ++it) {
849 else if (*it == '\0') {
851 pos = it - str.begin();
857 res = res.substr(pos - 30);
859 res = res.substr(0, 60);
860 bv->owner()->message(res);
865 Inset::Code InsetFormulaBase::lyxCode() const
867 return Inset::MATH_CODE;
871 int InsetFormulaBase::ylow() const
873 return yo_ - ascent(view(), font_);
877 int InsetFormulaBase::yhigh() const
879 return yo_ + descent(view(), font_);
883 int InsetFormulaBase::xlow() const
889 int InsetFormulaBase::xhigh() const
891 return xo_ + width(view(), font_);
895 /////////////////////////////////////////////////////////////////////
898 bool InsetFormulaBase::searchForward(BufferView * bv, string const & str,
904 static InsetFormulaBase * lastformula = 0;
905 static MathIterator current = MathIterator(ibegin(par().nucleus()));
907 static string laststr;
909 if (lastformula != this || laststr != str) {
910 //lyxerr << "reset lastformula to " << this << "\n";
913 current = ibegin(par().nucleus());
915 mathed_parse_cell(ar, str);
919 //lyxerr << "searching '" << str << "' in " << this << ar << endl;
921 for (MathIterator it = current; it != iend(par().nucleus()); ++it) {
922 if (it.cell().matchpart(ar, it.back().pos_)) {
923 bv->unlockInset(bv->theLockingInset());
924 if (!bv->lockInset(this)) {
925 lyxerr << "Cannot lock inset" << endl;
929 mathcursor = new MathCursor(this, true);
931 mathcursor->setSelection(it, ar.size());
934 updateLocal(bv, false);
939 //lyxerr << "not found!\n";
945 bool InsetFormulaBase::searchBackward(BufferView * bv, string const & what,
948 lyxerr[Debug::MATHED] << "searching backward not implemented in mathed\n";
949 return searchForward(bv, what, a, b);
953 bool InsetFormulaBase::display() const
955 return par()->asHullInset() && par()->asHullInset()->display();
959 string InsetFormulaBase::selectionAsString() const
961 return mathcursor ? mathcursor->grabSelection() : string();
964 /////////////////////////////////////////////////////////////////////
967 void mathDispatchCreation(FuncRequest const & cmd, bool display)
969 BufferView * bv = cmd.view();
970 // use selection if available..
972 //if (action == LFUN_MATH_IMPORT_SELECTION)
976 string sel = bv->getLyXText()->selectionAsString(bv->buffer(), false);
979 InsetFormula * f = new InsetFormula(bv);
980 if (openNewInset(bv, f)) {
981 bv->theLockingInset()->
982 localDispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
983 // don't do that also for LFUN_MATH_MODE unless you want end up with
984 // always changing to mathrm when opening an inlined inset
985 // -- I really hate "LyXfunc overloading"...
987 f->localDispatch(FuncRequest(bv, LFUN_MATH_DISPLAY));
988 f->localDispatch(FuncRequest(bv, LFUN_INSERT_MATH, cmd.argument));
991 // create a macro if we see "\\newcommand" somewhere, and an ordinary
993 InsetFormulaBase * f;
994 if (sel.find("\\newcommand") == string::npos &&
995 sel.find("\\def") == string::npos)
996 f = new InsetFormula(sel);
998 f = new InsetFormulaMacro(sel);
999 bv->getLyXText()->cutSelection(bv);
1000 openNewInset(bv, f);
1002 cmd.message(N_("Math editor mode"));
1006 void mathDispatch(FuncRequest const & cmd)
1008 BufferView * bv = cmd.view();
1009 if (!bv->available())
1012 switch (cmd.action) {
1014 case LFUN_MATH_DISPLAY:
1015 mathDispatchCreation(cmd, true);
1018 case LFUN_MATH_MODE:
1019 mathDispatchCreation(cmd, false);
1022 case LFUN_MATH_IMPORT_SELECTION:
1023 mathDispatchCreation(cmd, false);
1026 case LFUN_MATH_MACRO:
1027 if (cmd.argument.empty())
1028 cmd.errorMessage(N_("Missing argument"));
1030 string s = cmd.argument;
1031 string const s1 = token(s, ' ', 1);
1032 int const na = s1.empty() ? 0 : lyx::atoi(s1);
1033 openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na));
1038 case LFUN_INSERT_MATH:
1039 case LFUN_INSERT_MATRIX:
1040 case LFUN_MATH_DELIM: {
1041 InsetFormula * f = new InsetFormula(bv);
1042 if (openNewInset(bv, f)) {
1043 bv->theLockingInset()->
1044 localDispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
1045 bv->theLockingInset()->localDispatch(cmd);