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_symbolinset.h"
29 #include "math_support.h"
30 #include "math_unknowninset.h"
32 #include "BufferView.h"
33 #include "CutAndPaste.h"
34 #include "FuncStatus.h"
36 #include "bufferview_funcs.h"
39 #include "dispatchresult.h"
40 #include "funcrequest.h"
42 #include "outputparams.h"
45 #include "support/lstrings.h"
47 #include "frontends/Dialogs.h"
48 #include "frontends/LyXView.h"
49 #include "frontends/Painter.h"
53 using lyx::cap::copySelection;
54 using lyx::cap::grabAndEraseSelection;
55 using lyx::cap::cutSelection;
56 using lyx::cap::pasteSelection;
57 using lyx::cap::replaceSelection;
58 using lyx::cap::selClearOrDel;
62 using std::istringstream;
77 MathNestInset::MathNestInset(idx_type nargs)
78 : cells_(nargs), lock_(false)
82 MathInset::idx_type MathNestInset::nargs() const
88 MathArray & MathNestInset::cell(idx_type i)
94 MathArray const & MathNestInset::cell(idx_type i) const
100 void MathNestInset::getCursorPos(LCursor const & cur, int & x, int & y) const
102 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
103 MathArray const & ar = cur.cell();
104 x = ar.xo() + ar.pos2x(cur.pos());
105 y = ar.yo() + cur.bv().top_y();
106 // move cursor visually into empty cells ("blue rectangles");
107 if (cur.cell().empty())
112 void MathNestInset::metrics(MetricsInfo const & mi) const
115 for (idx_type i = 0; i < nargs(); ++i)
120 bool MathNestInset::idxNext(LCursor & cur) const
122 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
123 if (cur.idx() == cur.lastidx())
131 bool MathNestInset::idxRight(LCursor & cur) const
137 bool MathNestInset::idxPrev(LCursor & cur) const
139 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
143 cur.pos() = cur.lastpos();
148 bool MathNestInset::idxLeft(LCursor & cur) const
154 bool MathNestInset::idxFirst(LCursor & cur) const
156 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
165 bool MathNestInset::idxLast(LCursor & cur) const
167 BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
170 cur.idx() = cur.lastidx();
171 cur.pos() = cur.lastpos();
176 void MathNestInset::dump() const
178 WriteStream os(lyxerr);
179 os << "---------------------------------------------\n";
182 for (idx_type i = 0; i < nargs(); ++i)
183 os << cell(i) << "\n";
184 os << "---------------------------------------------\n";
188 void MathNestInset::draw(PainterInfo & pi, int x, int y) const
192 pi.pain.fillRectangle(x, y - ascent(), width(), height(),
195 setPosCache(pi, x, y);
199 void MathNestInset::drawSelection(PainterInfo & pi, int x, int y) const
201 // FIXME: hack to get position cache warm
204 // this should use the x/y values given, not the cached values
205 LCursor & cur = pi.base.bv->cursor();
206 if (!cur.selection())
208 if (!ptr_cmp(&cur.inset(), this))
210 CursorSlice s1 = cur.selBegin();
211 CursorSlice s2 = cur.selEnd();
212 //lyxerr << "MathNestInset::drawing selection: "
213 // << " s1: " << s1 << " s2: " << s2 << endl;
214 if (s1.idx() == s2.idx()) {
215 MathArray const & c = cell(s1.idx());
216 int x1 = c.xo() + c.pos2x(s1.pos());
217 int y1 = c.yo() - c.ascent();
218 int x2 = c.xo() + c.pos2x(s2.pos());
219 int y2 = c.yo() + c.descent();
220 pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
221 //lyxerr << "MathNestInset::drawing selection 3: "
222 // << " x1: " << x1 << " x2: " << x2
223 // << " y1: " << y1 << " y2: " << y2 << endl;
225 for (idx_type i = 0; i < nargs(); ++i) {
226 if (idxBetween(i, s1.idx(), s2.idx())) {
227 MathArray const & c = cell(i);
229 int y1 = c.yo() - c.ascent();
230 int x2 = c.xo() + c.width();
231 int y2 = c.yo() + c.descent();
232 pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
239 void MathNestInset::validate(LaTeXFeatures & features) const
241 for (idx_type i = 0; i < nargs(); ++i)
242 cell(i).validate(features);
246 void MathNestInset::replace(ReplaceData & rep)
248 for (idx_type i = 0; i < nargs(); ++i)
249 cell(i).replace(rep);
253 bool MathNestInset::contains(MathArray const & ar) const
255 for (idx_type i = 0; i < nargs(); ++i)
256 if (cell(i).contains(ar))
262 bool MathNestInset::lock() const
268 void MathNestInset::lock(bool l)
274 bool MathNestInset::isActive() const
280 MathArray MathNestInset::glue() const
283 for (size_t i = 0; i < nargs(); ++i)
289 void MathNestInset::write(WriteStream & os) const
291 os << '\\' << name().c_str();
292 for (size_t i = 0; i < nargs(); ++i)
293 os << '{' << cell(i) << '}';
295 os.pendingSpace(true);
296 if (lock_ && !os.latex()) {
298 os.pendingSpace(true);
303 void MathNestInset::normalize(NormalStream & os) const
305 os << '[' << name().c_str();
306 for (size_t i = 0; i < nargs(); ++i)
307 os << ' ' << cell(i);
312 int MathNestInset::latex(Buffer const &, std::ostream & os,
313 OutputParams const & runparams) const
315 WriteStream wi(os, runparams.moving_arg, true);
321 void MathNestInset::notifyCursorLeaves(LCursor & /*cur*/)
327 MathArray & ar = cur.cell();
328 // remove base-only "scripts"
329 for (pos_type i = 0; i + 1 < ar.size(); ++i) {
330 MathScriptInset * p = operator[](i).nucleus()->asScriptInset();
331 if (p && p->nargs() == 1) {
332 MathArray ar = p->nuc();
335 cur.adjust(i, ar.size() - 1);
339 // glue adjacent font insets of the same kind
340 for (pos_type i = 0; i + 1 < size(); ++i) {
341 MathFontInset * p = operator[](i).nucleus()->asFontInset();
342 MathFontInset const * q = operator[](i + 1)->asFontInset();
343 if (p && q && p->name() == q->name()) {
344 p->cell(0).append(q->cell(0));
353 void MathNestInset::handleFont
354 (LCursor & cur, string const & arg, string const & font)
356 // this whole function is a hack and won't work for incremental font
358 recordUndo(cur, Undo::ATOMIC);
360 if (cur.inset().asMathInset()->name() == font)
361 cur.handleFont(font);
363 cur.handleNest(createMathInset(font));
369 void MathNestInset::handleFont2(LCursor & cur, string const & arg)
371 recordUndo(cur, Undo::ATOMIC);
374 bv_funcs::string2font(arg, font, b);
375 if (font.color() != LColor::inherit) {
376 MathAtom at = createMathInset("color");
377 asArray(lcolor.getGUIName(font.color()), at.nucleus()->cell(0));
378 cur.handleNest(at, 1);
383 void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
385 //lyxerr << "MathNestInset: request: " << cmd << std::endl;
386 //CursorSlice sl = cur.current();
388 switch (cmd.action) {
392 cur.message(_("Paste"));
393 replaceSelection(cur);
395 istringstream is(cmd.argument);
397 pasteSelection(cur, n);
398 cur.clearSelection(); // bug 393
399 cur.bv().switchKeyMap();
405 cutSelection(cur, true, true);
406 cur.message(_("Cut"));
411 cur.message(_("Copy"));
414 case LFUN_MOUSE_PRESS:
415 lfunMousePress(cur, cmd);
418 case LFUN_MOUSE_MOTION:
419 lfunMouseMotion(cur, cmd);
422 case LFUN_MOUSE_RELEASE:
423 lfunMouseRelease(cur, cmd);
426 case LFUN_FINISHED_LEFT:
427 cur.bv().cursor() = cur;
430 case LFUN_FINISHED_RIGHT:
432 cur.bv().cursor() = cur;
435 case LFUN_FINISHED_UP:
436 cur.bv().cursor() = cur;
439 case LFUN_FINISHED_DOWN:
440 cur.bv().cursor() = cur;
445 cur.selHandle(cmd.action == LFUN_RIGHTSEL);
446 cur.autocorrect() = false;
448 cur.macroModeClose();
449 if (cur.pos() != cur.lastpos() && cur.openable(cur.nextAtom())) {
450 cur.pushLeft(*cur.nextAtom().nucleus());
451 cur.inset().idxFirst(cur);
452 } else if (cur.posRight() || idxRight(cur)
453 || cur.popRight() || cur.selection())
456 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
461 cur.selHandle(cmd.action == LFUN_LEFTSEL);
462 cur.autocorrect() = false;
464 cur.macroModeClose();
465 if (cur.pos() != 0 && cur.openable(cur.prevAtom())) {
467 cur.push(*cur.nextAtom().nucleus());
468 cur.inset().idxLast(cur);
469 } else if (cur.posLeft() || idxLeft(cur)
470 || cur.popLeft() || cur.selection())
473 cmd = FuncRequest(LFUN_FINISHED_LEFT);
478 cur.selHandle(cmd.action == LFUN_UPSEL);
480 cmd = FuncRequest(LFUN_FINISHED_UP);
485 cur.selHandle(cmd.action == LFUN_DOWNSEL);
487 cmd = FuncRequest(LFUN_FINISHED_DOWN);
490 case LFUN_MOUSE_DOUBLE:
491 case LFUN_MOUSE_TRIPLE:
496 cur.selection() = true;
497 cur.pos() = cur.lastpos();
498 cur.idx() = cur.lastidx();
501 case LFUN_UP_PARAGRAPHSEL:
502 case LFUN_UP_PARAGRAPH:
503 case LFUN_DOWN_PARAGRAPHSEL:
504 case LFUN_DOWN_PARAGRAPH:
509 case LFUN_WORDLEFTSEL:
511 cur.selHandle(cmd.action == LFUN_WORDLEFTSEL || cmd.action == LFUN_HOMESEL);
512 cur.macroModeClose();
513 if (cur.pos() != 0) {
515 } else if (cur.col() != 0) {
516 cur.idx() -= cur.col();
518 } else if (cur.idx() != 0) {
522 cmd = FuncRequest(LFUN_FINISHED_LEFT);
526 case LFUN_WORDRIGHTSEL:
530 cur.selHandle(cmd.action == LFUN_WORDRIGHTSEL || cmd.action == LFUN_ENDSEL);
531 cur.macroModeClose();
533 if (cur.pos() != cur.lastpos()) {
534 cur.pos() = cur.lastpos();
535 } else if (cur.col() != cur.lastcol()) {
536 cur.idx() = cur.idx() - cur.col() + cur.lastcol();
537 cur.pos() = cur.lastpos();
538 } else if (cur.idx() != cur.lastidx()) {
539 cur.idx() = cur.lastidx();
540 cur.pos() = cur.lastpos();
542 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
548 cmd = FuncRequest(LFUN_FINISHED_LEFT);
553 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
556 case LFUN_CELL_FORWARD:
557 cur.inset().idxNext(cur);
560 case LFUN_CELL_BACKWARD:
561 cur.inset().idxPrev(cur);
564 case LFUN_DELETE_WORD_BACKWARD:
566 recordUndo(cur, Undo::ATOMIC);
570 case LFUN_DELETE_WORD_FORWARD:
574 cmd = FuncRequest(LFUN_FINISHED_LEFT);
579 cur.clearSelection();
581 cmd = FuncRequest(LFUN_FINISHED_LEFT);
584 case LFUN_INSET_TOGGLE:
587 if (cur.pos() != cur.lastpos()) {
588 // toggle previous inset ...
589 cur.nextAtom().nucleus()->lock(!cur.nextAtom()->lock());
590 } else if (cur.popLeft() && cur.pos() != cur.lastpos()) {
591 // ... or enclosing inset if we are in the last inset position
592 cur.nextAtom().nucleus()->lock(!cur.nextAtom()->lock());
597 case LFUN_SELFINSERT:
599 if (cmd.argument.size() != 1) {
600 cur.insert(cmd.argument);
603 if (!interpret(cur, cmd.argument[0]))
604 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
608 // sprintf(dispatch_buffer, "%d %d",);
612 lyxerr << "LFUN_SETXY broken!" << endl;
615 istringstream is(cmd.argument);
617 cur.setScreenPos(x, y);
621 // Special casing for superscript in case of LyX handling
623 case LFUN_CIRCUMFLEX:
624 if (cmd.argument.empty()) {
625 // do superscript if LyX handles
627 recordUndo(cur, Undo::ATOMIC);
645 case LFUN_HUNG_UMLAUT:
649 case LFUN_FREEFONT_APPLY:
650 case LFUN_FREEFONT_UPDATE:
651 handleFont2(cur, cmd.argument);
655 handleFont(cur, cmd.argument, "mathbf");
658 handleFont(cur, cmd.argument, "mathsf");
661 handleFont(cur, cmd.argument, "mathcal");
664 handleFont(cur, cmd.argument, "mathrm");
667 handleFont(cur, cmd.argument, "texttt");
670 handleFont(cur, cmd.argument, "mathfrak");
673 handleFont(cur, cmd.argument, "mathit");
676 handleFont(cur, cmd.argument, "mathbb");
678 //case LFUN_FREEFONT_APPLY:
679 handleFont(cur, cmd.argument, "textrm");
682 handleFont(cur, cmd.argument, "textnormal");
687 cur.macroModeClose();
689 cur.plainInsert(MathAtom(new MathMBoxInset(cur.bv())));
691 cur.pushLeft(*cur.nextInset());
693 if (currentMode() == InsetBase::TEXT_MODE) {
694 cur.niceInsert(MathAtom(new MathHullInset("simple")));
695 cur.message(_("create new math text environment ($...$)"));
697 handleFont(cur, cmd.argument, "textrm");
698 cur.message(_("entered math text mode (textrm)"));
710 case LFUN_INSERT_MATRIX: {
711 recordUndo(cur, Undo::ATOMIC);
716 istringstream is(cmd.argument);
717 is >> m >> n >> v_align >> h_align;
724 MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
728 case LFUN_MATH_DELIM: {
729 lyxerr << "MathNestInset::LFUN_MATH_DELIM" << endl;
731 string rs = lyx::support::split(cmd.argument, ls, ' ');
732 // Reasonable default values
737 recordUndo(cur, Undo::ATOMIC);
738 cur.handleNest(MathAtom(new MathDelimInset(ls, rs)));
742 case LFUN_SPACE_INSERT:
743 case LFUN_MATH_SPACE:
744 recordUndo(cur, Undo::ATOMIC);
745 cur.insert(MathAtom(new MathSpaceInset(",")));
749 // interpret this as if a backslash was typed
750 recordUndo(cur, Undo::ATOMIC);
751 interpret(cur, '\\');
754 // FIXME: We probably should swap parts of "math-insert" and "self-insert"
755 // handling such that "self-insert" works on "arbitrary stuff" too, and
756 // math-insert only handles special math things like "matrix".
757 case LFUN_INSERT_MATH:
758 recordUndo(cur, Undo::ATOMIC);
759 cur.niceInsert(cmd.argument);
762 case LFUN_DIALOG_SHOW_NEW_INSET: {
763 string const & name = cmd.argument;
768 data = tmp.createDialogStr(name);
771 cur.bv().owner()->getDialogs().show(name, data, 0);
775 case LFUN_INSET_APPLY: {
776 string const name = cmd.getArg(0);
777 InsetBase * base = cur.bv().owner()->getDialogs().getOpenInset(name);
780 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
781 base->dispatch(cur, fr);
785 if (createMathInset_fromDialogStr(cmd.argument, ar)) {
794 MathDimInset::priv_dispatch(cur, cmd);
800 bool MathNestInset::getStatus(LCursor & /*cur*/, FuncRequest const & cmd,
801 FuncStatus & flag) const
803 // the font related toggles
804 //string tc = "mathnormal";
806 switch (cmd.action) {
808 case LFUN_TABULAR_FEATURE:
809 // FIXME: check temporarily disabled
811 char align = mathcursor::valign();
816 if (cmd.argument.empty()) {
820 if (!contains("tcb", cmd.argument[0])) {
824 flag.setOnOff(cmd.argument[0] == align);
827 flag.setOnOff(tc == "mathbf");
830 flag.setOnOff(tc == "mathsf");
833 flag.setOnOff(tc == "mathcal");
836 flag.setOnOff(tc == "mathrm");
839 flag.setOnOff(tc == "mathtt");
842 flag.setOnOff(tc == "mathbb");
845 flag.setOnOff(tc == "mathnormal");
848 case LFUN_MATH_MUTATE:
849 //flag.setOnOff(mathcursor::formula()->hullType() == cmd.argument);
850 flag.setOnOff(false);
853 // we just need to be in math mode to enable that
855 case LFUN_MATH_SPACE:
856 case LFUN_MATH_LIMITS:
857 case LFUN_MATH_NONUMBER:
858 case LFUN_MATH_NUMBER:
859 case LFUN_MATH_EXTERN:
871 void MathNestInset::edit(LCursor & cur, bool left)
874 cur.idx() = left ? 0 : cur.lastidx();
875 cur.pos() = left ? 0 : cur.lastpos();
877 lyxerr << "MathNestInset::edit, cur:\n" << cur << endl;
881 InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y) const
884 int dist_min = 1000000;
885 for (idx_type i = 0; i < nargs(); ++i) {
886 int d = cell(i).dist(x, y);
892 MathArray const & ar = cell(idx_min);
893 cur.push(const_cast<MathNestInset&>(*this));
895 cur.pos() = ar.x2pos(x - ar.xo());
896 lyxerr << "found cell : " << idx_min << " pos: " << cur.pos() << endl;
899 for (pos_type i = 0, n = ar.size(); i < n; ++i)
900 if (ar[i]->covers(x, y))
901 return ar[i].nucleus()->editXY(cur, x, y);
903 return const_cast<MathNestInset*>(this);
907 void MathNestInset::lfunMousePress(LCursor & cur, FuncRequest & cmd)
909 lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
910 if (cmd.button() == mouse_button::button1) {
913 lyxerr << "lfunMousePress: setting cursor to: " << cur << endl;
915 cur.bv().cursor() = cur;
918 if (cmd.button() == mouse_button::button2) {
919 cur.dispatch(FuncRequest(LFUN_PASTESELECTION));
924 void MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest & cmd)
926 // only select with button 1
927 if (cmd.button() == mouse_button::button1) {
928 LCursor & bvcur = cur.bv().cursor();
929 if (abs(cmd.x - first_x) + abs(cmd.y - first_y) > 4
930 && bvcur.anchor_.hasPart(cur)) {
934 bvcur.setCursor(cur);
935 bvcur.selection() = true;
941 void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
943 lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
945 if (cmd.button() == mouse_button::button1) {
946 //cur.bv().stuffClipboard(cur.grabSelection());
950 if (cmd.button() == mouse_button::button2) {
952 asArray(cur.bv().getClipboard(), ar);
953 cur.clearSelection();
954 cur.setScreenPos(cmd.x, cmd.y);
960 if (cmd.button() == mouse_button::button3) {
961 // try to dispatch to enclosed insets first
962 cur.bv().owner()->getDialogs().show("mathpanel");
970 bool MathNestInset::interpret(LCursor & cur, char c)
972 lyxerr << "interpret 2: '" << c << "'" << endl;
976 if (cur.inMacroMode()) {
977 string name = cur.macroName();
979 /// are we currently typing '#1' or '#2' or...?
983 if (n >= 1 && n <= 9)
984 cur.insert(new MathMacroArgument(n));
989 cur.activeMacro()->setName(name + c);
993 // handle 'special char' macros
998 if (currentMode() == MathInset::TEXT_MODE)
999 cur.niceInsert(createMathInset("textbackslash"));
1001 cur.niceInsert(createMathInset("backslash"));
1002 } else if (c == '{') {
1004 cur.niceInsert(MathAtom(new MathBraceInset));
1005 } else if (c == '%') {
1007 cur.niceInsert(MathAtom(new MathCommentInset));
1008 } else if (c == '#') {
1009 BOOST_ASSERT(cur.activeMacro());
1010 cur.activeMacro()->setName(name + c);
1013 cur.niceInsert(createMathInset(string(1, c)));
1018 // leave macro mode and try again if necessary
1019 cur.macroModeClose();
1021 cur.niceInsert(MathAtom(new MathBraceInset));
1027 // This is annoying as one has to press <space> far too often.
1031 // leave autocorrect mode if necessary
1032 if (autocorrect() && c == ' ') {
1033 autocorrect() = false;
1038 // just clear selection on pressing the space bar
1039 if (cur.selection() && c == ' ') {
1040 cur.selection() = false;
1047 //lyxerr << "starting with macro" << endl;
1048 cur.insert(MathAtom(new MathUnknownInset("\\", false)));
1053 if (currentMode() == MathInset::TEXT_MODE)
1059 if (currentMode() == MathInset::TEXT_MODE) {
1060 // insert spaces in text mode,
1061 // but suppress direct insertion of two spaces in a row
1062 // the still allows typing '<space>a<space>' and deleting the 'a', but
1063 // it is better than nothing...
1064 if (!cur.pos() != 0 || cur.prevAtom()->getChar() != ' ')
1068 if (cur.pos() != 0 && cur.prevAtom()->asSpaceInset()) {
1069 cur.prevAtom().nucleus()->asSpaceInset()->incSpace();
1074 // if are at the very end, leave the formula
1075 return cur.pos() != cur.lastpos();
1088 if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#' || c == '%') {
1089 cur.niceInsert(createMathInset(string(1, c)));
1094 cur.niceInsert(createMathInset("sim"));
1098 // try auto-correction
1099 //if (autocorrect() && hasPrevAtom() && math_autocorrect(prevAtom(), c))
1102 // no special circumstances, so insert the character without any fuss
1104 cur.autocorrect() = true;
1109 bool MathNestInset::script(LCursor & cur, bool up)
1111 // Hack to get \^ and \_ working
1112 lyxerr << "handling script: up: " << up << endl;
1113 if (cur.inMacroMode() && cur.macroName() == "\\") {
1115 cur.niceInsert(createMathInset("mathcircumflex"));
1117 interpret(cur, '_');
1121 cur.macroModeClose();
1122 string safe = grabAndEraseSelection(cur);
1123 if (asScriptInset() && cur.idx() == 0) {
1124 // we are in a nucleus of a script inset, move to _our_ script
1125 MathScriptInset * inset = asScriptInset();
1126 lyxerr << " going to cell " << inset->idxOfScript(up) << endl;
1128 cur.idx() = inset->idxOfScript(up);
1130 } else if (cur.pos() != 0 && cur.prevAtom()->asScriptInset()) {
1132 MathScriptInset * inset = cur.nextAtom().nucleus()->asScriptInset();
1134 cur.idx() = inset->idxOfScript(up);
1135 cur.pos() = cur.lastpos();
1137 // convert the thing to our left to a scriptinset or create a new
1138 // one if in the very first position of the array
1139 if (cur.pos() == 0) {
1140 lyxerr << "new scriptinset" << endl;
1141 cur.insert(new MathScriptInset(up));
1143 lyxerr << "converting prev atom " << endl;
1144 cur.prevAtom() = MathAtom(new MathScriptInset(cur.prevAtom(), up));
1147 MathScriptInset * inset = cur.nextAtom().nucleus()->asScriptInset();
1152 lyxerr << "pasting 1: safe:\n" << safe << endl;
1155 lyxerr << "pasting 2: safe:\n" << safe << endl;