]> git.lyx.org Git - features.git/commitdiff
re-enable { and } in seperate cells;
authorAndré Pönitz <poenitz@gmx.net>
Wed, 29 Aug 2001 16:23:54 +0000 (16:23 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 29 Aug 2001 16:23:54 +0000 (16:23 +0000)
nuke MathScopeInset;

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

src/mathed/Makefile.am
src/mathed/math_cursor.C
src/mathed/math_parser.C
src/mathed/math_scopeinset.C [deleted file]
src/mathed/math_scopeinset.h [deleted file]

index a0f324a8671b2cd2a062a95d4458bc415d433af8..ca542e96686652cf7a96e9fab2c83a7abd1eef81 100644 (file)
@@ -76,8 +76,6 @@ libmathed_la_SOURCES = \
        math_parser.h \
        math_rootinset.C \
        math_rootinset.h \
-       math_scopeinset.C \
-       math_scopeinset.h \
        math_scriptinset.C \
        math_scriptinset.h \
        math_sizeinset.C \
index 124a0ac6104756b57fc13317bc9ac10152d49c91..5241a194a50b9c79210b8239f54f09e067ce653e 100644 (file)
@@ -35,7 +35,6 @@
 #include "math_charinset.h"
 #include "math_deliminset.h"
 #include "math_matrixinset.h"
-#include "math_scopeinset.h"
 #include "math_scriptinset.h"
 #include "math_spaceinset.h"
 #include "math_parser.h"
@@ -1300,14 +1299,11 @@ void MathCursor::interpret(string const & s)
                return;
        }
 
-       if (c == '{') {
-               niceInsert(new MathScopeInset);
+       if (c == '{' || c == '}') {
+               niceInsert(new MathCharInset(c, LM_TC_SPECIAL));
                return;
        }
 
-       if (c == '}') // ignore it
-               return;
-
        if (isalpha(c) && (lastcode_ == LM_TC_GREEK || lastcode_ == LM_TC_GREEK1)) {
                static char const greek[26] =
                        {'A', 'B', 'X',  0 , 'E',  0 ,  0 , 'H', 'I',  0 ,
index 3ca1a4a86777764e0ab398b10a76e61ea08c406f..4eadb7bc9900b6814d0157855fa5d3765e702eb3 100644 (file)
@@ -37,7 +37,6 @@
 #include "math_macrotemplate.h"
 #include "math_matrixinset.h"
 #include "math_rootinset.h"
-#include "math_scopeinset.h"
 #include "math_sqrtinset.h"
 #include "math_scriptinset.h"
 #include "math_sqrtinset.h"
@@ -439,7 +438,7 @@ void Parser::tokenize(string const & buffer)
                }
        }
 
-#if 0
+#if 1
        lyxerr << "\nTokens: ";
        for (unsigned i = 0; i < tokens_.size(); ++i)
                lyxerr << tokens_[i];
@@ -655,7 +654,7 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
                }
 
                if (flags & FLAG_BLOCK) {
-                       if (t.cat() == catEnd || t.cat() == catAlign || t.cs() == "\\")
+                       if (t.cat() == catAlign || t.cs() == "\\")
                                return;
                        if (t.cs() == "end") {
                                getArg('{', '}');
@@ -683,15 +682,13 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
                }
 
                else if (t.cat() == catBegin) {
-                       //lyxerr << " creating ScopeInset\n";
-                       array.push_back(new MathScopeInset);
-                       parse_into(array.back()->cell(0), FLAG_BRACE_LAST);
+                       array.push_back(new MathCharInset('{', LM_TC_SPECIAL));
                }
 
                else if (t.cat() == catEnd) {
-                       if (!(flags & FLAG_BRACE_LAST))
-                               lyxerr << " ##### unexpected end of block\n";
-                       return;
+                       if (flags & FLAG_BRACE_LAST)
+                               return;
+                       array.push_back(new MathCharInset('}', LM_TC_SPECIAL));
                }
                
                else if (t.cat() == catAlign) {
@@ -848,7 +845,21 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
                else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") {
                        limits = 0;
                        MathInset * p = createMathInset(t.cs());
-                       p->cell(0).swap(array);
+                       // search backward for position of last '{' if any
+                       int pos;
+                       for (pos = array.size() - 1; pos >= 0; --pos) {
+                               MathInset * q = array.nextInset(pos);
+                               if (q->getChar() == '{' && q->code() == LM_TC_SPECIAL)
+                                       break;
+                       }
+                       if (pos >= 0) {
+                               // found it -> use the part after '{' as "numerator", erase the '{'
+                               p->cell(0) = MathArray(array, pos + 1, array.size());
+                               array.erase(pos, array.size());
+                       } else {
+                               // not found -> use everything as "numerator"
+                               p->cell(0).swap(array);
+                       }
                        array.push_back(p);
                        parse_into(p->cell(1), FLAG_BLOCK);
                }
diff --git a/src/mathed/math_scopeinset.C b/src/mathed/math_scopeinset.C
deleted file mode 100644 (file)
index 199429d..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "math_scopeinset.h"
-#include "LColor.h"
-#include "Painter.h"
-#include "support.h"
-#include "support/LOstream.h"
-
-
-MathScopeInset::MathScopeInset()
-       : MathNestInset(1)
-{}
-
-
-MathInset * MathScopeInset::clone() const
-{   
-       return new MathScopeInset(*this);
-}
-
-
-void MathScopeInset::metrics(MathStyles st) const
-{
-       xcell(0).metrics(st);
-       size_    = st;
-       ascent_  = xcell(0).ascent();
-       descent_ = xcell(0).descent();
-       width_   = xcell(0).width() + mathed_string_width(LM_TC_TEX, st, "{}");
-}
-
-
-void MathScopeInset::draw(Painter & pain, int x, int y) const
-{ 
-       xo(x);
-       yo(y);
-       int d = mathed_char_width(LM_TC_TEX, size_, '{');
-       drawChar(pain, LM_TC_TEX, size_, x, y, '{');
-       xcell(0).draw(pain, x + d, y); 
-       drawChar(pain, LM_TC_TEX, size_, x + width_ - d, y, '}');
-       //pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
-}
-
-
-void MathScopeInset::write(std::ostream & os, bool fragile) const
-{
-       os << '{';
-       cell(0).write(os, fragile); 
-       os << '}';
-}
-
-
-void MathScopeInset::writeNormal(std::ostream & os) const
-{
-       os << "[scope ";
-       cell(0).writeNormal(os); 
-       os << "] ";
-}
diff --git a/src/mathed/math_scopeinset.h b/src/mathed/math_scopeinset.h
deleted file mode 100644 (file)
index 13cfdf6..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// -*- C++ -*-
-#ifndef MATH_SCOPEINSET_H
-#define MATH_SCOPEINSET_H
-
-#include "math_nestinset.h"
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-/** An inset for new scopes (i.e.  {....} blocks in LaTeX)
-    \author André Pönitz
- */
-class MathScopeInset : public MathNestInset {
-public:
-       ///
-       MathScopeInset();
-       ///
-       MathInset * clone() const;
-       ///
-       void draw(Painter &, int x, int y) const;
-       ///
-       void write(std::ostream &, bool fragile) const;
-       ///
-       void writeNormal(std::ostream &) const;
-       ///
-       void metrics(MathStyles st) const;
-};
-#endif