From cd8d582c67a873f32e0d1fac5212cc42765d9ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 25 Jul 2001 14:15:05 +0000 Subject: [PATCH] M-m as substitute for the old C- 'enlarge space' feature git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2339 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 4 ++++ src/mathed/formulabase.C | 12 ++++++++++++ src/mathed/math_cursor.C | 8 ++++++++ src/mathed/math_cursor.h | 3 +++ src/mathed/math_inset.h | 2 ++ src/mathed/math_spaceinset.C | 22 +++++++--------------- src/mathed/math_spaceinset.h | 4 ++-- 7 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 17c0c25748..384d5f81b6 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,7 @@ +2001-07-25 André Pönitz + + * formulabase.C: re-enable 'space enlargement' feature + 2001-07-22 André Pönitz * math_cursor.C: fix "pullArg" behaviour diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index baed9845a6..2dd0a2d97e 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -617,6 +617,18 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, } 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: { bv->lockedInsetStoreUndo(Undo::INSERT); diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index bba13ac2e4..ca5852a3ca 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -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(p) : 0; +} + + MathArray & MathCursor::array() const { static MathArray dummy; diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index c8a7e574e4..769143eb05 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -26,6 +26,7 @@ class MathInset; class MathFuncInset; class MathUpDownInset; +class MathSpaceInset; class InsetFormulaBase; class MathArray; class MathXArray; @@ -259,6 +260,8 @@ public: MathInset * prevInset() const; /// MathUpDownInset * prevUpDownInset() const; + /// + MathSpaceInset * prevSpaceInset() const; /// MathFuncInset * imacro; diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 76279a1970..b5ad07d7d1 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -182,6 +182,8 @@ public: virtual bool isUpDownInset() const { return false; } /// Identifies BigopInsets virtual bool isBigopInset() const { return false; } + /// Identifies SpaceInsets + virtual bool isSpaceInset() const { return false; } /// virtual bool isActive() const { return nargs() > 0; } diff --git a/src/mathed/math_spaceinset.C b/src/mathed/math_spaceinset.C index 926546a72c..8f9d999825 100644 --- a/src/mathed/math_spaceinset.C +++ b/src/mathed/math_spaceinset.C @@ -34,15 +34,14 @@ void MathSpaceInset::draw(Painter & pain, int x, int y) xp[2] = x + width_ - 2; yp[2] = y; 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 { - if (space_ >= 0 && space_ < 6) { + if (space_ >= 0 && space_ < 6) os << '\\' << latex_mathspace[space_] << ' '; - } } @@ -54,26 +53,19 @@ void MathSpaceInset::WriteNormal(std::ostream & os) const void MathSpaceInset::Metrics(MathStyles st, int, int) { - size_ = st; + size_ = st; width_ = space_ ? space_ * 2 : 2; if (space_ > 3) width_ *= 2; if (space_ == 5) width_ *= 2; - width_ += 4; - ascent_ = 4; + width_ += 4; + ascent_ = 4; descent_ = 0; } -void MathSpaceInset::SetSpace(int sp) -{ - space_ = sp; - Metrics(size_); -} - - -int MathSpaceInset::GetSpace() +void MathSpaceInset::incSpace() { - return space_; + space_ = (space_ + 1) % 6; } diff --git a/src/mathed/math_spaceinset.h b/src/mathed/math_spaceinset.h index 620f4d2bdd..df88004c9a 100644 --- a/src/mathed/math_spaceinset.h +++ b/src/mathed/math_spaceinset.h @@ -25,9 +25,9 @@ public: /// void Metrics(MathStyles st, int asc = 0, int des = 0); /// - void SetSpace(int sp); + bool isSpaceInset() const { return true; } /// - int GetSpace(); + void incSpace(); private: /// int space_;