up/down tweaks

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4915 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-08-09 08:14:18 +00:00
parent b54bf51387
commit 73cd1891e8
4 changed files with 35 additions and 12 deletions

View File

@ -380,11 +380,15 @@ void MathCursor::niceInsert(MathAtom const & t)
macroModeClose();
MathGridInset safe = grabAndEraseSelection();
plainInsert(t);
int x, y;
getPos(x, y);
// enter the new inset and move the contents of the selection if possible
if (t->isActive()) {
posLeft();
pushLeft(nextAtom());
paste(safe);
// lets pretend we've not moved too far away...
array().setXY(x, y);
}
}

View File

@ -382,10 +382,9 @@ void MathArray::towards(int & x, int & y) const
}
/*
std::ostream & operator<<(std::ostream & os, MathArray const & ar)
void MathArray::setXY(int x, int y)
{
os << ar.data();
xo_ = x;
yo_ = y;
}
*/

View File

@ -124,6 +124,8 @@ public:
int xm() const { return xo_ + dim_.w / 2; }
/// access to cached y coordinate of mid point of last drawing
int ym() const { return yo_ + (dim_.d - dim_.a) / 2; }
/// write access to coordinate;
void setXY(int x, int y);
/// returns x coordinate of given position in the array
int pos2x(size_type pos) const;
/// returns position of given x coordinate

View File

@ -325,17 +325,35 @@ bool MathScriptInset::idxLeft(idx_type &, pos_type &) const
bool MathScriptInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
int) const
{
if ((idx == 1 && up) || (idx == 0 && !up))
if (idx == 1) {
// if we are 'up' we can't go further up
if (up)
return false;
// in nuclues?
if (idx == 2) {
idx = up;
pos = 0;
} else {
// otherwise go to last base position
idx = 2;
pos = cell(2).size();
}
else if (idx == 0) {
// if we are 'down' we can't go further down
if (!up)
return false;
idx = 2;
pos = cell(2).size();
}
else {
// in nucleus
// don't go up/down unless in last position
if (pos != cell(2).size())
return false;
// don't go up/down if there is no cell.
if (!has(up))
return false;
// otherwise move into the first position
idx = up;
pos = 0;
}
return true;
}