M-m <space> as substitute for the old C-<space> <space> 'enlarge space'

feature


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2339 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-07-25 14:15:05 +00:00
parent 0563d2e80b
commit cd8d582c67
7 changed files with 38 additions and 17 deletions

View File

@ -1,3 +1,7 @@
2001-07-25 André Pönitz <poenitz@gmx.net>
* formulabase.C: re-enable 'space enlargement' feature
2001-07-22 André Pönitz <poenitz@gmx.net> 2001-07-22 André Pönitz <poenitz@gmx.net>
* math_cursor.C: fix "pullArg" behaviour * math_cursor.C: fix "pullArg" behaviour

View File

@ -617,6 +617,18 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
} }
break; break;
case LFUN_MATH_SPACE:
{
bv->lockedInsetStoreUndo(Undo::EDIT);
MathSpaceInset * p = mathcursor->prevSpaceInset();
if (p)
p->incSpace();
else
mathcursor->insert(new MathSpaceInset(1));
updateLocal(bv, true);
break;
}
case LFUN_MATH_DELIM: case LFUN_MATH_DELIM:
{ {
bv->lockedInsetStoreUndo(Undo::INSERT); bv->lockedInsetStoreUndo(Undo::INSERT);

View File

@ -1103,6 +1103,14 @@ MathUpDownInset * MathCursor::prevUpDownInset() const
} }
MathSpaceInset * MathCursor::prevSpaceInset() const
{
normalize();
MathInset * p = array().prevInset(cursor().pos_);
return (p && p->isSpaceInset()) ? static_cast<MathSpaceInset *>(p) : 0;
}
MathArray & MathCursor::array() const MathArray & MathCursor::array() const
{ {
static MathArray dummy; static MathArray dummy;

View File

@ -26,6 +26,7 @@
class MathInset; class MathInset;
class MathFuncInset; class MathFuncInset;
class MathUpDownInset; class MathUpDownInset;
class MathSpaceInset;
class InsetFormulaBase; class InsetFormulaBase;
class MathArray; class MathArray;
class MathXArray; class MathXArray;
@ -259,6 +260,8 @@ public:
MathInset * prevInset() const; MathInset * prevInset() const;
/// ///
MathUpDownInset * prevUpDownInset() const; MathUpDownInset * prevUpDownInset() const;
///
MathSpaceInset * prevSpaceInset() const;
/// ///
MathFuncInset * imacro; MathFuncInset * imacro;

View File

@ -182,6 +182,8 @@ public:
virtual bool isUpDownInset() const { return false; } virtual bool isUpDownInset() const { return false; }
/// Identifies BigopInsets /// Identifies BigopInsets
virtual bool isBigopInset() const { return false; } virtual bool isBigopInset() const { return false; }
/// Identifies SpaceInsets
virtual bool isSpaceInset() const { return false; }
/// ///
virtual bool isActive() const { return nargs() > 0; } virtual bool isActive() const { return nargs() > 0; }

View File

@ -34,15 +34,14 @@ void MathSpaceInset::draw(Painter & pain, int x, int y)
xp[2] = x + width_ - 2; yp[2] = y; xp[2] = x + width_ - 2; yp[2] = y;
xp[3] = x + width_ - 2; yp[3] = y - 3; xp[3] = x + width_ - 2; yp[3] = y - 3;
pain.lines(xp, yp, 4, (space_) ? LColor::latex : LColor::math); pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math);
} }
void MathSpaceInset::Write(std::ostream & os, bool /* fragile */) const void MathSpaceInset::Write(std::ostream & os, bool /* fragile */) const
{ {
if (space_ >= 0 && space_ < 6) { if (space_ >= 0 && space_ < 6)
os << '\\' << latex_mathspace[space_] << ' '; os << '\\' << latex_mathspace[space_] << ' ';
}
} }
@ -54,26 +53,19 @@ void MathSpaceInset::WriteNormal(std::ostream & os) const
void MathSpaceInset::Metrics(MathStyles st, int, int) void MathSpaceInset::Metrics(MathStyles st, int, int)
{ {
size_ = st; size_ = st;
width_ = space_ ? space_ * 2 : 2; width_ = space_ ? space_ * 2 : 2;
if (space_ > 3) if (space_ > 3)
width_ *= 2; width_ *= 2;
if (space_ == 5) if (space_ == 5)
width_ *= 2; width_ *= 2;
width_ += 4; width_ += 4;
ascent_ = 4; ascent_ = 4;
descent_ = 0; descent_ = 0;
} }
void MathSpaceInset::SetSpace(int sp) void MathSpaceInset::incSpace()
{
space_ = sp;
Metrics(size_);
}
int MathSpaceInset::GetSpace()
{ {
return space_; space_ = (space_ + 1) % 6;
} }

View File

@ -25,9 +25,9 @@ public:
/// ///
void Metrics(MathStyles st, int asc = 0, int des = 0); void Metrics(MathStyles st, int asc = 0, int des = 0);
/// ///
void SetSpace(int sp); bool isSpaceInset() const { return true; }
/// ///
int GetSpace(); void incSpace();
private: private:
/// ///
int space_; int space_;