git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8898 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-08-13 12:05:27 +00:00
parent d2acd41055
commit eec2d548eb
4 changed files with 12 additions and 17 deletions

View 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>

View 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;
}

View 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();

View 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;