]> git.lyx.org Git - features.git/commitdiff
fix #1654
authorAndré Pönitz <poenitz@gmx.net>
Fri, 13 Aug 2004 12:05:27 +0000 (12:05 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 13 Aug 2004 12:05:27 +0000 (12:05 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8898 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/CutAndPaste.C
src/cursor.C
src/mathed/math_nestinset.C

index c496dc6f7b83d286f4109cd6cb000ef8161664e4..9da3aa7317ae9597b38296bd13ea4bdeb7bf657d 100644 (file)
@@ -1,7 +1,10 @@
 
 2004-08-13  André Pönitz  <poenitz@gmx.net>
 
-       * cursor.C: macroModeClose: use plainInsert instead of niceInsert.
+       * cursor.C (macroModeClose): use plainInsert instead of niceInsert.
+
+       * CutAndPaste.C (eraseSelection): fix cursor position after erasing
+         multiple cells
    
 2004-08-12  André Pönitz  <poenitz@gmx.net>
 
index dd9affac0695be1141aca98285b227ced2dde389..4f422ae268d751360fd428b581edf150ef2c4306 100644 (file)
@@ -639,12 +639,9 @@ void replaceWord(LCursor & cur, string const & replacestring)
 
 void eraseSelection(LCursor & cur)
 {
-       //lyxerr << "LCursor::eraseSelection" << endl;
+       //lyxerr << "LCursor::eraseSelection begin: " << cur << endl;
        CursorSlice const & i1 = cur.selBegin();
        CursorSlice const & i2 = cur.selEnd();
-#ifdef WITH_WARNINGS
-#warning FIXME
-#endif
        if (i1.inset().asMathInset()) {
                if (i1.idx() == i2.idx()) {
                        i1.cell().erase(i1.pos(), i2.pos());
@@ -658,10 +655,12 @@ void eraseSelection(LCursor & cur)
                                        p->cell(p->index(row, col)).clear();
                }
                cur.back() = i1;
+               cur.pos() = 0; // We've deleted the whole cell. Only pos 0 is valid.
+               cur.resetAnchor();
        } else {
                lyxerr << "can't erase this selection 1" << endl;
        }
-       //lyxerr << "LCursor::eraseSelection end" << endl;
+       //lyxerr << "LCursor::eraseSelection end: " << cur << endl;
 }
 
 
index b29605efe336dc0fd99d1e7bc0acb8980c047183..c2de922fb858c1633c51d2219f7dcf1da04a5321 100644 (file)
@@ -94,7 +94,7 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
        LCursor safe = *this;
 
        for ( ; size(); pop()) {
-               //lyxerr << "LCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
+               lyxerr << "LCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
                BOOST_ASSERT(pos() <= lastpos());
                BOOST_ASSERT(idx() <= lastidx());
                BOOST_ASSERT(par() <= lastpar());
@@ -397,6 +397,7 @@ void LCursor::selHandle(bool sel)
 
 std::ostream & operator<<(std::ostream & os, LCursor const & cur)
 {
+       os << "\n cursor:                                | anchor:\n";
        for (size_t i = 0, n = cur.size(); i != n; ++i) {
                os << " " << cur.operator[](i) << " | ";
                if (i < cur.anchor_.size())
@@ -539,11 +540,10 @@ void LCursor::insert(char c)
 
 void LCursor::insert(MathAtom const & t)
 {
-       //lyxerr << "LCursor::insert MathAtom" << endl;
+       //lyxerr << "LCursor::insert MathAtom '" << t << "'" << endl;
        macroModeClose();
        lyx::cap::selClearOrDel(*this);
        plainInsert(t);
-       lyxerr << "LCursor::insert MathAtom: cur:\n" << *this << endl;
 }
 
 
@@ -711,7 +711,6 @@ void LCursor::macroModeClose()
                return;
 
        string const name = s.substr(1);
-       lyxerr << "creating macro of name '" << name << "'" << endl;
 
        // prevent entering of recursive macros
        // FIXME: this is only a weak attempt... only prevents immediate
@@ -755,7 +754,7 @@ int LCursor::targetX() const
 
 bool LCursor::inMacroMode() const
 {
-       if (!pos() != 0)
+       if (pos() == 0)
                return false;
        MathUnknownInset const * p = prevAtom()->asUnknownInset();
        return p && !p->final();
index 6a6ceb3e7017e6e2c8ff69e08c025206748c6dd1..74af5a143969999e5f5a2fc8b326cbe4614d078e 100644 (file)
@@ -977,7 +977,6 @@ bool MathNestInset::interpret(LCursor & cur, char c)
        // handle macroMode
        if (cur.inMacroMode()) {
                string name = cur.macroName();
-               lyxerr << "interpret macro name: '" << name << "'" << endl;
 
                /// are we currently typing '#1' or '#2' or...?
                if (name == "\\#") {
@@ -1009,10 +1008,8 @@ bool MathNestInset::interpret(LCursor & cur, char c)
                                cur.backspace();
                                cur.niceInsert(MathAtom(new MathCommentInset));
                        } else if (c == '#') {
-                               lyxerr << "setting name to " << name + c << endl;
                                BOOST_ASSERT(cur.activeMacro());
                                cur.activeMacro()->setName(name + c);
-                               lyxerr << "set name to " << name + c << endl;
                        } else {
                                cur.backspace();
                                cur.niceInsert(createMathInset(string(1, c)));
@@ -1148,11 +1145,8 @@ bool MathNestInset::script(LCursor & cur, bool up)
                        lyxerr << "converting prev atom " << endl;
                        cur.prevAtom() = MathAtom(new MathScriptInset(cur.prevAtom(), up));
                }
-               lyxerr << "new scriptinset 2: cur:\n" << cur << endl;
                --cur.pos();
-               lyxerr << "new scriptinset 3: cur:\n" << cur << endl;
                MathScriptInset * inset = cur.nextAtom().nucleus()->asScriptInset();
-               lyxerr << "new scriptinset 3: inset:\n" << inset << endl;
                cur.push(*inset);
                cur.idx() = 1;
                cur.pos() = 0;