]> git.lyx.org Git - features.git/commitdiff
^ now copies selection into new scriptinset
authorAndré Pönitz <poenitz@gmx.net>
Tue, 24 Jul 2001 16:10:17 +0000 (16:10 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 24 Jul 2001 16:10:17 +0000 (16:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2324 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/array.C
src/mathed/math_cursor.C
src/mathed/math_cursor.h

index 4bf8501ec1d7e31a2a1938d421db7fe22fe6ad1b..1034326f4adde433f27d20c5db91caddef16bd85 100644 (file)
@@ -8,6 +8,8 @@
 
        * formulabase.C: fix memory leak
 
+       * math_cursor.C: ^ now copies selection into new srriptinset
+
 2001-07-22  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * formula.C (insetAllowed): allow insertion of label
index c73d888503824b31a7b3ee2412e8415b3e94f189..c1cee61e430c1d9d3e96aaeb9b5970f7cf8dd1aa 100644 (file)
@@ -151,15 +151,15 @@ void MathArray::setCode(int pos, MathTextCodes t)
 }
 
 
-void MathArray::insert(int pos, MathInset * p)
+void MathArray::replace(int pos, MathInset * p)
 {
-       bf_.insert(bf_.begin() + pos, 2 + sizeof(p), LM_TC_INSET);
        memcpy(&bf_[pos + 1], &p, sizeof(p));
 }
 
 
-void MathArray::replace(int pos, MathInset * p)
+void MathArray::insert(int pos, MathInset * p)
 {
+       bf_.insert(bf_.begin() + pos, 2 + sizeof(p), LM_TC_INSET);
        memcpy(&bf_[pos + 1], &p, sizeof(p));
 }
 
index 27bb3006f04a424cb3bd89ae0d64fa3bdf9205bc..6ac93ae45ff85e1cf81d91c8cf1417d71abb9872 100644 (file)
@@ -628,29 +628,23 @@ void MathCursor::Interpret(string const & s)
        lyxerr << "Interpret: '" << s << "'  ('" << s.substr(0, 7)  << "' " <<
 in_word_set(s) << " \n";
 
-       if (s[0] == '^') {
-               MathUpDownInset * p = nearbyUpDownInset();
+       if (s[0] == '^' || s[0] == '_') {
+               bool const up = (s[0] == '^');
+               SelCut();       
+               MathUpDownInset * p = prevUpDownInset();
                if (!p) {
-                       p = new MathScriptInset(true, false);
+                       p = new MathScriptInset(up, !up);
                        insert(p);
                        plainLeft();
                }
                push(p, true);
-               p->up(true);
-               cursor().idx_ = 0;
-               return;
-       }
-
-       if (s[0] == '_') {
-               MathUpDownInset * p = nearbyUpDownInset();
-               if (!p) {
-                       p = new MathScriptInset(false, true);
-                       insert(p);
-                       plainLeft();
-               }
-               push(p, true);
-               p->down(true);
-               cursor().idx_ = 1;
+               if (up)
+                       p->up(true);
+               else
+                       p->down(true);
+               cursor().idx_ = up ? 0 : 1;
+               cursor().pos_ = 0;
+               SelPaste();
                return;
        }
 
@@ -1103,16 +1097,11 @@ MathInset * MathCursor::nextInset() const
 }
 
 
-MathUpDownInset * MathCursor::nearbyUpDownInset() const
+MathUpDownInset * MathCursor::prevUpDownInset() const
 {
        normalize();
        MathInset * p = array().prevInset(cursor().pos_);
-       if (p && p->isUpDownInset())
-               return static_cast<MathUpDownInset *>(p);
-       //p = array().nextInset(cursor().pos_);
-       //if (p && p->isUpDownInset())
-       //      return static_cast<MathUpDownInset *>(p);
-       return 0;
+       return (p && p->isUpDownInset()) ? static_cast<MathUpDownInset *>(p) : 0;
 }
 
 
index d0a71e46fc8338ce2f09c99f040b8e01744de14a..c8a7e574e41c4f88ca8e20b9a5914d182f337743 100644 (file)
@@ -258,7 +258,7 @@ public:
        ///
        MathInset * prevInset() const;
        ///
-       MathUpDownInset * nearbyUpDownInset() const;
+       MathUpDownInset * prevUpDownInset() const;
 
        ///
        MathFuncInset * imacro;