]> git.lyx.org Git - features.git/commitdiff
M-m <space> as substitute for the old C-<space> <space> 'enlarge space'
authorAndré Pönitz <poenitz@gmx.net>
Wed, 25 Jul 2001 14:15:05 +0000 (14:15 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 25 Jul 2001 14:15:05 +0000 (14:15 +0000)
feature

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2339 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/formulabase.C
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_inset.h
src/mathed/math_spaceinset.C
src/mathed/math_spaceinset.h

index 17c0c257482f74006464c22a24ff8c66ad181173..384d5f81b66f77b4d582d0ceb80c54f8ca9acf5f 100644 (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>
 
        * math_cursor.C: fix "pullArg" behaviour
index baed9845a60ac467f28a3c50411109ab55515ed9..2dd0a2d97e71731d463f1112a6e3e91cd027811d 100644 (file)
@@ -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);
index bba13ac2e461a10782831660c2e0754e47ce6ef4..ca5852a3ca87b3fa169312d70a062fb38ba426ad 100644 (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
 {
        static MathArray dummy;
index c8a7e574e41c4f88ca8e20b9a5914d182f337743..769143eb0561d4d601f7b3267b8a2cfaa1402d8a 100644 (file)
@@ -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;
index 76279a19703cc7eb450b197d5d59b7bd1e465224..b5ad07d7d14c0bd3b7877827ff98b52915c765b1 100644 (file)
@@ -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; }
 
index 926546a72cd83c6b79c262e8d526a5678d33b08d..8f9d99982554dbd9e4599fe35f0400405b293f8f 100644 (file)
@@ -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;
 }
index 620f4d2bdd4ae1c83e8c11f8331890bafde0e8ec..df88004c9aecb6eb66e903d1e2a3abfb781814d1 100644 (file)
@@ -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_;