+
+ // try auto-correction
+ //if (autocorrect() && hasPrevAtom() && math_autocorrect(prevAtom(), c))
+ // return true;
+
+ // no special circumstances, so insert the character without any fuss
+ cur.insert(c);
+ cur.autocorrect() = true;
+ return true;
+}
+
+
+bool MathNestInset::script(LCursor & cur, bool up)
+{
+ // Hack to get \^ and \_ working
+ lyxerr << "handling script: up: " << up << endl;
+ if (cur.inMacroMode() && cur.macroName() == "\\") {
+ if (up)
+ cur.niceInsert(createMathInset("mathcircumflex"));
+ else
+ interpret(cur, '_');
+ return true;
+ }
+
+ cur.macroModeClose();
+ string safe = grabAndEraseSelection(cur);
+ if (asScriptInset() && cur.idx() == 0) {
+ // we are in a nucleus of a script inset, move to _our_ script
+ MathScriptInset * inset = asScriptInset();
+ lyxerr << " going to cell " << inset->idxOfScript(up) << endl;
+ inset->ensure(up);
+ cur.idx() = inset->idxOfScript(up);
+ cur.pos() = 0;
+ } else if (cur.pos() != 0 && cur.prevAtom()->asScriptInset()) {
+ --cur.pos();
+ MathScriptInset * inset = cur.nextAtom().nucleus()->asScriptInset();
+ cur.push(*inset);
+ inset->ensure(up);
+ cur.idx() = inset->idxOfScript(up);
+ cur.pos() = cur.lastpos();
+ } else {
+ // convert the thing to our left to a scriptinset or create a new
+ // one if in the very first position of the array
+ if (cur.pos() == 0) {
+ //lyxerr << "new scriptinset" << endl;
+ cur.insert(new MathScriptInset(up));
+ } else {
+ //lyxerr << "converting prev atom " << endl;
+ cur.prevAtom() = MathAtom(new MathScriptInset(cur.prevAtom(), up));
+ }
+ --cur.pos();
+ MathScriptInset * inset = cur.nextAtom().nucleus()->asScriptInset();
+ cur.push(*inset);
+ cur.idx() = 1;
+ cur.pos() = 0;
+ }
+ //lyxerr << "pasting 1: safe:\n" << safe << endl;
+ cur.paste(safe);
+ cur.resetAnchor();
+ //lyxerr << "pasting 2: safe:\n" << safe << endl;
+ return true;