]> git.lyx.org Git - lyx.git/commitdiff
fix super/subscript crash
authorAndré Pönitz <poenitz@gmx.net>
Tue, 3 Feb 2004 14:29:00 +0000 (14:29 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 3 Feb 2004 14:29:00 +0000 (14:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8393 a592a061-630c-0410-9148-cb99ea01b6c8

src/cursor.C
src/lyxfunc.C
src/mathed/math_data.C
src/mathed/math_nestinset.C

index 854886481bdc481dd8f368ec4520d763f2f0b084..4fea08cdf8ccef568945689fb4ee4b61efdc98c8 100644 (file)
@@ -303,7 +303,8 @@ void LCursor::getPos(int & x, int & y) const
                // inset.yo_, so getCursor() returns an old value.
                // Ugly as you like.
        }
-       lyxerr << "#### LCursor::getPos: x: " << x << " y: " << y << endl;
+       //lyxerr << "#### LCursor::getPos: " << *this 
+       // << " x: " << x << " y: " << y << endl;
 }
 
 
@@ -1313,7 +1314,7 @@ void LCursor::normalize()
                       << idx() << ' ' << nargs()
                       << " in: " << inset() << endl;
        }
-       idx() = min(idx(), nargs() - 1);
+       idx() = min(idx(), lastidx());
 
        if (pos() > lastpos()) {
                lyxerr << "this should not really happen - 2: "
@@ -1537,22 +1538,22 @@ bool LCursor::script(bool up)
                idx() = up;
                pos() = 0;
        } else if (pos() != 0 && prevAtom()->asScriptInset()) {
-               prevAtom().nucleus()->asScriptInset()->ensure(up);
-               posLeft();
-               push(inset());
+               --pos();
+               nextAtom().nucleus()->asScriptInset()->ensure(up);
+               push(nextInset());
                idx() = up;
                pos() = lastpos();
        } else if (pos() != 0) {
                --pos();
                cell()[pos()] = MathAtom(new MathScriptInset(nextAtom(), up));
-               push(inset());
+               push(nextInset());
                idx() = up;
                pos() = 0;
        } else {
                plainInsert(MathAtom(new MathScriptInset(up)));
-               posLeft();
+               --pos();
                nextAtom().nucleus()->asScriptInset()->ensure(up);
-               push(inset());
+               push(nextInset());
                idx() = up;
                pos() = 0;
        }
@@ -1563,7 +1564,7 @@ bool LCursor::script(bool up)
 
 bool LCursor::interpret(char c)
 {
-       lyxerr << "interpret 2: '" << c << "'" << endl;
+       //lyxerr << "interpret 2: '" << c << "'" << endl;
        clearTargetX();
        if (inMacroArgMode()) {
                posLeft();
index 0b55b74c009539dc2adcc308ca53e6671b042f6c..eee8bb805e99b32a84bb66e41fb365caf3489c8c 100644 (file)
@@ -162,13 +162,7 @@ void LyXFunc::handleKeyFunc(kb_action action)
 
 void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
 {
-       string argument;
-
-       if (lyxerr.debugging(Debug::KEY)) {
-               lyxerr << "KeySym is "
-                      << keysym->getSymbolName()
-                      << endl;
-       }
+       lyxerr[Debug::KEY] << "KeySym is " << keysym->getSymbolName() << endl;
 
        // Do nothing if we have nothing (JMarc)
        if (!keysym->isOK()) {
@@ -254,9 +248,11 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
                if (encoded_last_key != 0) {
                        string arg;
                        arg += encoded_last_key;
+                       lyxerr << "SelfInsert arg[`"
+                                  << arg << "']" << endl;
                        dispatch(FuncRequest(LFUN_SELFINSERT, arg));
-                       lyxerr[Debug::KEY] << "SelfInsert arg[`"
-                                  << argument << "']" << endl;
+                       lyxerr[Debug::KEY]
+                               << "SelfInsert arg[`" << arg << "']" << endl;
                }
        } else {
                dispatch(func);
index d8a1f31902a37edc45d846b8eeaa8ff922483a83..7617621047e771cd031f7eaa09e28b1375f5cda7 100644 (file)
@@ -314,8 +314,8 @@ int MathArray::pos2x(size_type pos, int glue) const
                const_iterator it = begin() + i;
                if ((*it)->getChar() == ' ')
                        x += glue;
-               lyxerr << "char: " << (*it)->getChar()
-                       << "width: " << (*it)->width() << std::endl;
+               //lyxerr << "char: " << (*it)->getChar()
+               //      << "width: " << (*it)->width() << std::endl;
                x += (*it)->width();
        }
        return x;
index d99f9fa30e366608cc25fbfd7d5e8d5a00d8fba8..8e1ba41b5f805eeb138a5c0ed30be88ea97397aa 100644 (file)
@@ -79,9 +79,6 @@ void MathNestInset::getCursorPos(CursorSlice const & cur,
        // move cursor visually into empty cells ("blue rectangles");
        if (cur.cell().empty())
                x += 2;
-       lyxerr << "MathNestInset::getCursorPos: cur: " << cur
-               << " x: " << x << " y: " << y << endl;
-       BOOST_ASSERT(x < 100000);
 }
 
 
@@ -103,7 +100,7 @@ void MathNestInset::metrics(MetricsInfo const & mi) const
 bool MathNestInset::idxNext(LCursor & cur) const
 {
        BOOST_ASSERT(cur.inset() == this);
-       if (cur.idx() + 1 >= nargs())
+       if (cur.idx() == cur.lastidx())
                return false;
        ++cur.idx();
        cur.pos() = 0;
@@ -150,7 +147,7 @@ bool MathNestInset::idxLast(LCursor & cur) const
        BOOST_ASSERT(cur.inset() == this);
        if (nargs() == 0)
                return false;
-       cur.idx() = nargs() - 1;
+       cur.idx() = cur.lastidx();
        cur.pos() = cur.lastpos();
        return true;
 }