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_macroarg.h"
24 #include "math_mboxinset.h"
25 #include "math_parser.h"
26 #include "math_scriptinset.h"
27 #include "math_spaceinset.h"
28 #include "math_support.h"
29 #include "math_unknowninset.h"
31 #include "BufferView.h"
32 #include "CutAndPaste.h"
33 #include "FuncStatus.h"
35 #include "bufferview_funcs.h"
38 #include "dispatchresult.h"
39 #include "funcrequest.h"
41 #include "outputparams.h"
44 #include "support/lstrings.h"
46 #include "frontends/Dialogs.h"
47 #include "frontends/LyXView.h"
48 #include "frontends/Painter.h"
52 using lyx::cap::copySelection;
53 using lyx::cap::grabAndEraseSelection;
54 using lyx::cap::cutSelection;
55 using lyx::cap::pasteSelection;
56 using lyx::cap::replaceSelection;
57 using lyx::cap::selClearOrDel;
61 using std::istringstream;
76 MathNestInset::MathNestInset(idx_type nargs)
77 : cells_(nargs), lock_(false)
81 MathInset::idx_type MathNestInset::nargs() const
87 MathArray & MathNestInset::cell(idx_type i)
93 MathArray const & MathNestInset::cell(idx_type i) const
99 void MathNestInset::getCursorPos(LCursor const & cur, int & x, int & y) const
101 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
102 MathArray const & ar = cur.cell();
103 x = ar.xo() + ar.pos2x(cur.pos());
104 y = ar.yo() + cur.bv().top_y();
105 // move cursor visually into empty cells ("blue rectangles");
106 if (cur.cell().empty())
111 void MathNestInset::metrics(MetricsInfo const & mi) const
114 for (idx_type i = 0; i < nargs(); ++i)
119 bool MathNestInset::idxNext(LCursor & cur) const
121 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
122 if (cur.idx() == cur.lastidx())
130 bool MathNestInset::idxRight(LCursor & cur) const
136 bool MathNestInset::idxPrev(LCursor & cur) const
138 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
142 cur.pos() = cur.lastpos();
147 bool MathNestInset::idxLeft(LCursor & cur) const
153 bool MathNestInset::idxFirst(LCursor & cur) const
155 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
164 bool MathNestInset::idxLast(LCursor & cur) const
166 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
169 cur.idx() = cur.lastidx();
170 cur.pos() = cur.lastpos();
175 void MathNestInset::dump() const
177 WriteStream os(lyxerr);
178 os << "---------------------------------------------\n";
181 for (idx_type i = 0; i < nargs(); ++i)
182 os << cell(i) << "\n";
183 os << "---------------------------------------------\n";
187 void MathNestInset::draw(PainterInfo & pi, int x, int y) const
191 pi.pain.fillRectangle(x, y - ascent(), width(), height(),
194 setPosCache(pi, x, y);
198 void MathNestInset::drawSelection(PainterInfo & pi, int, int) const
200 // this should use the x/y values given, not the cached values
201 LCursor & cur = pi.base.bv->cursor();
202 if (!cur.selection())
204 if (!ptr_cmp(&cur.inset(), this))
206 CursorSlice s1 = cur.selBegin();
207 CursorSlice s2 = cur.selEnd();
208 //lyxerr << "MathNestInset::drawing selection: "
209 // << " s1: " << s1 << " s2: " << s2 << endl;
210 if (s1.idx() == s2.idx()) {
211 MathArray const & c = cell(s1.idx());
212 int x1 = c.xo() + c.pos2x(s1.pos());
213 int y1 = c.yo() - c.ascent();
214 int x2 = c.xo() + c.pos2x(s2.pos());
215 int y2 = c.yo() + c.descent();
216 pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
217 //lyxerr << "MathNestInset::drawing selection 3: "
218 // << " x1: " << x1 << " x2: " << x2
219 // << " y1: " << y1 << " y2: " << y2 << endl;
221 for (idx_type i = 0; i < nargs(); ++i) {
222 if (idxBetween(i, s1.idx(), s2.idx())) {
223 MathArray const & c = cell(i);
225 int y1 = c.yo() - c.ascent();
226 int x2 = c.xo() + c.width();
227 int y2 = c.yo() + c.descent();
228 pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
235 void MathNestInset::validate(LaTeXFeatures & features) const
237 for (idx_type i = 0; i < nargs(); ++i)
238 cell(i).validate(features);
242 void MathNestInset::replace(ReplaceData & rep)
244 for (idx_type i = 0; i < nargs(); ++i)
245 cell(i).replace(rep);
249 bool MathNestInset::contains(MathArray const & ar) const
251 for (idx_type i = 0; i < nargs(); ++i)
252 if (cell(i).contains(ar))
258 bool MathNestInset::lock() const
264 void MathNestInset::lock(bool l)
270 bool MathNestInset::isActive() const
276 MathArray MathNestInset::glue() const
279 for (size_t i = 0; i < nargs(); ++i)
285 void MathNestInset::write(WriteStream & os) const
287 os << '\\' << name().c_str();
288 for (size_t i = 0; i < nargs(); ++i)
289 os << '{' << cell(i) << '}';
291 os.pendingSpace(true);
292 if (lock_ && !os.latex()) {
294 os.pendingSpace(true);
299 void MathNestInset::normalize(NormalStream & os) const
301 os << '[' << name().c_str();
302 for (size_t i = 0; i < nargs(); ++i)
303 os << ' ' << cell(i);
308 int MathNestInset::latex(Buffer const &, std::ostream & os,
309 OutputParams const & runparams) const
311 WriteStream wi(os, runparams.moving_arg, true);
317 void MathNestInset::notifyCursorLeaves(LCursor & /*cur*/)
323 MathArray & ar = cur.cell();
324 // remove base-only "scripts"
325 for (pos_type i = 0; i + 1 < ar.size(); ++i) {
326 MathScriptInset * p = operator[](i).nucleus()->asScriptInset();
327 if (p && p->nargs() == 1) {
328 MathArray ar = p->nuc();
331 cur.adjust(i, ar.size() - 1);
335 // glue adjacent font insets of the same kind
336 for (pos_type i = 0; i + 1 < size(); ++i) {
337 MathFontInset * p = operator[](i).nucleus()->asFontInset();
338 MathFontInset const * q = operator[](i + 1)->asFontInset();
339 if (p && q && p->name() == q->name()) {
340 p->cell(0).append(q->cell(0));
349 void MathNestInset::handleFont
350 (LCursor & cur, string const & arg, string const & font)
352 // this whole function is a hack and won't work for incremental font
354 recordUndo(cur, Undo::ATOMIC);
356 if (cur.inset().asMathInset()->name() == font)
357 cur.handleFont(font);
359 cur.handleNest(createMathInset(font));
365 void MathNestInset::handleFont2(LCursor & cur, string const & arg)
367 recordUndo(cur, Undo::ATOMIC);
370 bv_funcs::string2font(arg, font, b);
371 if (font.color() != LColor::inherit) {
372 MathAtom at = createMathInset("color");
373 asArray(lcolor.getGUIName(font.color()), at.nucleus()->cell(0));
374 cur.handleNest(at, 1);
379 void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
381 //lyxerr << "MathNestInset: request: " << cmd << std::endl;
382 //CursorSlice sl = cur.current();
384 switch (cmd.action) {
388 cur.message(_("Paste"));
389 replaceSelection(cur);
391 istringstream is(cmd.argument.c_str());
393 pasteSelection(cur, n);
394 cur.clearSelection(); // bug 393
395 cur.bv().switchKeyMap();
401 cutSelection(cur, true, true);
402 cur.message(_("Cut"));
407 cur.message(_("Copy"));
410 case LFUN_MOUSE_PRESS:
411 lfunMousePress(cur, cmd);
414 case LFUN_MOUSE_MOTION:
415 lfunMouseMotion(cur, cmd);
418 case LFUN_MOUSE_RELEASE:
419 lfunMouseRelease(cur, cmd);
422 case LFUN_FINISHED_LEFT:
423 cur.bv().cursor() = cur;
426 case LFUN_FINISHED_RIGHT:
428 cur.bv().cursor() = cur;
431 case LFUN_FINISHED_UP:
432 cur.bv().cursor() = cur;
435 case LFUN_FINISHED_DOWN:
436 cur.bv().cursor() = cur;
441 cur.selHandle(cmd.action == LFUN_RIGHTSEL);
442 cur.autocorrect() = false;
444 if (cur.inMacroMode())
445 cur.macroModeClose();
446 else if (cur.pos() != cur.lastpos() && cur.openable(cur.nextAtom())) {
447 cur.pushLeft(*cur.nextAtom().nucleus());
448 cur.inset().idxFirst(cur);
449 } else if (cur.posRight() || idxRight(cur)
450 || cur.popRight() || cur.selection())
453 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
458 cur.selHandle(cmd.action == LFUN_LEFTSEL);
459 cur.autocorrect() = false;
461 if (cur.inMacroMode())
462 cur.macroModeClose();
463 else if (cur.pos() != 0 && cur.openable(cur.prevAtom())) {
465 cur.push(*cur.nextAtom().nucleus());
466 cur.inset().idxLast(cur);
467 } else if (cur.posLeft() || idxLeft(cur)
468 || cur.popLeft() || cur.selection())
471 cmd = FuncRequest(LFUN_FINISHED_LEFT);
476 cur.selHandle(cmd.action == LFUN_UPSEL);
478 cmd = FuncRequest(LFUN_FINISHED_UP);
483 cur.selHandle(cmd.action == LFUN_DOWNSEL);
485 cmd = FuncRequest(LFUN_FINISHED_DOWN);
488 case LFUN_MOUSE_DOUBLE:
489 case LFUN_MOUSE_TRIPLE:
494 cur.selection() = true;
495 cur.pos() = cur.lastpos();
496 cur.idx() = cur.lastidx();
499 case LFUN_UP_PARAGRAPHSEL:
500 case LFUN_UP_PARAGRAPH:
501 case LFUN_DOWN_PARAGRAPHSEL:
502 case LFUN_DOWN_PARAGRAPH:
507 case LFUN_WORDLEFTSEL:
509 cur.selHandle(cmd.action == LFUN_WORDLEFTSEL || cmd.action == LFUN_HOMESEL);
510 cur.macroModeClose();
511 if (cur.pos() != 0) {
513 } else if (cur.col() != 0) {
514 cur.idx() -= cur.col();
516 } else if (cur.idx() != 0) {
520 cmd = FuncRequest(LFUN_FINISHED_LEFT);
524 case LFUN_WORDRIGHTSEL:
528 cur.selHandle(cmd.action == LFUN_WORDRIGHTSEL || cmd.action == LFUN_ENDSEL);
529 cur.macroModeClose();
531 if (cur.pos() != cur.lastpos()) {
532 cur.pos() = cur.lastpos();
533 } else if (cur.col() != cur.lastcol()) {
534 cur.idx() = cur.idx() - cur.col() + cur.lastcol();
535 cur.pos() = cur.lastpos();
536 } else if (cur.idx() != cur.lastidx()) {
537 cur.idx() = cur.lastidx();
538 cur.pos() = cur.lastpos();
540 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
546 case LFUN_BEGINNINGBUFSEL:
547 case LFUN_BEGINNINGBUF:
548 cmd = FuncRequest(LFUN_FINISHED_LEFT);
555 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
558 case LFUN_CELL_FORWARD:
559 cur.inset().idxNext(cur);
562 case LFUN_CELL_BACKWARD:
563 cur.inset().idxPrev(cur);
566 case LFUN_DELETE_WORD_BACKWARD:
568 recordUndo(cur, Undo::ATOMIC);
572 case LFUN_DELETE_WORD_FORWARD:
576 cmd = FuncRequest(LFUN_FINISHED_LEFT);
581 cur.clearSelection();
583 cmd = FuncRequest(LFUN_FINISHED_LEFT);
586 case LFUN_INSET_TOGGLE:
589 if (cur.pos() != cur.lastpos()) {
590 // toggle previous inset ...
591 cur.nextAtom().nucleus()->lock(!cur.nextAtom()->lock());
592 } else if (cur.popLeft() && cur.pos() != cur.lastpos()) {
593 // ... or enclosing inset if we are in the last inset position
594 cur.nextAtom().nucleus()->lock(!cur.nextAtom()->lock());
599 case LFUN_SELFINSERT:
601 if (cmd.argument.size() != 1) {
602 cur.insert(cmd.argument);
605 if (!interpret(cur, cmd.argument[0]))
606 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
610 // sprintf(dispatch_buffer, "%d %d",);
614 lyxerr << "LFUN_SETXY broken!" << endl;
617 istringstream is(cmd.argument.c_str());
619 cur.setScreenPos(x, y);
623 // Special casing for superscript in case of LyX handling
625 case LFUN_CIRCUMFLEX:
626 if (cmd.argument.empty()) {
627 // do superscript if LyX handles
629 recordUndo(cur, Undo::ATOMIC);
647 case LFUN_HUNG_UMLAUT:
651 case LFUN_FREEFONT_APPLY:
652 case LFUN_FREEFONT_UPDATE:
653 handleFont2(cur, cmd.argument);
657 handleFont(cur, cmd.argument, "mathbf");
660 handleFont(cur, cmd.argument, "mathsf");
663 handleFont(cur, cmd.argument, "mathcal");
666 handleFont(cur, cmd.argument, "mathrm");
669 handleFont(cur, cmd.argument, "texttt");
672 handleFont(cur, cmd.argument, "mathfrak");
675 handleFont(cur, cmd.argument, "mathit");
678 handleFont(cur, cmd.argument, "mathbb");
680 //case LFUN_FREEFONT_APPLY:
681 handleFont(cur, cmd.argument, "textrm");
684 handleFont(cur, cmd.argument, "textnormal");
689 cur.macroModeClose();
691 cur.plainInsert(MathAtom(new MathMBoxInset(cur.bv())));
693 cur.pushLeft(*cur.nextInset());
695 if (currentMode() == InsetBase::TEXT_MODE) {
696 cur.niceInsert(MathAtom(new MathHullInset("simple")));
697 cur.message(_("create new math text environment ($...$)"));
699 handleFont(cur, cmd.argument, "textrm");
700 cur.message(_("entered math text mode (textrm)"));
712 case LFUN_INSERT_MATRIX: {
713 recordUndo(cur, Undo::ATOMIC);
718 istringstream is(cmd.argument);
719 is >> m >> n >> v_align >> h_align;
726 MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
730 case LFUN_MATH_DELIM: {
731 lyxerr << "MathNestInset::LFUN_MATH_DELIM" << endl;
733 string rs = lyx::support::split(cmd.argument, ls, ' ');
734 // Reasonable default values
739 recordUndo(cur, Undo::ATOMIC);
740 cur.handleNest(MathAtom(new MathDelimInset(ls, rs)));
744 case LFUN_SPACE_INSERT:
745 case LFUN_MATH_SPACE:
746 recordUndo(cur, Undo::ATOMIC);
747 cur.insert(MathAtom(new MathSpaceInset(",")));
751 // interpret this as if a backslash was typed
752 recordUndo(cur, Undo::ATOMIC);
753 interpret(cur, '\\');
756 // FIXME: We probably should swap parts of "math-insert" and "self-insert"
757 // handling such that "self-insert" works on "arbitrary stuff" too, and
758 // math-insert only handles special math things like "matrix".
759 case LFUN_INSERT_MATH:
760 recordUndo(cur, Undo::ATOMIC);
761 cur.niceInsert(cmd.argument);
764 case LFUN_DIALOG_SHOW_NEW_INSET: {
765 string const & name = cmd.argument;
770 data = tmp.createDialogStr(name);
773 cur.bv().owner()->getDialogs().show(name, data, 0);
777 case LFUN_INSET_APPLY: {
778 string const name = cmd.getArg(0);
779 InsetBase * base = cur.bv().owner()->getDialogs().getOpenInset(name);
782 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
783 base->dispatch(cur, fr);
787 if (createMathInset_fromDialogStr(cmd.argument, ar)) {
796 MathDimInset::priv_dispatch(cur, cmd);
802 bool MathNestInset::getStatus(LCursor & /*cur*/, FuncRequest const & cmd,
803 FuncStatus & flag) const
805 // the font related toggles
806 //string tc = "mathnormal";
808 switch (cmd.action) {
810 case LFUN_TABULAR_FEATURE:
811 // FIXME: check temporarily disabled
813 char align = mathcursor::valign();
818 if (cmd.argument.empty()) {
822 if (!contains("tcb", cmd.argument[0])) {
826 flag.setOnOff(cmd.argument[0] == align);
829 flag.setOnOff(tc == "mathbf");
832 flag.setOnOff(tc == "mathsf");
835 flag.setOnOff(tc == "mathcal");
838 flag.setOnOff(tc == "mathrm");
841 flag.setOnOff(tc == "mathtt");
844 flag.setOnOff(tc == "mathbb");
847 flag.setOnOff(tc == "mathnormal");
850 case LFUN_MATH_MUTATE:
851 //flag.setOnOff(mathcursor::formula()->hullType() == cmd.argument);
852 flag.setOnOff(false);
855 // we just need to be in math mode to enable that
857 case LFUN_MATH_SPACE:
858 case LFUN_MATH_LIMITS:
859 case LFUN_MATH_NONUMBER:
860 case LFUN_MATH_NUMBER:
861 case LFUN_MATH_EXTERN:
873 void MathNestInset::edit(LCursor & cur, bool left)
876 cur.idx() = left ? 0 : cur.lastidx();
877 cur.pos() = left ? 0 : cur.lastpos();
879 lyxerr << "MathNestInset::edit, cur:\n" << cur << endl;
883 InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y)
886 int dist_min = 1000000;
887 for (idx_type i = 0; i < nargs(); ++i) {
888 int d = cell(i).dist(x, y);
894 MathArray & ar = cell(idx_min);
897 cur.pos() = ar.x2pos(x - ar.xo());
898 lyxerr << "found cell : " << idx_min << " pos: " << cur.pos() << endl;
901 for (pos_type i = 0, n = ar.size(); i < n; ++i)
902 if (ar[i]->covers(x, y))
903 return ar[i].nucleus()->editXY(cur, x, y);
909 void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
911 //lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
913 if (cmd.button() == mouse_button::button1) {
914 // try to dispatch to enclosed insets first
915 //cur.bv().stuffClipboard(cur.grabSelection());
919 if (cmd.button() == mouse_button::button2) {
921 asArray(cur.bv().getClipboard(), ar);
922 cur.clearSelection();
923 cur.setScreenPos(cmd.x, cmd.y);
929 if (cmd.button() == mouse_button::button3) {
930 // try to dispatch to enclosed insets first
931 cur.bv().owner()->getDialogs().show("mathpanel");
939 void MathNestInset::lfunMousePress(LCursor & cur, FuncRequest & cmd)
941 lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
942 if (cmd.button() == mouse_button::button1) {
945 //cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
946 lyxerr << "lfunMousePress: setting cursor to: " << cur << endl;
948 cur.bv().cursor() = cur;
951 if (cmd.button() == mouse_button::button2) {
952 cur.dispatch(FuncRequest(LFUN_PASTESELECTION));
957 void MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest & cmd)
959 // only select with button 1
960 if (cmd.button() != mouse_button::button1)
963 if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
969 cur.bv().cursor().setCursor(cur, true);
973 bool MathNestInset::interpret(LCursor & cur, char c)
975 lyxerr << "interpret 2: '" << c << "'" << endl;
979 if (cur.inMacroMode()) {
980 string name = cur.macroName();
981 lyxerr << "interpret macro name: '" << name << "'" << endl;
983 /// are we currently typing '#1' or '#2' or...?
987 if (n >= 1 && n <= 9)
988 cur.insert(new MathMacroArgument(n));
993 cur.activeMacro()->setName(name + c);
997 // handle 'special char' macros
1002 if (currentMode() == MathInset::TEXT_MODE)
1003 cur.niceInsert(createMathInset("textbackslash"));
1005 cur.niceInsert(createMathInset("backslash"));
1006 } else if (c == '{') {
1008 cur.niceInsert(MathAtom(new MathBraceInset));
1009 } else if (c == '#') {
1010 lyxerr << "setting name to " << name + c << endl;
1011 BOOST_ASSERT(cur.activeMacro());
1012 cur.activeMacro()->setName(name + c);
1013 lyxerr << "set name to " << name + c << endl;
1016 cur.niceInsert(createMathInset(string(1, c)));
1021 // leave macro mode and try again if necessary
1022 cur.macroModeClose();
1024 cur.niceInsert(MathAtom(new MathBraceInset));
1030 // This is annoying as one has to press <space> far too often.
1034 // leave autocorrect mode if necessary
1035 if (autocorrect() && c == ' ') {
1036 autocorrect() = false;
1041 // just clear selection on pressing the space bar
1042 if (cur.selection() && c == ' ') {
1043 cur.selection() = false;
1050 //lyxerr << "starting with macro" << endl;
1051 cur.insert(MathAtom(new MathUnknownInset("\\", false)));
1056 if (currentMode() == MathInset::TEXT_MODE)
1062 if (currentMode() == MathInset::TEXT_MODE) {
1063 // insert spaces in text mode,
1064 // but suppress direct insertion of two spaces in a row
1065 // the still allows typing '<space>a<space>' and deleting the 'a', but
1066 // it is better than nothing...
1067 if (!cur.pos() != 0 || cur.prevAtom()->getChar() != ' ')
1071 if (cur.pos() != 0 && cur.prevAtom()->asSpaceInset()) {
1072 cur.prevAtom().nucleus()->asSpaceInset()->incSpace();
1077 // if are at the very end, leave the formula
1078 return cur.pos() != cur.lastpos();
1091 if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#') {
1092 cur.niceInsert(createMathInset(string(1, c)));
1097 cur.niceInsert(MathAtom(new MathCommentInset));
1101 // try auto-correction
1102 //if (autocorrect() && hasPrevAtom() && math_autocorrect(prevAtom(), c))
1105 // no special circumstances, so insert the character without any fuss
1107 cur.autocorrect() = true;
1112 bool MathNestInset::script(LCursor & cur, bool up)
1114 // Hack to get \\^ and \\_ working
1115 lyxerr << "handling script: up: " << up << endl;
1116 if (cur.inMacroMode() && cur.macroName() == "\\") {
1118 cur.niceInsert(createMathInset("mathcircumflex"));
1120 interpret(cur, '_');
1124 cur.macroModeClose();
1125 string safe = grabAndEraseSelection(cur);
1126 if (asScriptInset() && cur.idx() == 0) {
1127 // we are in a nucleus of a script inset, move to _our_ script
1128 MathScriptInset * inset = asScriptInset();
1129 lyxerr << " going to cell " << inset->idxOfScript(up) << endl;
1131 cur.idx() = inset->idxOfScript(up);
1133 } else if (cur.pos() != 0 && cur.prevAtom()->asScriptInset()) {
1135 MathScriptInset * inset = cur.nextAtom().nucleus()->asScriptInset();
1137 cur.idx() = inset->idxOfScript(up);
1138 cur.pos() = cur.lastpos();
1140 // convert the thing to our left to a scriptinset or create a new
1141 // one if in the very first position of the array
1142 if (cur.pos() == 0) {
1143 lyxerr << "new scriptinset" << endl;
1144 cur.insert(new MathScriptInset(up));
1146 lyxerr << "converting prev atom " << endl;
1147 cur.prevAtom() = MathAtom(new MathScriptInset(cur.prevAtom(), up));
1149 lyxerr << "new scriptinset 2: cur:\n" << cur << endl;
1151 lyxerr << "new scriptinset 3: cur:\n" << cur << endl;
1152 MathScriptInset * inset = cur.nextAtom().nucleus()->asScriptInset();
1153 lyxerr << "new scriptinset 3: inset:\n" << inset << endl;
1158 lyxerr << "pasting 1: safe:\n" << safe << endl;
1161 lyxerr << "pasting 2: safe:\n" << safe << endl;