2 * \file math_nestinset.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "math_nestinset.h"
15 #include "math_arrayinset.h"
16 #include "math_braceinset.h"
17 #include "math_commentinset.h"
18 #include "math_data.h"
19 #include "math_deliminset.h"
20 #include "math_factory.h"
21 #include "math_hullinset.h"
22 #include "math_mathmlstream.h"
23 #include "math_parser.h"
24 #include "math_scriptinset.h"
25 #include "math_spaceinset.h"
26 #include "math_support.h"
27 #include "math_mboxinset.h"
28 #include "math_unknowninset.h"
30 #include "BufferView.h"
31 #include "FuncStatus.h"
32 #include "bufferview_funcs.h"
35 #include "dispatchresult.h"
36 #include "funcrequest.h"
41 #include "support/std_sstream.h"
42 #include "support/lstrings.h"
44 #include "frontends/Dialogs.h"
45 #include "frontends/LyXView.h"
46 #include "frontends/Painter.h"
51 using std::istringstream;
65 MathNestInset::MathNestInset(idx_type nargs)
66 : cells_(nargs), lock_(false)
70 MathInset::idx_type MathNestInset::nargs() const
76 MathArray & MathNestInset::cell(idx_type i)
82 MathArray const & MathNestInset::cell(idx_type i) const
88 void MathNestInset::getCursorPos(CursorSlice const & cur,
89 int & x, int & y) const
91 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
92 MathArray const & ar = cur.cell();
93 x = ar.xo() + ar.pos2x(cur.pos());
95 // move cursor visually into empty cells ("blue rectangles");
96 if (cur.cell().empty())
101 void MathNestInset::substitute(MathMacro const & m)
103 for (idx_type i = 0; i < nargs(); ++i)
104 cell(i).substitute(m);
108 void MathNestInset::metrics(MetricsInfo const & mi) const
111 for (idx_type i = 0; i < nargs(); ++i)
116 bool MathNestInset::idxNext(LCursor & cur) const
118 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
119 if (cur.idx() == cur.lastidx())
127 bool MathNestInset::idxRight(LCursor & cur) const
133 bool MathNestInset::idxPrev(LCursor & cur) const
135 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
139 cur.pos() = cur.lastpos();
144 bool MathNestInset::idxLeft(LCursor & cur) const
150 bool MathNestInset::idxFirst(LCursor & cur) const
152 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
161 bool MathNestInset::idxLast(LCursor & cur) const
163 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
166 cur.idx() = cur.lastidx();
167 cur.pos() = cur.lastpos();
172 void MathNestInset::dump() const
174 WriteStream os(lyxerr);
175 os << "---------------------------------------------\n";
178 for (idx_type i = 0; i < nargs(); ++i)
179 os << cell(i) << "\n";
180 os << "---------------------------------------------\n";
184 //void MathNestInset::draw(PainterInfo & pi, int x, int y) const
185 void MathNestInset::draw(PainterInfo &, int, int) const
189 pi.pain.fillRectangle(x, y - ascent(), width(), height(),
195 void MathNestInset::drawSelection(PainterInfo & pi, int, int) const
197 // this should use the x/y values given, not the cached values
198 LCursor & cur = pi.base.bv->cursor();
199 if (!cur.selection())
201 if (!ptr_cmp(&cur.inset(), this))
203 CursorSlice & s1 = cur.selBegin();
204 CursorSlice & s2 = cur.selEnd();
205 if (s1.idx() == s2.idx()) {
206 MathArray const & c = cell(s1.idx());
207 int x1 = c.xo() + c.pos2x(s1.pos());
208 int y1 = c.yo() - c.ascent();
209 int x2 = c.xo() + c.pos2x(s2.pos());
210 int y2 = c.yo() + c.descent();
211 pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
213 for (idx_type i = 0; i < nargs(); ++i) {
214 if (idxBetween(i, s1.idx(), s2.idx())) {
215 MathArray const & c = cell(i);
217 int y1 = c.yo() - c.ascent();
218 int x2 = c.xo() + c.width();
219 int y2 = c.yo() + c.descent();
220 pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
227 void MathNestInset::validate(LaTeXFeatures & features) const
229 for (idx_type i = 0; i < nargs(); ++i)
230 cell(i).validate(features);
234 void MathNestInset::replace(ReplaceData & rep)
236 for (idx_type i = 0; i < nargs(); ++i)
237 cell(i).replace(rep);
241 bool MathNestInset::contains(MathArray const & ar) const
243 for (idx_type i = 0; i < nargs(); ++i)
244 if (cell(i).contains(ar))
250 bool MathNestInset::lock() const
256 void MathNestInset::lock(bool l)
262 bool MathNestInset::isActive() const
268 MathArray MathNestInset::glue() const
271 for (size_t i = 0; i < nargs(); ++i)
277 void MathNestInset::write(WriteStream & os) const
279 os << '\\' << name().c_str();
280 for (size_t i = 0; i < nargs(); ++i)
281 os << '{' << cell(i) << '}';
283 os.pendingSpace(true);
284 if (lock_ && !os.latex()) {
286 os.pendingSpace(true);
291 void MathNestInset::normalize(NormalStream & os) const
293 os << '[' << name().c_str();
294 for (size_t i = 0; i < nargs(); ++i)
295 os << ' ' << cell(i);
300 void MathNestInset::notifyCursorLeaves(idx_type idx)
302 cell(idx).notifyCursorLeaves();
306 void MathNestInset::handleFont
307 (LCursor & cur, string const & arg, string const & font)
309 // this whole function is a hack and won't work for incremental font
311 recordUndo(cur, Undo::ATOMIC);
313 if (cur.inset().asMathInset()->name() == font)
314 cur.handleFont(font);
316 cur.handleNest(createMathInset(font));
322 void MathNestInset::handleFont2(LCursor & cur, string const & arg)
324 recordUndo(cur, Undo::ATOMIC);
327 bv_funcs::string2font(arg, font, b);
328 if (font.color() != LColor::inherit) {
329 MathAtom at = createMathInset("color");
330 asArray(lcolor.getGUIName(font.color()), at.nucleus()->cell(0));
331 cur.handleNest(at, 1);
336 void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
338 lyxerr << "MathNestInset: request: " << cmd << std::endl;
339 //CursorSlice sl = cur.current();
341 switch (cmd.action) {
343 case LFUN_PASTESELECTION: {
345 mathed_parse_cell(ar, cur.bv().getClipboard());
346 cur.cell().insert(cur.pos(), ar);
347 cur.pos() += ar.size();
352 if (!cmd.argument.empty()) {
354 mathed_parse_cell(ar, cmd.argument);
355 cur.cell().insert(cur.pos(), ar);
356 cur.pos() += ar.size();
362 istringstream is(cmd.argument.c_str());
365 cur.macroModeClose();
366 recordUndo(cur, Undo::ATOMIC);
372 case LFUN_MOUSE_PRESS:
373 lfunMousePress(cur, cmd);
376 case LFUN_MOUSE_MOTION:
377 lfunMouseMotion(cur, cmd);
380 case LFUN_MOUSE_RELEASE:
381 lfunMouseRelease(cur, cmd);
384 case LFUN_FINISHED_LEFT:
385 cur.bv().cursor() = cur;
388 case LFUN_FINISHED_RIGHT:
390 cur.bv().cursor() = cur;
393 case LFUN_FINISHED_UP:
394 //idxUpDown(cur, true);
395 cur.bv().cursor() = cur;
398 case LFUN_FINISHED_DOWN:
399 //idxUpDown(cur, false);
400 cur.bv().cursor() = cur;
405 lyxerr << "mathnest RIGHT: from:\n" << cur << endl;
406 cur.selHandle(cmd.action == LFUN_RIGHTSEL);
407 cur.autocorrect() = false;
409 if (cur.inMacroMode())
410 cur.macroModeClose();
411 else if (cur.pos() != cur.lastpos() && cur.openable(cur.nextAtom())) {
412 cur.pushLeft(*cur.nextAtom().nucleus());
413 cur.inset().idxFirst(cur);
414 } else if (cur.posRight() || idxRight(cur)
415 || cur.popRight() || cur.selection())
418 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
419 lyxerr << "mathnest RIGHT: to:\n" << cur << endl;
424 cur.selHandle(cmd.action == LFUN_LEFTSEL);
425 cur.autocorrect() = false;
427 if (cur.inMacroMode())
428 cur.macroModeClose();
429 else if (cur.pos() != 0 && cur.openable(cur.prevAtom())) {
431 cur.push(*cur.nextAtom().nucleus());
432 cur.inset().idxLast(cur);
433 } else if (cur.posLeft() || idxLeft(cur)
434 || cur.popLeft() || cur.selection())
437 cmd = FuncRequest(LFUN_FINISHED_LEFT);
442 cur.selHandle(cmd.action == LFUN_UPSEL);
444 cmd = FuncRequest(LFUN_FINISHED_UP);
449 cur.selHandle(cmd.action == LFUN_DOWNSEL);
451 cmd = FuncRequest(LFUN_FINISHED_DOWN);
454 case LFUN_MOUSE_DOUBLE:
455 case LFUN_MOUSE_TRIPLE:
460 cur.selection() = true;
461 cur.pos() = cur.lastpos();
462 cur.idx() = cur.lastidx();
465 case LFUN_UP_PARAGRAPHSEL:
466 case LFUN_UP_PARAGRAPH:
467 case LFUN_DOWN_PARAGRAPHSEL:
468 case LFUN_DOWN_PARAGRAPH:
473 case LFUN_WORDLEFTSEL:
475 cur.selHandle(cmd.action == LFUN_WORDLEFTSEL || cmd.action == LFUN_HOMESEL);
476 cur.macroModeClose();
477 if (cur.pos() != 0) {
479 } else if (cur.col() != 0) {
480 cur.idx() -= cur.col();
482 } else if (cur.idx() != 0) {
486 cmd = FuncRequest(LFUN_FINISHED_LEFT);
490 case LFUN_WORDRIGHTSEL:
494 cur.selHandle(cmd.action == LFUN_WORDRIGHTSEL || cmd.action == LFUN_ENDSEL);
495 cur.macroModeClose();
497 if (cur.pos() != cur.lastpos()) {
498 cur.pos() = cur.lastpos();
499 } else if (cur.col() != cur.lastcol()) {
500 cur.idx() = cur.idx() - cur.col() + cur.lastcol();
501 cur.pos() = cur.lastpos();
502 } else if (cur.idx() != cur.lastidx()) {
503 cur.idx() = cur.lastidx();
504 cur.pos() = cur.lastpos();
506 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
512 case LFUN_BEGINNINGBUFSEL:
513 case LFUN_BEGINNINGBUF:
514 cmd = FuncRequest(LFUN_FINISHED_LEFT);
521 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
524 case LFUN_CELL_FORWARD:
525 cur.inset().idxNext(cur);
528 case LFUN_CELL_BACKWARD:
529 cur.inset().idxPrev(cur);
532 case LFUN_DELETE_WORD_BACKWARD:
534 recordUndo(cur, Undo::ATOMIC);
538 case LFUN_DELETE_WORD_FORWARD:
540 recordUndo(cur, Undo::ATOMIC);
542 cmd = FuncRequest(LFUN_FINISHED_LEFT);
549 cmd = FuncRequest(LFUN_FINISHED_LEFT);
552 case LFUN_INSET_TOGGLE:
554 if (cur.pos() != cur.lastpos()) {
555 // toggle previous inset ...
556 cur.nextAtom().nucleus()->lock(!cur.nextAtom()->lock());
557 } else if (cur.popLeft() && cur.pos() != cur.lastpos()) {
558 // ... or enclosing inset if we are in the last inset position
559 cur.nextAtom().nucleus()->lock(!cur.nextAtom()->lock());
564 case LFUN_SELFINSERT:
565 if (cmd.argument.empty()) {
566 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
569 recordUndo(cur, Undo::ATOMIC);
570 if (cmd.argument.size() != 1) {
571 cur.insert(cmd.argument);
574 if (!interpret(cur, cmd.argument[0]))
575 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
580 // this needs to be incorporated
582 // delete empty mathbox (LFUN_BACKSPACE and LFUN_DELETE)
583 bool remove_inset = false;
585 DispatchResult result(true);
586 bool was_macro = cur.inMacroMode();
593 // sprintf(dispatch_buffer, "%d %d",);
594 // DispatchResult= dispatch_buffer;
597 lyxerr << "LFUN_SETXY broken!" << endl;
600 istringstream is(cmd.argument.c_str());
602 cur.setScreenPos(x, y);
607 recordUndo(cur, Undo::DELETE);
615 // Special casing for superscript in case of LyX handling
617 case LFUN_CIRCUMFLEX:
618 if (cmd.argument.empty()) {
619 // do superscript if LyX handles
621 recordUndo(cur, Undo::ATOMIC);
639 case LFUN_HUNG_UMLAUT:
643 case LFUN_FREEFONT_APPLY:
644 case LFUN_FREEFONT_UPDATE:
645 handleFont2(cur, cmd.argument);
649 handleFont(cur, cmd.argument, "mathbf");
652 handleFont(cur, cmd.argument, "mathsf");
655 handleFont(cur, cmd.argument, "mathcal");
658 handleFont(cur, cmd.argument, "mathrm");
661 handleFont(cur, cmd.argument, "texttt");
664 handleFont(cur, cmd.argument, "mathfrak");
667 handleFont(cur, cmd.argument, "mathit");
670 handleFont(cur, cmd.argument, "mathbb");
672 //case LFUN_FREEFONT_APPLY:
673 handleFont(cur, cmd.argument, "textrm");
676 handleFont(cur, cmd.argument, "textnormal");
681 cur.macroModeClose();
683 cur.plainInsert(MathAtom(new MathMBoxInset(cur.bv())));
685 cur.pushLeft(*cur.nextInset());
687 if (currentMode() == InsetBase::TEXT_MODE)
688 cur.niceInsert(MathAtom(new MathHullInset("simple")));
690 handleFont(cur, cmd.argument, "textrm");
691 //cur.owner()->message(_("math text mode toggled"));
698 recordUndo(cur, Undo::ATOMIC);
704 case LFUN_INSERT_MATRIX: {
705 recordUndo(cur, Undo::ATOMIC);
710 istringstream is(cmd.argument);
711 is >> m >> n >> v_align >> h_align;
718 MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
722 case LFUN_MATH_DELIM: {
723 lyxerr << "MathNestInset::LFUN_MATH_DELIM" << endl;
725 string rs = lyx::support::split(cmd.argument, ls, ' ');
726 // Reasonable default values
731 recordUndo(cur, Undo::ATOMIC);
732 cur.handleNest(MathAtom(new MathDelimInset(ls, rs)));
736 case LFUN_SPACE_INSERT:
737 case LFUN_MATH_SPACE:
738 recordUndo(cur, Undo::ATOMIC);
739 cur.insert(MathAtom(new MathSpaceInset(",")));
744 //cur.bv().owner()->message(_("Invalid action in math mode!"));
748 // interpret this as if a backslash was typed
749 recordUndo(cur, Undo::ATOMIC);
750 interpret(cur, '\\');
753 // FIXME: We probably should swap parts of "math-insert" and "self-insert"
754 // handling such that "self-insert" works on "arbitrary stuff" too, and
755 // math-insert only handles special math things like "matrix".
756 case LFUN_INSERT_MATH:
757 recordUndo(cur, Undo::ATOMIC);
758 cur.niceInsert(cmd.argument);
761 case LFUN_DIALOG_SHOW_NEW_INSET: {
762 string const & name = cmd.argument;
767 data = tmp.createDialogStr(name);
770 cur.bv().owner()->getDialogs().show(name, data, 0);
774 case LFUN_INSET_APPLY: {
775 string const name = cmd.getArg(0);
776 InsetBase * base = cur.bv().owner()->getDialogs().getOpenInset(name);
779 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
780 base->dispatch(cur, fr);
784 if (createMathInset_fromDialogStr(cmd.argument, ar)) {
795 case LFUN_WORD_REPLACE:
797 if (!searchForward(&cur.bv(), cmd.getArg(0), false, false))
804 BOOST_ASSERT(cur.inMathed());
806 if (result.dispatched()) {
808 cur.bv().stuffClipboard(cur.grabSelection());
811 cur.bv().owner()->dispatch(FuncRequest(LFUN_DELETE));
817 MathDimInset::priv_dispatch(cur, cmd);
823 bool MathNestInset::getStatus(LCursor & cur, FuncRequest const & cmd,
824 FuncStatus & flag) const
826 // the font related toggles
827 //string tc = mathcursor::getLastCode();
829 switch (cmd.action) {
831 case LFUN_TABULAR_FEATURE:
832 // FIXME: check temporarily disabled
834 char align = mathcursor::valign();
839 if (cmd.argument.empty()) {
843 if (!contains("tcb", cmd.argument[0])) {
847 flag.setOnOff(cmd.argument[0] == align);
850 flag.setOnOff(tc == "mathbf");
853 flag.setOnOff(tc == "mathsf");
856 flag.setOnOff(tc == "mathcal");
859 flag.setOnOff(tc == "mathrm");
862 flag.setOnOff(tc == "mathtt");
865 flag.setOnOff(tc == "mathbb");
868 flag.setOnOff(tc == "mathnormal");
871 case LFUN_MATH_MUTATE:
872 //flag.setOnOff(mathcursor::formula()->hullType() == cmd.argument);
873 flag.setOnOff(false);
876 // we just need to be in math mode to enable that
878 case LFUN_MATH_SPACE:
879 case LFUN_MATH_LIMITS:
880 case LFUN_MATH_NONUMBER:
881 case LFUN_MATH_NUMBER:
882 case LFUN_MATH_EXTERN:
893 void MathNestInset::edit(LCursor & cur, bool left)
896 cur.idx() = left ? 0 : cur.lastidx();
897 cur.pos() = left ? 0 : cur.lastpos();
902 InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y)
905 int dist_min = 1000000;
906 for (idx_type i = 0; i < nargs(); ++i) {
907 int d = cell(i).dist(x, y);
913 MathArray & ar = cell(idx_min);
916 cur.pos() = ar.x2pos(x - ar.xo());
917 lyxerr << "found cell : " << idx_min << " pos: " << cur.pos() << endl;
920 for (pos_type i = 0, n = ar.size(); i < n; ++i)
921 if (ar[i]->covers(x, y))
922 return ar[i].nucleus()->editXY(cur, x, y);
928 void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
930 //lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
932 if (cmd.button() == mouse_button::button1) {
933 // try to dispatch to enclosed insets first
934 //cur.bv().stuffClipboard(cur.grabSelection());
938 if (cmd.button() == mouse_button::button2) {
940 asArray(cur.bv().getClipboard(), ar);
942 cur.setScreenPos(cmd.x, cmd.y);
948 if (cmd.button() == mouse_button::button3) {
949 // try to dispatch to enclosed insets first
950 cur.bv().owner()->getDialogs().show("mathpanel");
958 void MathNestInset::lfunMousePress(LCursor & cur, FuncRequest & cmd)
960 lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
961 if (cmd.button() == mouse_button::button1) {
965 //cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
966 lyxerr << "lfunMousePress: setting cursor to: " << cur << endl;
967 cur.bv().cursor() = cur;
970 if (cmd.button() == mouse_button::button2) {
971 cur.dispatch(FuncRequest(LFUN_PASTESELECTION));
976 void MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest & cmd)
978 // only select with button 1
979 if (cmd.button() != mouse_button::button1)
982 if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
988 if (!cur.selection())
991 //cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
992 cur.bv().cursor().setCursor(cur, true);
996 bool MathNestInset::interpret(LCursor & cur, char c)
998 //lyxerr << "interpret 2: '" << c << "'" << endl;
1000 if (cur.inMacroArgMode()) {
1006 MathMacroTemplate const * p = formula()->asMacroTemplate();
1007 if (p && 1 <= n && n <= p->numargs())
1008 cur.insert(MathAtom(new MathMacroArgument(c - '0')));
1010 cur.insert(createMathInset("#"));
1011 interpret(cur, c); // try again
1018 if (cur.inMacroMode()) {
1019 string name = cur.macroName();
1020 //lyxerr << "interpret name: '" << name << "'" << endl;
1023 cur.activeMacro()->setName(cur.activeMacro()->name() + c);
1027 // handle 'special char' macros
1032 if (currentMode() == MathInset::TEXT_MODE)
1033 cur.niceInsert(createMathInset("textbackslash"));
1035 cur.niceInsert(createMathInset("backslash"));
1036 } else if (c == '{') {
1037 cur.niceInsert(MathAtom(new MathBraceInset));
1039 cur.niceInsert(createMathInset(string(1, c)));
1044 // leave macro mode and try again if necessary
1045 cur.macroModeClose();
1047 cur.niceInsert(MathAtom(new MathBraceInset));
1053 // This is annoying as one has to press <space> far too often.
1057 // leave autocorrect mode if necessary
1058 if (autocorrect() && c == ' ') {
1059 autocorrect() = false;
1064 // just clear selection on pressing the space bar
1065 if (cur.selection() && c == ' ') {
1066 cur.selection() = false;
1070 cur.selClearOrDel();
1073 //lyxerr << "starting with macro" << endl;
1074 cur.insert(MathAtom(new MathUnknownInset("\\", false)));
1079 if (currentMode() == MathInset::TEXT_MODE)
1085 if (currentMode() == MathInset::TEXT_MODE) {
1086 // insert spaces in text mode,
1087 // but suppress direct insertion of two spaces in a row
1088 // the still allows typing '<space>a<space>' and deleting the 'a', but
1089 // it is better than nothing...
1090 if (!cur.pos() != 0 || cur.prevAtom()->getChar() != ' ')
1094 if (cur.pos() != 0 && cur.prevAtom()->asSpaceInset()) {
1095 cur.prevAtom().nucleus()->asSpaceInset()->incSpace();
1100 // if are at the very end, leave the formula
1101 return cur.pos() != cur.lastpos();
1114 if (c == '{' || c == '}' || c == '#' || c == '&' || c == '$') {
1115 cur.niceInsert(createMathInset(string(1, c)));
1120 cur.niceInsert(MathAtom(new MathCommentInset));
1124 // try auto-correction
1125 //if (autocorrect() && hasPrevAtom() && math_autocorrect(prevAtom(), c))
1128 // no special circumstances, so insert the character without any fuss
1130 cur.autocorrect() = true;
1135 bool MathNestInset::script(LCursor & cur, bool up)
1137 // Hack to get \\^ and \\_ working
1138 lyxerr << "handling script: up: " << up << endl;
1139 if (cur.inMacroMode() && cur.macroName() == "\\") {
1141 cur.niceInsert(createMathInset("mathcircumflex"));
1143 interpret(cur, '_');
1147 cur.macroModeClose();
1148 string safe = cur.grabAndEraseSelection();
1149 if (asScriptInset() && cur.idx() == 2) {
1150 // we are in a nucleus of a script inset, move to _our_ script
1151 asScriptInset()->ensure(up);
1154 } else if (cur.pos() != 0 && cur.prevAtom()->asScriptInset()) {
1156 cur.nextAtom().nucleus()->asScriptInset()->ensure(up);
1157 cur.push(*cur.nextInset());
1159 cur.pos() = cur.lastpos();
1160 } else if (cur.pos() != 0) {
1162 cur.cell()[cur.pos()] = MathAtom(new MathScriptInset(cur.nextAtom(), up));
1163 cur.push(*cur.nextInset());
1167 cur.plainInsert(MathAtom(new MathScriptInset(up)));
1169 cur.nextAtom().nucleus()->asScriptInset()->ensure(up);
1170 cur.push(*cur.nextInset());