small bugfix for pasting into non-gridded inset (I broke that yesterday)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4988 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-08-15 10:02:53 +00:00
parent 5b652f0360
commit ee259f68d5
4 changed files with 29 additions and 6 deletions

View File

@ -92,7 +92,7 @@ void MathCursor::push(MathAtom & t)
void MathCursor::pushLeft(MathAtom & t) void MathCursor::pushLeft(MathAtom & t)
{ {
//cerr << "Entering atom "; t->write(cerr, false); cerr << " left\n"; //lyxerr << "Entering atom " << t << " left\n";
push(t); push(t);
t->idxFirst(idx(), pos()); t->idxFirst(idx(), pos());
} }
@ -100,7 +100,7 @@ void MathCursor::pushLeft(MathAtom & t)
void MathCursor::pushRight(MathAtom & t) void MathCursor::pushRight(MathAtom & t)
{ {
//cerr << "Entering atom "; t->write(cerr, false); cerr << " right\n"; //lyxerr << "Entering atom " << t << " right\n";
posLeft(); posLeft();
push(t); push(t);
t->idxLast(idx(), pos()); t->idxLast(idx(), pos());

View File

@ -1031,7 +1031,7 @@ MathInset::result_type MathGridInset::dispatch
} }
default: default:
break; return MathNestInset::dispatch(cmd, idx, pos);
} }
return UNDISPATCHED; return UNDISPATCHED;
} }

View File

@ -5,12 +5,11 @@
#include "math_nestinset.h" #include "math_nestinset.h"
#include "math_cursor.h" #include "math_cursor.h"
#include "math_mathmlstream.h" #include "math_mathmlstream.h"
#include "formulabase.h" #include "math_parser.h"
#include "funcrequest.h"
#include "debug.h" #include "debug.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
using std::vector;
MathNestInset::MathNestInset(idx_type nargs) MathNestInset::MathNestInset(idx_type nargs)
: MathDimInset(), cells_(nargs), lock_(false) : MathDimInset(), cells_(nargs), lock_(false)
@ -311,3 +310,24 @@ void MathNestInset::normalize(NormalStream & os) const
void MathNestInset::notifyCursorLeaves() void MathNestInset::notifyCursorLeaves()
{} {}
MathInset::result_type MathNestInset::dispatch
(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
switch (cmd.action) {
case LFUN_PASTE: {
//lyxerr << "pasting '" << cmd.argument << "'\n";
MathArray ar;
mathed_parse_cell(ar, cmd.argument);
cell(idx).insert(pos, ar);
pos += ar.size();
return DISPATCHED;
}
default:
return MathInset::dispatch(cmd, idx, pos);
}
return UNDISPATCHED;
}

View File

@ -101,6 +101,9 @@ public:
/// writes [, name(), and args in [] /// writes [, name(), and args in []
void normalize(NormalStream & os) const; void normalize(NormalStream & os) const;
/// local dispatcher
result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
protected: protected:
/// we store the cells in a vector /// we store the cells in a vector
typedef std::vector<MathArray> cells_type; typedef std::vector<MathArray> cells_type;