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 << "\n";
234 void InsetFormulaBase::toggleInsetCursor(BufferView * bv)
236 //lyxerr << "toggleInsetCursor: " << isCursorVisible() << "\n";
237 if (isCursorVisible())
244 void InsetFormulaBase::showInsetCursor(BufferView * bv, bool)
247 lyxerr << "showInsetCursor impossible\n";
250 if (isCursorVisible())
253 mathcursor->getPos(x, y);
254 math_font_max_dim(font_, asc, des);
255 bv->showLockedInsetCursor(x, y - yo_, asc, des);
256 setCursorVisible(true);
257 //lyxerr << "showInsetCursor: " << x << " " << y << "\n";
261 void InsetFormulaBase::hideInsetCursor(BufferView * bv)
265 if (!isCursorVisible())
267 bv->hideLockedInsetCursor();
268 setCursorVisible(false);
269 //lyxerr << "hideInsetCursor: \n";
273 void InsetFormulaBase::fitInsetCursor(BufferView * bv) const
278 math_font_max_dim(font_, asc, des);
279 getCursorPos(bv, x, y);
281 //lyxerr << "fitInsetCursor: x: " << x << " y: " << y << " yo: " << yo_ << "\n";
282 bv->fitLockedInsetCursor(x, y, asc, des);
286 void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
289 bv->updateInset(this, false);
293 vector<string> const InsetFormulaBase::getLabelList() const
295 return vector<string>();
299 void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
301 bv->updateInset(this, dirty);
305 Inset::RESULT InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
310 BufferView * bv = cmd.view();
313 bv->updateInset(this, false);
314 //lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << "\n";
316 if (cmd.button() == mouse_button::button3) {
317 // try to dispatch to enclosed insets first
318 if (mathcursor->dispatch(cmd) == MathInset::UNDISPATCHED) {
319 // launch math panel for right mouse button
320 bv->owner()->getDialogs().showMathPanel();
325 if (cmd.button() == mouse_button::button2) {
326 mathcursor->selClear();
327 mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
328 mathcursor->insert(asArray(bv->getClipboard()));
329 bv->updateInset(this, true);
333 if (cmd.button() == mouse_button::button1) {
334 // try to dispatch to enclosed insets first
335 mathcursor->dispatch(cmd);
336 cmd.view()->stuffClipboard(mathcursor->grabSelection());
337 // try to set the cursor
339 //mathcursor = new MathCursor(this, x == 0);
341 //mathcursor->setPos(x + xo_, y + yo_);
349 Inset::RESULT InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
351 BufferView * bv = cmd.view();
352 //lyxerr << "lfunMousePress: buttons: " << cmd.button() << "\n";
354 if (!mathcursor || mathcursor->formula() != this) {
355 lyxerr << "re-create cursor\n";
356 releaseMathCursor(bv);
357 mathcursor = new MathCursor(this, cmd.x == 0);
359 mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
362 if (cmd.button() == mouse_button::button3) {
363 mathcursor->dispatch(cmd);
367 if (cmd.button() == mouse_button::button1) {
370 mathcursor->selClear();
371 mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
372 mathcursor->dispatch(cmd);
376 bv->updateInset(this, false);
381 Inset::RESULT InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
386 if (mathcursor->dispatch(FuncRequest(cmd)) != MathInset::UNDISPATCHED)
389 // only select with button 1
390 if (cmd.button() != mouse_button::button1)
393 if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
399 if (!mathcursor->selection())
400 mathcursor->selStart();
402 BufferView * bv = cmd.view();
404 mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
406 bv->updateInset(this, false);
411 Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
413 //lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action
414 // << " arg: '" << cmd.argument
415 // << " x: '" << cmd.x
416 // << " y: '" << cmd.y
417 // << "' button: " << cmd.button() << "\n";
419 switch (cmd.action) {
420 case LFUN_MOUSE_PRESS:
421 return lfunMousePress(cmd);
422 case LFUN_MOUSE_MOTION:
423 return lfunMouseMotion(cmd);
424 case LFUN_MOUSE_RELEASE:
425 return lfunMouseRelease(cmd);
426 case LFUN_MOUSE_DOUBLE:
427 //lyxerr << "Mouse double\n";
428 return localDispatch(FuncRequest(LFUN_WORDSEL));
436 BufferView * bv = cmd.view();
437 string argument = cmd.argument;
438 RESULT result = DISPATCHED;
440 bool was_macro = mathcursor->inMacroMode();
441 bool was_selection = mathcursor->selection();
445 mathcursor->normalize();
448 switch (cmd.action) {
450 case LFUN_MATH_MUTATE:
451 case LFUN_MATH_DISPLAY:
452 case LFUN_MATH_NUMBER:
453 case LFUN_MATH_NONUMBER:
456 case LFUN_DELETE_LINE_FORWARD:
457 case LFUN_INSERT_LABEL:
458 case LFUN_MATH_EXTERN:
459 case LFUN_TABULAR_FEATURE:
460 case LFUN_PASTESELECTION:
461 case LFUN_MATH_LIMITS:
462 bv->lockedInsetStoreUndo(Undo::EDIT);
463 mathcursor->dispatch(cmd);
464 updateLocal(bv, true);
468 sel = true; // fall through...
470 result = mathcursor->right(sel) ? DISPATCHED : FINISHED_RIGHT;
471 //lyxerr << "calling scroll 20\n";
473 updateLocal(bv, false);
474 // write something to the minibuffer
475 //bv->owner()->message(mathcursor->info());
479 sel = true; // fall through
481 result = mathcursor->left(sel) ? DISPATCHED : FINISHED;
482 updateLocal(bv, false);
486 sel = true; // fall through
488 result = mathcursor->up(sel) ? DISPATCHED : FINISHED_UP;
489 updateLocal(bv, false);
493 sel = true; // fall through
495 result = mathcursor->down(sel) ? DISPATCHED : FINISHED_DOWN;
496 updateLocal(bv, false);
500 mathcursor->home(false);
501 mathcursor->end(true);
502 updateLocal(bv, false);
506 case LFUN_WORDLEFTSEL:
507 sel = true; // fall through
510 result = mathcursor->home(sel) ? DISPATCHED : FINISHED;
511 updateLocal(bv, false);
515 case LFUN_WORDRIGHTSEL:
516 sel = true; // fall through
519 result = mathcursor->end(sel) ? DISPATCHED : FINISHED_RIGHT;
520 updateLocal(bv, false);
525 case LFUN_BEGINNINGBUFSEL:
526 case LFUN_BEGINNINGBUF:
527 result = FINISHED_UP;
528 updateLocal(bv, false);
535 result = FINISHED_DOWN;
536 updateLocal(bv, false);
540 mathcursor->idxNext();
541 updateLocal(bv, false);
545 mathcursor->idxPrev();
546 updateLocal(bv, false);
549 case LFUN_DELETE_WORD_BACKWARD:
551 bv->lockedInsetStoreUndo(Undo::DELETE);
552 mathcursor->backspace();
553 updateLocal(bv, true);
556 case LFUN_DELETE_WORD_FORWARD:
558 bv->lockedInsetStoreUndo(Undo::DELETE);
560 bv->updateInset(this, true);
564 // sprintf(dispatch_buffer, "%d %d",);
565 // dispatch_result = dispatch_buffer;
568 lyxerr << "LFUN_SETXY broken!\n";
571 istringstream is(cmd.argument.c_str());
573 mathcursor->setPos(x, y);
574 updateLocal(bv, false);
580 mathcursor->macroModeClose();
581 bv->lockedInsetStoreUndo(Undo::EDIT);
582 mathcursor->selPaste();
583 updateLocal(bv, true);
587 bv->lockedInsetStoreUndo(Undo::DELETE);
588 mathcursor->selCut();
589 updateLocal(bv, true);
593 mathcursor->selCopy();
597 // Special casing for superscript in case of LyX handling
599 case LFUN_CIRCUMFLEX:
600 if (cmd.argument.empty()) {
601 // do superscript if LyX handles
603 bv->lockedInsetStoreUndo(Undo::EDIT);
604 mathcursor->script(true);
605 updateLocal(bv, true);
622 case LFUN_HUNG_UMLAUT:
626 case LFUN_GREEK_TOGGLE: handleFont(bv, cmd.argument, "lyxgreek"); break;
627 case LFUN_BOLD: handleFont(bv, cmd.argument, "mathbf"); break;
628 case LFUN_SANS: handleFont(bv, cmd.argument, "mathsf"); break;
629 case LFUN_EMPH: handleFont(bv, cmd.argument, "mathcal"); break;
630 case LFUN_ROMAN: handleFont(bv, cmd.argument, "mathrm"); break;
631 case LFUN_CODE: handleFont(bv, cmd.argument, "texttt"); break;
632 case LFUN_FRAK: handleFont(bv, cmd.argument, "mathfrak"); break;
633 case LFUN_ITAL: handleFont(bv, cmd.argument, "mathit"); break;
634 case LFUN_NOUN: handleFont(bv, cmd.argument, "mathbb"); break;
635 case LFUN_FREE: handleFont(bv, cmd.argument, "textrm"); break;
636 case LFUN_DEFAULT: handleFont(bv, cmd.argument, "textnormal"); break;
639 handleFont(bv, cmd.argument, "lyxgreek1");
640 if (cmd.argument.size())
641 mathcursor->insert(asArray(cmd.argument));
645 if (mathcursor->currentMode() == MathInset::TEXT_MODE) {
646 mathcursor->niceInsert(MathAtom(new MathHullInset("simple")));
647 updateLocal(bv, true);
649 handleFont(bv, cmd.argument, "textrm");
651 //bv->owner()->message(_("math text mode toggled"));
657 bv->lockedInsetStoreUndo(Undo::EDIT);
658 mathcursor->setSize(arg);
659 updateLocal(bv, true);
664 case LFUN_INSERT_MATRIX: {
665 bv->lockedInsetStoreUndo(Undo::EDIT);
670 istringstream is(STRCONV(argument));
671 is >> m >> n >> v_align >> h_align;
675 mathcursor->niceInsert(
676 MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
677 updateLocal(bv, true);
681 case LFUN_SUPERSCRIPT:
684 bv->lockedInsetStoreUndo(Undo::EDIT);
685 mathcursor->script(cmd.action == LFUN_SUPERSCRIPT);
686 updateLocal(bv, true);
690 case LFUN_MATH_DELIM:
692 //lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
694 string rs = split(cmd.argument, ls, ' ');
695 // Reasonable default values
701 bv->lockedInsetStoreUndo(Undo::EDIT);
702 mathcursor->handleNest(MathAtom(new MathDelimInset(ls, rs)));
703 updateLocal(bv, true);
707 case LFUN_PROTECTEDSPACE:
708 case LFUN_MATH_SPACE:
709 bv->lockedInsetStoreUndo(Undo::EDIT);
710 mathcursor->insert(MathAtom(new MathSpaceInset(",")));
711 updateLocal(bv, true);
715 bv->owner()->message(_("Invalid action in math mode!"));
719 case LFUN_EXEC_COMMAND:
720 result = UNDISPATCHED;
724 // interpret this as if a backslash was typed
725 bv->lockedInsetStoreUndo(Undo::EDIT);
726 mathcursor->interpret('\\');
727 updateLocal(bv, true);
730 case LFUN_BREAKPARAGRAPH:
731 case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
732 case LFUN_BREAKPARAGRAPH_SKIP:
736 // FIXME: We probably should swap parts of "math-insert" and "self-insert"
737 // handling such that "self-insert" works on "arbitrary stuff" too, and
738 // math-insert only handles special math things like "matrix".
739 case LFUN_INSERT_MATH:
740 bv->lockedInsetStoreUndo(Undo::EDIT);
741 mathcursor->niceInsert(argument);
742 updateLocal(bv, true);
746 case LFUN_SELFINSERT:
747 if (!argument.empty()) {
748 bv->lockedInsetStoreUndo(Undo::EDIT);
749 if (argument.size() == 1)
750 result = mathcursor->interpret(argument[0]) ? DISPATCHED : FINISHED_RIGHT;
752 mathcursor->insert(asArray(argument));
753 updateLocal(bv, true);
757 case LFUN_MATH_PANEL:
758 result = UNDISPATCHED;
762 if (mathcursor->selection())
763 mathcursor->selClear();
765 result = UNDISPATCHED;
768 case LFUN_INSET_TOGGLE:
769 mathcursor->insetToggle();
770 updateLocal(bv, true);
773 case LFUN_REF_INSERT:
774 //if (argument.empty()) {
775 // InsetCommandParams p("ref");
776 // owner_->getDialogs().createRef(p.getAsString());
778 // InsetCommandParams p;
779 // p.setFromString(argument);
781 // InsetRef * inset = new InsetRef(p, *buffer_);
782 // if (!insertInset(inset))
785 // updateInset(inset, true);
788 if (cmd.argument.empty()) {
789 InsetCommandParams p("ref");
790 bv->owner()->getDialogs().createRef(p.getAsString());
792 //mathcursor->handleNest(new InsetRef2);
793 //mathcursor->insert(arg);
794 mathcursor->insert(MathAtom(new RefInset(cmd.argument)));
796 updateLocal(bv, true);
800 result = UNDISPATCHED;
803 mathcursor->normalize();
806 lyx::Assert(mathcursor);
808 if (mathcursor->selection() || was_selection)
809 toggleInsetSelection(bv);
811 if (result == DISPATCHED || result == DISPATCHED_NOUPDATE ||
812 result == UNDISPATCHED) {
816 cmd.view()->stuffClipboard(mathcursor->grabSelection());
818 releaseMathCursor(bv);
819 bv->unlockInset(this);
822 return result; // original version
826 void InsetFormulaBase::revealCodes(BufferView * bv) const
830 bv->owner()->message(mathcursor->info());
833 // write something to the minibuffer
834 // translate to latex
835 mathcursor->markInsert();
838 string str = os.str();
839 mathcursor->markErase();
840 string::size_type pos = 0;
842 for (string::iterator it = str.begin(); it != str.end(); ++it) {
845 else if (*it == '\0') {
847 pos = it - str.begin();
853 res = res.substr(pos - 30);
855 res = res.substr(0, 60);
856 bv->owner()->message(res);
861 Inset::Code InsetFormulaBase::lyxCode() const
863 return Inset::MATH_CODE;
867 int InsetFormulaBase::ylow() const
869 return yo_ - ascent(view(), font_);
873 int InsetFormulaBase::yhigh() const
875 return yo_ + descent(view(), font_);
879 int InsetFormulaBase::xlow() const
885 int InsetFormulaBase::xhigh() const
887 return xo_ + width(view(), font_);
891 /////////////////////////////////////////////////////////////////////
894 bool InsetFormulaBase::searchForward(BufferView * bv, string const & str,
900 static InsetFormulaBase * lastformula = 0;
901 static MathIterator current = MathIterator(ibegin(par().nucleus()));
903 static string laststr;
905 if (lastformula != this || laststr != str) {
906 //lyxerr << "reset lastformula to " << this << "\n";
909 current = ibegin(par().nucleus());
911 mathed_parse_cell(ar, str);
915 //lyxerr << "searching '" << str << "' in " << this << ar << endl;
917 for (MathIterator it = current; it != iend(par().nucleus()); ++it) {
918 if (it.cell().matchpart(ar, it.back().pos_)) {
919 bv->unlockInset(bv->theLockingInset());
920 if (!bv->lockInset(this)) {
921 lyxerr << "Cannot lock inset" << endl;
925 mathcursor = new MathCursor(this, true);
927 mathcursor->setSelection(it, ar.size());
930 updateLocal(bv, false);
935 //lyxerr << "not found!\n";
941 bool InsetFormulaBase::searchBackward(BufferView * bv, string const & what,
944 lyxerr[Debug::MATHED] << "searching backward not implemented in mathed\n";
945 return searchForward(bv, what, a, b);
949 bool InsetFormulaBase::display() const
951 return par()->asHullInset() && par()->asHullInset()->display();
955 string InsetFormulaBase::selectionAsString() const
957 return mathcursor ? mathcursor->grabSelection() : string();
960 /////////////////////////////////////////////////////////////////////
963 void mathDispatchCreation(FuncRequest const & cmd, bool display)
965 BufferView * bv = cmd.view();
966 // use selection if available..
968 //if (action == LFUN_MATH_IMPORT_SELECTION)
972 string sel = bv->getLyXText()->selectionAsString(bv->buffer(), false);
975 InsetFormula * f = new InsetFormula(bv);
976 if (openNewInset(bv, f)) {
977 bv->theLockingInset()->
978 localDispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
979 // don't do that also for LFUN_MATH_MODE unless you want end up with
980 // always changing to mathrm when opening an inlined inset
981 // -- I really hate "LyXfunc overloading"...
983 f->localDispatch(FuncRequest(bv, LFUN_MATH_DISPLAY));
984 f->localDispatch(FuncRequest(bv, LFUN_INSERT_MATH, cmd.argument));
987 // create a macro if we see "\\newcommand" somewhere, and an ordinary
989 InsetFormulaBase * f;
990 if (sel.find("\\newcommand") == string::npos &&
991 sel.find("\\def") == string::npos)
992 f = new InsetFormula(sel);
994 f = new InsetFormulaMacro(sel);
995 bv->getLyXText()->cutSelection(bv);
998 cmd.message(N_("Math editor mode"));
1002 void mathDispatch(FuncRequest const & cmd)
1004 BufferView * bv = cmd.view();
1005 if (!bv->available())
1008 switch (cmd.action) {
1010 case LFUN_MATH_DISPLAY:
1011 mathDispatchCreation(cmd, true);
1014 case LFUN_MATH_MODE:
1015 mathDispatchCreation(cmd, false);
1018 case LFUN_MATH_IMPORT_SELECTION:
1019 mathDispatchCreation(cmd, false);
1022 case LFUN_MATH_MACRO:
1023 if (cmd.argument.empty())
1024 cmd.errorMessage(N_("Missing argument"));
1026 string s = cmd.argument;
1027 string const s1 = token(s, ' ', 1);
1028 int const na = s1.empty() ? 0 : lyx::atoi(s1);
1029 openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na));
1034 case LFUN_INSERT_MATH:
1035 case LFUN_INSERT_MATRIX:
1036 case LFUN_MATH_DELIM: {
1037 InsetFormula * f = new InsetFormula(bv);
1038 if (openNewInset(bv, f)) {
1039 bv->theLockingInset()->
1040 localDispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
1041 bv->theLockingInset()->localDispatch(cmd);