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>
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());
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;
}
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());
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())
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;
}
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
bool LCursor::inMacroMode() const
{
- if (!pos() != 0)
+ if (pos() == 0)
return false;
MathUnknownInset const * p = prevAtom()->asUnknownInset();
return p && !p->final();
// 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 == "\\#") {
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)));
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;