1 #include "math_gridinset.h"
2 #include "math_mathmlstream.h"
3 #include "math_streamstr.h"
5 #include "funcrequest.h"
6 #include "frontends/Painter.h"
16 void mathed_parse_normal(MathGridInset &, string const & argument);
20 string verboseHLine(int n)
23 for (int i = 0; i < n; ++i)
32 //////////////////////////////////////////////////////////////
35 MathGridInset::CellInfo::CellInfo()
42 //////////////////////////////////////////////////////////////
45 MathGridInset::RowInfo::RowInfo()
51 int MathGridInset::RowInfo::skipPixels() const
53 return crskip_.inBP();
58 //////////////////////////////////////////////////////////////
61 MathGridInset::ColInfo::ColInfo()
62 : align_('c'), leftline_(false), rightline_(false), lines_(0)
66 //////////////////////////////////////////////////////////////
69 MathGridInset::MathGridInset(char v, string const & h)
70 : MathNestInset(guessColumns(h)),
72 colinfo_(guessColumns(h) + 1),
73 cellinfo_(1 * guessColumns(h))
78 //lyxerr << "created grid with " << ncols() << " columns\n";
82 MathGridInset::MathGridInset()
93 MathGridInset::MathGridInset(col_type m, row_type n)
94 : MathNestInset(m * n),
104 MathGridInset::MathGridInset(col_type m, row_type n, char v, string const & h)
105 : MathNestInset(m * n),
117 MathInset * MathGridInset::clone() const
119 return new MathGridInset(*this);
123 MathInset::idx_type MathGridInset::index(row_type row, col_type col) const
125 return col + ncols() * row;
129 void MathGridInset::setDefaults()
132 lyxerr << "positive number of columns expected\n";
134 // lyxerr << "positive number of rows expected\n";
135 for (col_type col = 0; col < ncols(); ++col) {
136 colinfo_[col].align_ = defaultColAlign(col);
137 colinfo_[col].skip_ = defaultColSpace(col);
142 void MathGridInset::halign(string const & hh)
145 for (string::const_iterator it = hh.begin(); it != hh.end(); ++it) {
150 colinfo_[col].lines_++;
151 } else if (c == 'c' || c == 'l' || c == 'r') {
152 colinfo_[col].align_ = c;
154 colinfo_[col].lines_ = 0;
156 lyxerr << "unknown column separator: '" << c << "'\n";
161 col_type n = hh.size();
164 for (col_type col = 0; col < n; ++col)
165 colinfo_[col].align_ = hh[col];
170 MathGridInset::col_type MathGridInset::guessColumns(string const & hh) const
173 for (string::const_iterator it = hh.begin(); it != hh.end(); ++it)
174 if (*it == 'c' || *it == 'l' || *it == 'r')
176 // let's have at least one column, even if we did not recognize its
184 void MathGridInset::halign(char h, col_type col)
186 colinfo_[col].align_ = h;
190 char MathGridInset::halign(col_type col) const
192 return colinfo_[col].align_;
196 string MathGridInset::halign() const
199 for (col_type col = 0; col < ncols(); ++col) {
200 res += string(colinfo_[col].lines_, '|');
201 res += colinfo_[col].align_;
203 return res + string(colinfo_[ncols()].lines_, '|');
207 void MathGridInset::valign(char c)
213 char MathGridInset::valign() const
219 MathGridInset::col_type MathGridInset::ncols() const
221 return colinfo_.size() - 1;
225 MathGridInset::row_type MathGridInset::nrows() const
227 return rowinfo_.size() - 1;
231 MathGridInset::col_type MathGridInset::col(idx_type idx) const
233 return idx % ncols();
237 MathGridInset::row_type MathGridInset::row(idx_type idx) const
239 return idx / ncols();
243 void MathGridInset::vcrskip(LyXLength const & crskip, row_type row)
245 rowinfo_[row].crskip_ = crskip;
249 LyXLength MathGridInset::vcrskip(row_type row) const
251 return rowinfo_[row].crskip_;
255 void MathGridInset::metrics(MathMetricsInfo & mi) const
257 // let the cells adjust themselves
258 MathNestInset::metrics(mi);
260 // compute absolute sizes of vertical structure
261 for (row_type row = 0; row < nrows(); ++row) {
264 for (col_type col = 0; col < ncols(); ++col) {
265 MathArray const & c = cell(index(row, col));
266 asc = max(asc, c.ascent());
267 desc = max(desc, c.descent());
269 rowinfo_[row].ascent_ = asc;
270 rowinfo_[row].descent_ = desc;
272 rowinfo_[0].ascent_ += hlinesep() * rowinfo_[0].lines_;
273 rowinfo_[nrows()].ascent_ = 0;
274 rowinfo_[nrows()].descent_ = 0;
276 // compute vertical offsets
277 rowinfo_[0].offset_ = 0;
278 for (row_type row = 1; row <= nrows(); ++row) {
279 rowinfo_[row].offset_ =
280 rowinfo_[row - 1].offset_ +
281 rowinfo_[row - 1].descent_ +
282 rowinfo_[row - 1].skipPixels() +
284 rowinfo_[row].lines_ * hlinesep() +
285 rowinfo_[row].ascent_;
288 // adjust vertical offset
295 h = rowinfo_[nrows() - 1].offset_;
298 h = rowinfo_[nrows() - 1].offset_ / 2;
300 for (row_type row = 0; row <= nrows(); ++row)
301 rowinfo_[row].offset_ -= h;
304 // compute absolute sizes of horizontal structure
305 for (col_type col = 0; col < ncols(); ++col) {
307 for (row_type row = 0; row < nrows(); ++row)
308 wid = max(wid, cell(index(row, col)).width());
309 colinfo_[col].width_ = wid;
311 colinfo_[ncols()].width_ = 0;
313 // compute horizontal offsets
314 colinfo_[0].offset_ = border();
315 for (col_type col = 1; col <= ncols(); ++col) {
316 colinfo_[col].offset_ =
317 colinfo_[col - 1].offset_ +
318 colinfo_[col - 1].width_ +
319 colinfo_[col - 1].skip_ +
321 colinfo_[col].lines_ * vlinesep();
325 dim_.w = colinfo_[ncols() - 1].offset_
326 + colinfo_[ncols() - 1].width_
327 + vlinesep() * colinfo_[ncols()].lines_
330 dim_.a = - rowinfo_[0].offset_
331 + rowinfo_[0].ascent_
332 + hlinesep() * rowinfo_[0].lines_
335 dim_.d = rowinfo_[nrows() - 1].offset_
336 + rowinfo_[nrows() - 1].descent_
337 + hlinesep() * rowinfo_[nrows()].lines_
342 // Increase ws_[i] for 'R' columns (except the first one)
343 for (int i = 1; i < nc_; ++i)
344 if (align_[i] == 'R')
345 ws_[i] += 10 * df_width;
346 // Increase ws_[i] for 'C' column
347 if (align_[0] == 'C')
348 if (ws_[0] < 7 * workwidth / 8)
349 ws_[0] = 7 * workwidth / 8;
353 for (cxrow = row_.begin(); cxrow; ++cxrow) {
356 for (int i = 0; i < nc_; ++i) {
358 if (cxrow->getTab(i) <= 0) {
359 cxrow->setTab(i, df_width);
367 lf = (ws_[i] - cxrow->getTab(i))/2;
371 lf = ws_[i] - cxrow->getTab(i);
374 if (cxrow == row_.begin())
376 else if (cxrow.is_last())
377 lf = ws_[i] - cxrow->getTab(i);
379 lf = (ws_[i] - cxrow->getTab(i))/2;
382 int const ww = (isvoid) ? lf : lf + cxrow->getTab(i);
383 cxrow->setTab(i, lf + rg);
384 rg = ws_[i] - ww + colsep();
385 if (cxrow == row_.begin())
386 width += ws_[i] + colsep();
388 cxrow->setBaseline(cxrow->getBaseline() - ascent);
394 void MathGridInset::draw(MathPainterInfo & pi, int x, int y) const
396 for (idx_type idx = 0; idx < nargs(); ++idx)
397 cell(idx).draw(pi, x + cellXOffset(idx), y + cellYOffset(idx));
399 for (row_type row = 0; row <= nrows(); ++row)
400 for (int i = 0; i < rowinfo_[row].lines_; ++i) {
401 int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_
402 - i * hlinesep() - hlinesep()/2 - rowsep()/2;
403 pi.pain.line(x + 1, yy, x + width() - 1, yy);
406 for (col_type col = 0; col <= ncols(); ++col)
407 for (int i = 0; i < colinfo_[col].lines_; ++i) {
408 int xx = x + colinfo_[col].offset_
409 - i * vlinesep() - vlinesep()/2 - colsep()/2;
410 pi.pain.line(xx, y - ascent() + 1, xx, y + descent() - 1);
415 void MathGridInset::metricsT(TextMetricsInfo const & mi) const
417 // let the cells adjust themselves
418 //MathNestInset::metrics(mi);
419 for (idx_type i = 0; i < nargs(); ++i)
420 cell(i).metricsT(mi);
422 // compute absolute sizes of vertical structure
423 for (row_type row = 0; row < nrows(); ++row) {
426 for (col_type col = 0; col < ncols(); ++col) {
427 MathArray const & c = cell(index(row, col));
428 asc = max(asc, c.ascent());
429 desc = max(desc, c.descent());
431 rowinfo_[row].ascent_ = asc;
432 rowinfo_[row].descent_ = desc;
434 //rowinfo_[0].ascent_ += hlinesep() * rowinfo_[0].lines_;
435 rowinfo_[nrows()].ascent_ = 0;
436 rowinfo_[nrows()].descent_ = 0;
438 // compute vertical offsets
439 rowinfo_[0].offset_ = 0;
440 for (row_type row = 1; row <= nrows(); ++row) {
441 rowinfo_[row].offset_ =
442 rowinfo_[row - 1].offset_ +
443 rowinfo_[row - 1].descent_ +
444 //rowinfo_[row - 1].skipPixels() +
446 //rowinfo_[row].lines_ * hlinesep() +
447 rowinfo_[row].ascent_;
450 // adjust vertical offset
457 h = rowinfo_[nrows() - 1].offset_;
460 h = rowinfo_[nrows() - 1].offset_ / 2;
462 for (row_type row = 0; row <= nrows(); ++row)
463 rowinfo_[row].offset_ -= h;
466 // compute absolute sizes of horizontal structure
467 for (col_type col = 0; col < ncols(); ++col) {
469 for (row_type row = 0; row < nrows(); ++row)
470 wid = max(wid, cell(index(row, col)).width());
471 colinfo_[col].width_ = wid;
473 colinfo_[ncols()].width_ = 0;
475 // compute horizontal offsets
476 colinfo_[0].offset_ = border();
477 for (col_type col = 1; col <= ncols(); ++col) {
478 colinfo_[col].offset_ =
479 colinfo_[col - 1].offset_ +
480 colinfo_[col - 1].width_ +
481 colinfo_[col - 1].skip_ +
483 //colinfo_[col].lines_ * vlinesep();
487 dim_.w = colinfo_[ncols() - 1].offset_
488 + colinfo_[ncols() - 1].width_
489 //+ vlinesep() * colinfo_[ncols()].lines_
492 dim_.a = -rowinfo_[0].offset_
493 + rowinfo_[0].ascent_
494 //+ hlinesep() * rowinfo_[0].lines_
497 dim_.d = rowinfo_[nrows() - 1].offset_
498 + rowinfo_[nrows() - 1].descent_
499 //+ hlinesep() * rowinfo_[nrows()].lines_
505 void MathGridInset::drawT(TextPainter & pain, int x, int y) const
507 for (idx_type idx = 0; idx < nargs(); ++idx)
508 cell(idx).drawT(pain, x + cellXOffset(idx), y + cellYOffset(idx));
512 string MathGridInset::eolString(row_type row, bool fragile) const
516 if (!rowinfo_[row].crskip_.zero())
517 eol += '[' + rowinfo_[row].crskip_.asLatexString() + ']';
519 // make sure an upcoming '[' does not break anything
520 if (row + 1 < nrows()) {
521 MathArray const & c = cell(index(row + 1, 0));
522 if (c.size() && c.front()->getChar() == '[')
527 // only add \\ if necessary
528 if (eol.empty() && row + 1 == nrows())
531 return (fragile ? "\\protect\\\\" : "\\\\") + eol;
535 string MathGridInset::eocString(col_type col, col_type lastcol) const
537 if (col + 1 == lastcol)
543 void MathGridInset::addRow(row_type row)
545 rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
547 (cells_.begin() + (row + 1) * ncols(), ncols(), MathArray());
549 (cellinfo_.begin() + (row + 1) * ncols(), ncols(), CellInfo());
553 void MathGridInset::appendRow()
555 rowinfo_.push_back(RowInfo());
556 //cells_.insert(cells_.end(), ncols(), MathArray());
557 for (col_type col = 0; col < ncols(); ++col) {
558 cells_.push_back(cells_type::value_type());
559 cellinfo_.push_back(CellInfo());
564 void MathGridInset::delRow(row_type row)
569 cells_type::iterator it = cells_.begin() + row * ncols();
570 cells_.erase(it, it + ncols());
572 vector<CellInfo>::iterator jt = cellinfo_.begin() + row * ncols();
573 cellinfo_.erase(jt, jt + ncols());
575 rowinfo_.erase(rowinfo_.begin() + row);
579 void MathGridInset::copyRow(row_type row)
582 for (col_type col = 0; col < ncols(); ++col)
583 cells_[(row + 1) * ncols() + col] = cells_[row * ncols() + col];
587 void MathGridInset::swapRow(row_type row)
591 if (row + 1 == nrows())
593 for (col_type col = 0; col < ncols(); ++col)
594 swap(cells_[row * ncols() + col], cells_[(row + 1) * ncols() + col]);
598 void MathGridInset::addCol(col_type newcol)
600 const col_type nc = ncols();
601 const row_type nr = nrows();
602 cells_type new_cells((nc + 1) * nr);
603 vector<CellInfo> new_cellinfo((nc + 1) * nr);
605 for (row_type row = 0; row < nr; ++row)
606 for (col_type col = 0; col < nc; ++col) {
607 new_cells[row * (nc + 1) + col + (col > newcol)]
608 = cells_[row * nc + col];
609 new_cellinfo[row * (nc + 1) + col + (col > newcol)]
610 = cellinfo_[row * nc + col];
612 swap(cells_, new_cells);
613 swap(cellinfo_, new_cellinfo);
616 inf.skip_ = defaultColSpace(newcol);
617 inf.align_ = defaultColAlign(newcol);
618 colinfo_.insert(colinfo_.begin() + newcol, inf);
622 void MathGridInset::delCol(col_type col)
628 vector<CellInfo> tmpcellinfo;
629 for (col_type i = 0; i < nargs(); ++i)
630 if (i % ncols() != col) {
631 tmpcells.push_back(cells_[i]);
632 tmpcellinfo.push_back(cellinfo_[i]);
634 swap(cells_, tmpcells);
635 swap(cellinfo_, tmpcellinfo);
637 colinfo_.erase(colinfo_.begin() + col);
641 void MathGridInset::copyCol(col_type col)
644 for (row_type row = 0; row < nrows(); ++row)
645 cells_[row * ncols() + col + 1] = cells_[row * ncols() + col];
649 void MathGridInset::swapCol(col_type col)
653 if (col + 1 == ncols())
655 for (row_type row = 0; row < nrows(); ++row)
656 swap(cells_[row * ncols() + col], cells_[row * ncols() + col + 1]);
660 int MathGridInset::cellXOffset(idx_type idx) const
662 col_type c = col(idx);
663 int x = colinfo_[c].offset_;
664 char align = colinfo_[c].align_;
665 if (align == 'r' || align == 'R')
666 x += colinfo_[c].width_ - cell(idx).width();
667 if (align == 'c' || align == 'C')
668 x += (colinfo_[c].width_ - cell(idx).width()) / 2;
673 int MathGridInset::cellYOffset(idx_type idx) const
675 return rowinfo_[row(idx)].offset_;
679 bool MathGridInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
686 pos = cell(idx).x2pos(targetx - cell(idx).xo());
689 if (idx >= ncols() * (nrows() - 1))
692 pos = cell(idx).x2pos(targetx - cell(idx).xo());
698 bool MathGridInset::idxLeft(idx_type & idx, pos_type & pos) const
700 // leave matrix if on the left hand edge
704 pos = cell(idx).size();
709 bool MathGridInset::idxRight(idx_type & idx, pos_type & pos) const
711 // leave matrix if on the right hand edge
712 if (col(idx) + 1 == ncols())
720 bool MathGridInset::idxFirst(idx_type & idx, pos_type & pos) const
727 idx = (nrows() - 1) * ncols();
730 idx = ((nrows() - 1) / 2) * ncols();
737 bool MathGridInset::idxLast(idx_type & idx, pos_type & pos) const
747 idx = ((nrows() - 1) / 2 + 1) * ncols() - 1;
749 pos = cell(idx).size();
754 bool MathGridInset::idxHome(idx_type & idx, pos_type & pos) const
761 idx -= idx % ncols();
774 bool MathGridInset::idxEnd(idx_type & idx, pos_type & pos) const
776 if (pos < cell(idx).size()) {
777 pos = cell(idx).size();
780 if (col(idx) < ncols() - 1) {
781 idx = idx - idx % ncols() + ncols() - 1;
782 pos = cell(idx).size();
785 if (idx < nargs() - 1) {
787 pos = cell(idx).size();
794 bool MathGridInset::idxDelete(idx_type & idx)
796 // nothing to do if we have just one row
800 // nothing to do if we are in the middle of the last row of the inset
801 if (idx + ncols() > nargs())
804 // try to delete entire sequence of ncols() empty cells if possible
805 for (idx_type i = idx; i < idx + ncols(); ++i)
809 // move cells if necessary
810 for (idx_type i = index(row(idx), 0); i < idx; ++i)
811 std::swap(cell(i), cell(i + ncols()));
818 // undo effect of Ctrl-Tab (i.e. pull next cell)
819 //if (idx + 1 != nargs())
820 // cell(idx).swap(cell(idx + 1));
822 // we handled the event..
827 // reimplement old behaviour when pressing Delete in the last position
829 void MathGridInset::idxGlue(idx_type idx)
831 col_type c = col(idx);
832 if (c + 1 == ncols()) {
833 if (row(idx) + 1 != nrows()) {
834 for (col_type cc = 0; cc < ncols(); ++cc)
835 cell(idx).append(cell(idx + cc + 1));
836 delRow(row(idx) + 1);
839 cell(idx).append(cell(idx + 1));
840 for (col_type cc = c + 2; cc < ncols(); ++cc)
841 cell(idx - c + cc - 1) = cell(idx - c + cc);
842 cell(idx - c + ncols() - 1).clear();
847 MathGridInset::RowInfo const & MathGridInset::rowinfo(row_type row) const
849 return rowinfo_[row];
853 MathGridInset::RowInfo & MathGridInset::rowinfo(row_type row)
855 return rowinfo_[row];
859 bool MathGridInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
861 row_type const ri = row(idx);
862 row_type const r1 = min(row(from), row(to));
863 row_type const r2 = max(row(from), row(to));
864 col_type const ci = col(idx);
865 col_type const c1 = min(col(from), col(to));
866 col_type const c2 = max(col(from), col(to));
867 return r1 <= ri && ri <= r2 && c1 <= ci && ci <= c2;
872 void MathGridInset::normalize(NormalStream & os) const
875 for (row_type row = 0; row < nrows(); ++row) {
877 for (col_type col = 0; col < ncols(); ++col)
878 os << "[cell " << cell(index(row, col)) << ']';
885 void MathGridInset::mathmlize(MathMLStream & os) const
887 os << MTag("mtable");
888 for (row_type row = 0; row < nrows(); ++row) {
890 for (col_type col = 0; col < ncols(); ++col)
891 os << cell(index(row, col));
894 os << ETag("mtable");
898 void MathGridInset::write(WriteStream & os) const
900 for (row_type row = 0; row < nrows(); ++row) {
901 os << verboseHLine(rowinfo_[row].lines_);
902 // don't write & and empty cells at end of line
903 col_type lastcol = 0;
904 bool emptyline = true;
905 for (col_type col = 0; col < ncols(); ++col)
906 if (!cell(index(row, col)).empty()) {
910 for (col_type col = 0; col < lastcol; ++col)
911 os << cell(index(row, col)) << eocString(col, lastcol);
912 os << eolString(row, os.fragile());
913 // append newline only if line wasn't completely empty
914 // and this was not the last line in the grid
915 if (!emptyline && row + 1 < nrows())
918 string const s = verboseHLine(rowinfo_[nrows()].lines_);
919 if (!s.empty() && s != " ") {
927 int MathGridInset::colsep() const
933 int MathGridInset::rowsep() const
939 int MathGridInset::hlinesep() const
945 int MathGridInset::vlinesep() const
951 int MathGridInset::border() const
957 void MathGridInset::splitCell(idx_type & idx, pos_type & pos)
959 if (idx + 1 == nargs())
961 MathArray ar = cell(idx);
963 cell(idx).erase(pos, cell(idx).size());
966 cell(idx).insert(0, ar);
970 dispatch_result MathGridInset::dispatch
971 (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
973 switch (cmd.action) {
975 case LFUN_DELETE_LINE_FORWARD:
976 //autocorrect_ = false;
986 if (pos > cell(idx).size())
987 pos = cell(idx).size();
988 return DISPATCHED_POP;
991 //bv->lockedInsetStoreUndo(Undo::EDIT);
993 //updateLocal(bv, true);
994 return DISPATCHED_POP;
996 case LFUN_BREAKLINE: {
997 //bv->lockedInsetStoreUndo(Undo::INSERT);
998 row_type const r = row(idx);
1002 for (col_type c = col(idx) + 1; c < ncols(); ++c)
1003 std::swap(cell(index(r, c)), cell(index(r + 1, c)));
1006 splitCell(idx, pos);
1007 std::swap(cell(idx), cell(idx + ncols() - 1));
1010 pos = cell(idx).size();
1012 //mathcursor->normalize();
1013 //updateLocal(bv, true);
1014 return DISPATCHED_POP;
1017 case LFUN_TABULAR_FEATURE:
1018 //lyxerr << "handling tabular-feature " << cmd.argument << "\n";
1019 if (cmd.argument == "valign-top")
1021 else if (cmd.argument == "valign-center")
1023 else if (cmd.argument == "valign-bottom")
1025 else if (cmd.argument == "align-left")
1026 halign('l', col(idx));
1027 else if (cmd.argument == "align-right")
1028 halign('r', col(idx));
1029 else if (cmd.argument == "align-center")
1030 halign('c', col(idx));
1031 else if (cmd.argument == "append-row")
1033 else if (cmd.argument == "delete-row") {
1037 } else if (cmd.argument == "copy-row")
1039 else if (cmd.argument == "swap-row")
1041 else if (cmd.argument == "append-column") {
1042 row_type r = row(idx);
1043 col_type c = col(idx);
1046 } else if (cmd.argument == "delete-column") {
1047 row_type r = row(idx);
1048 col_type c = col(idx);
1053 } else if (cmd.argument == "copy-column")
1055 else if (cmd.argument == "swap-column")
1058 return UNDISPATCHED;
1059 return DISPATCHED_POP;
1062 //lyxerr << "pasting '" << cmd.argument << "'\n";
1063 MathGridInset grid(1, 1);
1064 mathed_parse_normal(grid, cmd.argument);
1065 if (grid.nargs() == 1) {
1066 // single cell/part of cell
1067 cell(idx).insert(pos, grid.cell(0));
1068 pos += grid.cell(0).size();
1071 col_type const numcols = min(grid.ncols(), ncols() - col(idx));
1072 row_type const numrows = min(grid.nrows(), nrows() - row(idx));
1073 for (row_type r = 0; r < numrows; ++r) {
1074 for (col_type c = 0; c < numcols; ++c) {
1075 idx_type i = index(r + row(idx), c + col(idx));
1076 cell(i).append(grid.cell(grid.index(r, c)));
1078 // append the left over horizontal cells to the last column
1079 idx_type i = index(r + row(idx), ncols() - 1);
1080 for (MathInset::col_type c = numcols; c < grid.ncols(); ++c)
1081 cell(i).append(grid.cell(grid.index(r, c)));
1083 // append the left over vertical cells to the last _cell_
1084 idx_type i = nargs() - 1;
1085 for (row_type r = numrows; r < grid.nrows(); ++r)
1086 for (col_type c = 0; c < grid.ncols(); ++c)
1087 cell(i).append(grid.cell(grid.index(r, c)));
1089 return DISPATCHED_POP;
1093 return MathNestInset::dispatch(cmd, idx, pos);
1095 return UNDISPATCHED;