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(); macroModeClose();
MathGridInset safe = grabAndEraseSelection(); MathGridInset safe = grabAndEraseSelection();
plainInsert(t); plainInsert(t);
int x, y;
getPos(x, y);
// enter the new inset and move the contents of the selection if possible // enter the new inset and move the contents of the selection if possible
if (t->isActive()) { if (t->isActive()) {
posLeft(); posLeft();
pushLeft(nextAtom()); pushLeft(nextAtom());
paste(safe); 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
} }
/* void MathArray::setXY(int x, int y)
std::ostream & operator<<(std::ostream & os, MathArray const & ar)
{ {
os << ar.data(); xo_ = x;
yo_ = y;
} }
*/

View File

@ -124,6 +124,8 @@ public:
int xm() const { return xo_ + dim_.w / 2; } int xm() const { return xo_ + dim_.w / 2; }
/// access to cached y coordinate of mid point of last drawing /// access to cached y coordinate of mid point of last drawing
int ym() const { return yo_ + (dim_.d - dim_.a) / 2; } 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 /// returns x coordinate of given position in the array
int pos2x(size_type pos) const; int pos2x(size_type pos) const;
/// returns position of given x coordinate /// 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, bool MathScriptInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
int) const 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; return false;
// otherwise go to last base position
// in nuclues?
if (idx == 2) {
idx = up;
pos = 0;
} else {
idx = 2; idx = 2;
pos = cell(2).size(); 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; return true;
} }