This is a regression from 1.3. It should be possible, both with ^ _ keys and with the math panel (and directly with the commands math-superscript and math-subscript), to raise the selection to a superscript or lower it to a subscript. Works in 1.3.7.
At the same time we get rid of The Abominable LCursor::paste() Method. Will go into trunk later if nobody spots a problem. - Martin
Index: cursor.C =================================================================== --- cursor.C (revision 13408) +++ cursor.C (working copy) @@ -379,15 +379,6 @@ void LCursor::getPos(int & x, int & y) c } -// Don't use this routine. It is erroneous: LFUN_PASTE should be called with -// buffer number, not data to be inserted -- MV 26.02.2006 -void LCursor::paste(string const & data) -{ - if (!data.empty()) - dispatch(FuncRequest(LFUN_PASTE, data)); -} - - void LCursor::resetAnchor() { anchor_ = *this; Index: mathed/math_nestinset.C =================================================================== --- mathed/math_nestinset.C (revision 13408) +++ mathed/math_nestinset.C (working copy) @@ -685,9 +685,13 @@ void MathNestInset::doDispatch(LCursor & cur.posLeft(); cur.pushLeft(*cur.nextInset()); } - } else if (!interpret(cur, cmd.argument[0])) { - cmd = FuncRequest(LFUN_FINISHED_RIGHT); - cur.undispatched(); + } else { + // single character, e.g. ^ or _ + safe_ = grabAndEraseSelection(cur); + if (!interpret(cur, cmd.argument[0])) { + cmd = FuncRequest(LFUN_FINISHED_RIGHT); + cur.undispatched(); + } } break; @@ -868,13 +872,16 @@ void MathNestInset::doDispatch(LCursor & case LFUN_SUBSCRIPT: // interpret this as if a _ was typed + // E.g., called from minibuffer (math-subscript) recordUndo(cur, Undo::ATOMIC); + safe_ = grabAndEraseSelection(cur); interpret(cur, '_'); break; case LFUN_SUPERSCRIPT: // interpret this as if a ^ was typed recordUndo(cur, Undo::ATOMIC); + safe_ = grabAndEraseSelection(cur); interpret(cur, '^'); break; @@ -882,13 +889,12 @@ void MathNestInset::doDispatch(LCursor & // handling such that "self-insert" works on "arbitrary stuff" too, and // math-insert only handles special math things like "matrix". case LFUN_INSERT_MATH: { + safe_ = grabAndEraseSelection(cur); recordUndo(cur, Undo::ATOMIC); - MathArray ar; - asArray(cmd.argument, ar); - int cell(0); - if (cmd.argument == "\\root") - cell = 1; - cur.niceInsert(cmd.argument); + if (cmd.argument.size() == 1) + interpret(cur, cmd.argument[0]); + else + cur.niceInsert(cmd.argument); break; } @@ -1246,7 +1252,6 @@ bool MathNestInset::script(LCursor & cur } 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(); @@ -1277,9 +1282,9 @@ bool MathNestInset::script(LCursor & cur cur.idx() = 1; cur.pos() = 0; } - //lyxerr << "pasting 1: safe:\n" << safe << endl; - cur.paste(safe); + //lyxerr << "pasting 1: safe:\n" << safe_ << endl; + cur.niceInsert(safe_); cur.resetAnchor(); - //lyxerr << "pasting 2: safe:\n" << safe << endl; + //lyxerr << "pasting 2: safe:\n" << safe_ << endl; return true; }
pgpM0IeScFCFh.pgp
Description: PGP signature