]> git.lyx.org Git - features.git/commitdiff
Further revision of the raise/lower selection to super/subscript
authorMartin Vermeer <martin.vermeer@hut.fi>
Mon, 20 Mar 2006 14:42:04 +0000 (14:42 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Mon, 20 Mar 2006 14:42:04 +0000 (14:42 +0000)
patch, avoiding class data member for nestinset

* cursor.h: remove paste() (was forgotten)
* mathed/math_nestinset.C
(MathNestInset::doDispatch):
(MathNestInset::lfunMouseRelease):
(MathNestInset::interpret): incorporate saved selection into
script() call parameters
(MathNestInset::script): saved selection is extra parameter
* mathed/math_nestinset.h: extra parameter; remove safe_

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13431 a592a061-630c-0410-9148-cb99ea01b6c8

src/cursor.h
src/mathed/math_nestinset.C
src/mathed/math_nestinset.h

index 1ec6255b0b8ee38b220ec36607e04eead5e542d3..d02952f0af2c8cec78a886c812fc9a106c58b641 100644 (file)
@@ -88,8 +88,6 @@ public:
        //
        std::string selectionAsString(bool label) const;
        ///
-       void paste(std::string const & data);
-       ///
        std::string currentState();
 
        /// auto-correct mode
index f232a6ecec3c221fa9f6a07a5594d42dfba91312..b69ce7b9d08db33536cc33cb55de3eab4682a22a 100644 (file)
@@ -712,8 +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);
+                       script(cur, true, grabAndEraseSelection(cur));
                }
                break;
 
@@ -792,19 +791,19 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                handleFont(cur, cmd.argument, "textnormal");
                break;
 
-       case LFUN_MATH_MODE:
+       case LFUN_MATH_MODE: {
 #if 1
                // ignore math-mode on when already in math mode
                if (currentMode() == InsetBase::MATH_MODE && cmd.argument == "on")
                        break;
                cur.macroModeClose();
-               safe_ = grabAndEraseSelection(cur);
+               string const save_selection = grabAndEraseSelection(cur);
                selClearOrDel(cur);
                //cur.plainInsert(MathAtom(new MathMBoxInset(cur.bv())));
                cur.plainInsert(MathAtom(new MathBoxInset("mbox")));
                cur.posLeft();
                cur.pushLeft(*cur.nextInset());
-               cur.niceInsert(safe_);
+               cur.niceInsert(save_selection);
 #else
                if (currentMode() == InsetBase::TEXT_MODE) {
                        cur.niceInsert(MathAtom(new MathHullInset("simple")));
@@ -815,6 +814,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                }
 #endif
                break;
+       }
 
        case LFUN_MATH_SIZE:
 #if 0
@@ -1095,8 +1095,9 @@ void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
 bool MathNestInset::interpret(LCursor & cur, char c)
 {
        //lyxerr << "interpret 2: '" << c << "'" << endl;
+       string save_selection;
        if (c == '^' || c == '_')
-               safe_ = grabAndEraseSelection(cur);
+               save_selection = grabAndEraseSelection(cur);
 
        cur.clearTargetX();
 
@@ -1206,11 +1207,11 @@ bool MathNestInset::interpret(LCursor & cur, char c)
        // These shouldn't work in text mode:
        if (currentMode() != MathInset::TEXT_MODE) {
                if (c == '_') {
-                       script(cur, false);
+                       script(cur, false, save_selection);
                        return true;
                }
                if (c == '^') {
-                       script(cur, true);
+                       script(cur, true, save_selection);
                        return true;
                }
                if (c == '~') {
@@ -1237,7 +1238,8 @@ bool MathNestInset::interpret(LCursor & cur, char c)
 }
 
 
-bool MathNestInset::script(LCursor & cur, bool up)
+bool MathNestInset::script(LCursor & cur, bool up, string const &
+               save_selection)
 {
        // Hack to get \^ and \_ working
        lyxerr << "handling script: up: " << up << endl;
@@ -1280,9 +1282,9 @@ bool MathNestInset::script(LCursor & cur, bool up)
                cur.idx() = 1;
                cur.pos() = 0;
        }
-       //lyxerr << "inserting 1: safe:\n" << safe_ << endl;
-       cur.niceInsert(safe_);
+       //lyxerr << "inserting selection 1:\n" << save_selection << endl;
+       cur.niceInsert(save_selection);
        cur.resetAnchor();
-       //lyxerr << "inserting 2: safe:\n" << safe_ << endl;
+       //lyxerr << "inserting selection 2:\n" << save_selection << endl;
        return true;
 }
index dda150a6dbd282394c9db5e78100b38163bc496e..36dc7e0aa0a65f2bd62ab90b11735047fc19b359 100644 (file)
@@ -110,7 +110,8 @@ protected:
        ///
        bool interpret(LCursor & cur, char c);
        ///
-       bool script(LCursor & cur, bool);
+       bool script(LCursor & cur, bool, 
+               std::string const & save_selection = std::string());
 
 
 private:
@@ -128,8 +129,6 @@ protected:
        cells_type cells_;
        /// if the inset is locked, it can't be entered with the cursor
        bool lock_;
-       ///
-       std::string safe_;
 };
 
 #endif