From 2c30e9b17afc036515a3d23fb657c4f55815d7c5 Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Mon, 20 Mar 2006 06:53:29 +0000 Subject: [PATCH] Get raising/lowering into super/subscripts of selection working (1.3 regression) * cursor.C: get rid of paste() * mathed/math_nestinset.C (MathNestInset::doDispatch): (MathNestInset::lfunMouseRelease): define safe_ (selection) in several places (MathNestInset::script): use data member safe_ to insert selection * mathed/math_nestinset.h: data member safe_ git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13424 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/cursor.C | 9 --------- src/mathed/math_nestinset.C | 21 +++++++++++---------- src/mathed/math_nestinset.h | 2 ++ 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/cursor.C b/src/cursor.C index b9e0c54382..1bbae28a5c 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -379,15 +379,6 @@ void LCursor::getPos(int & x, int & y) const } -// 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; diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index 0732cd20a1..3d54c3f35b 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -712,6 +712,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd) // do superscript if LyX handles // deadkeys recordUndo(cur, Undo::ATOMIC); + safe_ = grabAndEraseSelection(cur); script(cur, true); } break; @@ -883,12 +884,10 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd) // math-insert only handles special math things like "matrix". case LFUN_INSERT_MATH: { 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 == "^" || cmd.argument == "_") { + interpret(cur, cmd.argument[0]); + } else + cur.niceInsert(cmd.argument); break; } @@ -1094,6 +1093,9 @@ void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest & cmd) bool MathNestInset::interpret(LCursor & cur, char c) { //lyxerr << "interpret 2: '" << c << "'" << endl; + if (c == '^' || c == '_') + safe_ = grabAndEraseSelection(cur); + cur.clearTargetX(); // handle macroMode @@ -1246,7 +1248,6 @@ bool MathNestInset::script(LCursor & cur, bool up) } 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 +1278,9 @@ bool MathNestInset::script(LCursor & cur, bool up) cur.idx() = 1; cur.pos() = 0; } - //lyxerr << "pasting 1: safe:\n" << safe << endl; - cur.paste(safe); + //lyxerr << "inserting 1: safe:\n" << safe_ << endl; + cur.niceInsert(safe_); cur.resetAnchor(); - //lyxerr << "pasting 2: safe:\n" << safe << endl; + //lyxerr << "inserting 2: safe:\n" << safe_ << endl; return true; } diff --git a/src/mathed/math_nestinset.h b/src/mathed/math_nestinset.h index 72bdcd4536..dda150a6db 100644 --- a/src/mathed/math_nestinset.h +++ b/src/mathed/math_nestinset.h @@ -128,6 +128,8 @@ protected: cells_type cells_; /// if the inset is locked, it can't be entered with the cursor bool lock_; + /// + std::string safe_; }; #endif