From db033af70049c1227039c3871c8d714b69d30583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 12 Oct 2001 15:38:58 +0000 Subject: [PATCH] fix x^1_ git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2876 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/formulabase.C | 6 ++++-- src/mathed/math_cursor.C | 16 ++++++++++++---- src/mathed/math_scriptinset.C | 16 ++++++++++++++++ src/mathed/math_scriptinset.h | 5 +++++ 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 38dda883f5..f233c7851d 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -16,6 +16,7 @@ #include #include "Lsstream.h" +#include "support/LAssert.h" #ifdef __GNUG__ #pragma implementation @@ -641,10 +642,11 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, result = UNDISPATCHED; } + lyx::Assert(mathcursor); //mathcursor->normalize(); - if (was_macro != mathcursor->inMacroMode() - && action >= 0 && action != LFUN_BACKSPACE) + if (//was_macro != mathcursor->inMacroMode() && + action >= 0 && action != LFUN_BACKSPACE) updateLocal(bv, true); if (mathcursor->selection() || was_selection) diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 4c8ec8081d..ee057dedc2 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -132,9 +132,10 @@ MathCursor::MathCursor(InsetFormulaBase * formula, bool left) void MathCursor::push(MathAtom & t) { - //cerr << "Entering atom "; t->write(cerr, false); cerr << " left\n"; MathCursorPos p; p.par_ = &t; + p.idx_ = 0; + p.pos_ = 0; Cursor_.push_back(p); } @@ -937,7 +938,10 @@ void MathCursor::normalize() const if (pos() > size()) { lyxerr << "this should not really happen - 2: " - << pos() << " " << size() << "\n"; + << pos() << " " << size() << " in idx: " << it->idx() + << " in atom: '"; + it->par()->write(lyxerr, false); + lyxerr << "\n"; dump("error 4"); } it->pos() = min(pos(), size()); @@ -1321,17 +1325,22 @@ void MathCursor::interpret(char c) if (hasPrevAtom() && prevAtom()->asScriptInset()) { prevAtom()->asScriptInset()->ensure(up); pushRight(prevAtom()); + idx() = up; pos() = size(); } else if (hasNextAtom() && nextAtom()->asScriptInset()) { nextAtom()->asScriptInset()->ensure(up); pushLeft(nextAtom()); + idx() = up; pos() = 0; } else { plainInsert(MathAtom(new MathScriptInset(up))); + prevAtom()->asScriptInset()->ensure(up); pushRight(prevAtom()); + idx() = up; + pos() = 0; } - idx() = up; selPaste(); + dump("1"); return; } @@ -1393,7 +1402,6 @@ void MathCursor::interpret(char c) else insert(c, LM_TC_VAR); -#warning greek insert problem? look here! if (lastcode_ == LM_TC_GREEK1) lastcode_ = LM_TC_VAR; return; diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index 305d22c86a..a0ce5ebbc5 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -294,3 +294,19 @@ bool MathScriptInset::hasDown() const { return script_[0]; } + + +bool MathScriptInset::idxRight(MathInset::idx_type &, + MathInset::pos_type &) const +{ + return false; +} + + +bool MathScriptInset::idxLeft(MathInset::idx_type &, + MathInset::pos_type &) const +{ + return false; +} + + diff --git a/src/mathed/math_scriptinset.h b/src/mathed/math_scriptinset.h index d4c5e62f40..59e0535a68 100644 --- a/src/mathed/math_scriptinset.h +++ b/src/mathed/math_scriptinset.h @@ -40,6 +40,11 @@ public: /// int width(MathInset const * nucleus) const; + /// + bool idxLeft(MathInset::idx_type &, MathInset::pos_type &) const; + /// + bool idxRight(MathInset::idx_type &, MathInset::pos_type &) const; + /// MathScriptInset const * asScriptInset() const; ///